Attachment 'visualbasic.py'
Download 1 # -*- coding: iso-8859-1 -*-
2 """
3 MoinMoin - highlighting VB Source Parser
4
5 @license: GNU GPL, see COPYING for details.
6 """
7
8 from MoinMoin.util.ParserBase import ParserBase
9
10 Dependencies = ["time"]
11
12
13 class Parser(ParserBase):
14 """ Send colored VB source.
15 """
16 parsername = "ColorizedVB"
17 extensions = ['.bas', '.cls', '.frm', '.vbs', '.CATScript', '.catvbs', '.wsf']
18 Dependencies = []
19
20 def setupRules(self):
21 ParserBase.setupRules(self)
22
23 #self.addRulePair("Comment","/[*]","[*]/")
24 self.addRule("Comment","'.*$")
25 self.addRulePair("String",'L?"',r'$|[^\\](\\\\)*"')
26 self.addRule("Char",r"'\\.'|'[^\\]'")
27 self.addRule("Number",r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?")
28 self.addRule("Preprc",r"^\s*#(.*\\\n)*(.*(?!\\))$")
29 self.addRule("ID","[a-zA-Z_][0-9a-zA-Z_]*")
30 self.addRule("SPChar",r"[~!%^&*()+=|\[\]:;,.<>/?{}-]")
31
32 _words_string = """and begin case call continue do each else elseif end erase
33 error event exit false for function get gosub goto if implement in load loop lset
34 me mid new next not nothing on or property raiseevent rem resume return rset
35 select set stop sub then to true unload until wend while with withevents
36 attribute alias as boolean byref byte byval const compare currency date declare dim double
37 enum explicit friend global integer let lib long module object option optional
38 preserve private property public redim single static string type variant
39 appactivate beep chdir chdrive close
40 deletesetting filecopy get input kill line lock unlock lset mid mkdir name
41 open print put randomize reset rmdir rset savepicture savesetting seek
42 sendkeys setattr time unload width write debug call"""
43
44 reserved_words = _words_string.split()
45 reserved_words.extend(map(lambda X: X.title(), reserved_words))
46
47
48 _words2_string = """"""
49 reserved_words2 = _words2_string.split()
50 reserved_words2.extend(map(lambda X: X.title(), reserved_words2))
51
52 special_words = ['std','string','vector','map','set','cout','cin','cerr']
53 constant_words = ['True','False','Nothing','Empty']
54
55 self.addReserved(reserved_words)
56 self.addConstant(constant_words)
57
58 self.addWords(reserved_words2,'ResWord2')
59 self.addWords(special_words,'Special')
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.You are not allowed to attach a file to this page.