Attachment 'csharp.py'

Download

   1 # -*- coding: iso-8859-1 -*-
   2 """
   3    MoinMoin - C# Source Parser
   4 
   5    Copyright (c) 2005 by Zoran Isailovski <nuspheratu-4moin@yahoo.de>
   6    All rights reserved.
   7 
   8    Based on parser cplusplus.py by Taesu Pyo, which was copyrighted as follows:
   9       cplusplus.py
  10       Copyright (c) 2002 by Taesu Pyo <bigflood@hitel.net>
  11       All rights reserved.
  12 """
  13 
  14 from MoinMoin.util.ParserBase import ParserBase
  15 
  16 Dependencies = []
  17 
  18 class Parser(ParserBase):
  19 
  20     parsername = "ColorizedCSharp"
  21     extensions = ['.cs']
  22     Dependencies = []
  23 
  24     def setupRules(self):
  25         ParserBase.setupRules(self)
  26 
  27         self.addRulePair("Comment","/[*]","[*]/")
  28         self.addRule("Comment","//.*$")
  29         self.addRulePair("String",'L?"',r'$|[^\\](\\\\)*"')
  30         self.addRule("Char",r"'\\.'|'[^\\]'")
  31         self.addRule("Number",r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?")
  32         self.addRule("Preprc",r"^\s*#(.*\\\n)*(.*(?!\\))$")
  33         self.addRule("ID","[a-zA-Z_][0-9a-zA-Z_]*")
  34         self.addRule("SPChar",r"[~!%^&*()+=|\[\]:;,.<>/?{}-]")
  35 
  36         self.addReserved(reserved_words)
  37         self.addConstant(constant_words)
  38 
  39         self.addWords(reserved_words2,'ResWord2')
  40         self.addWords(special_words,'Special')
  41 
  42 
  43 ######################################################################
  44 ## 
  45 ## Token Classifications
  46 ## 
  47 ######################################################################
  48 
  49 reserved_words = '''\
  50 abstract event new struct
  51 as explicit null switch
  52 base extern object this
  53 bool false operator throw
  54 break finally out true
  55 byte fixed override try
  56 case float params typeof
  57 catch for private uint
  58 char foreach protected ulong
  59 checked goto public unchecked
  60 class if readonly unsafe
  61 const implicit ref ushort
  62 continue in return using
  63 decimal int sbyte virtual
  64 default interface sealed volatile
  65 delegate internal short void
  66 do is sizeof while
  67 double lock stackalloc
  68 else long static
  69 enum namespace string
  70 '''.split()
  71 
  72 
  73 reserved_words2 = 'object bool char byte short ushort int uint long ulong float double string'.split()
  74 special_words = 'this base'.split()
  75 constant_words = 'true false null'.split()
  76 
  77 ##reserved_words = [ word for word in reserved_words
  78 ##                   if word not in reserved_words2 + special_words + constant_words ]

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2012-01-05 09:14:39, 0.4 KB) [[attachment:AutoCreatedMoinMoinTestPlugin.pyo]]
  • [get | view] (2012-01-05 09:14:39, 15.2 KB) [[attachment:Calendar.py]]
  • [get | view] (2012-01-05 09:14:39, 14.1 KB) [[attachment:Calendar.pyc]]
  • [get | view] (2012-01-05 09:14:39, 13.8 KB) [[attachment:Calendar.pyo]]
  • [get | view] (2012-01-05 09:14:39, 0.1 KB) [[attachment:__init__.py]]
  • [get | view] (2012-01-05 09:14:39, 0.3 KB) [[attachment:__init__.pyc]]
  • [get | view] (2012-01-05 09:14:39, 0.3 KB) [[attachment:__init__.pyo]]
  • [get | view] (2012-01-05 09:14:39, 39.8 KB) [[attachment:__wiki.py]]
  • [get | view] (2012-01-05 09:14:39, 3.2 KB) [[attachment:basic.py]]
  • [get | view] (2012-01-05 09:14:39, 4.4 KB) [[attachment:basic.pyc]]
  • [get | view] (2012-01-05 09:14:39, 4.5 KB) [[attachment:basic.pyo]]
  • [get | view] (2012-01-05 09:14:39, 0.6 KB) [[attachment:cpp.py]]
  • [get | view] (2012-01-05 09:14:39, 0.4 KB) [[attachment:cpp.pyc]]
  • [get | view] (2012-01-05 09:14:39, 0.4 KB) [[attachment:cpp.pyo]]
  • [get | view] (2012-01-05 09:14:39, 2.3 KB) [[attachment:csharp.py]]
  • [get | view] (2012-01-05 09:14:39, 2.0 KB) [[attachment:csharp.pyo]]
  • [get | view] (2012-01-05 09:14:39, 0.6 KB) [[attachment:html.py]]
  • [get | view] (2012-01-05 09:14:39, 1.2 KB) [[attachment:html.pyc]]
  • [get | view] (2012-01-05 09:14:39, 0.6 KB) [[attachment:html.pyo]]
  • [get | view] (2012-01-05 09:14:39, 2.2 KB) [[attachment:lisp.py]]
  • [get | view] (2012-01-05 09:14:39, 1.2 KB) [[attachment:lisp.pyo]]
  • [get | view] (2012-01-05 09:14:39, 0.7 KB) [[attachment:quote.py]]
  • [get | view] (2012-01-05 09:14:39, 1.1 KB) [[attachment:quote.pyc]]
  • [get | view] (2012-01-05 09:14:39, 1.1 KB) [[attachment:quote.pyo]]
  • [get | view] (2012-01-05 09:14:39, 2.7 KB) [[attachment:scheme.py]]
  • [get | view] (2012-01-05 09:14:39, 1.7 KB) [[attachment:scheme.pyc]]
  • [get | view] (2012-01-05 09:14:39, 1.0 KB) [[attachment:scheme.pyo]]
  • [get | view] (2012-01-05 09:14:39, 0.6 KB) [[attachment:xml.py]]
  • [get | view] (2012-01-05 09:14:39, 1.3 KB) [[attachment:xml.pyc]]
  • [get | view] (2012-01-05 09:14:39, 0.9 KB) [[attachment:xml.pyo]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.