Attachment 'matlab.py'
Download 1 # -*- coding: iso-8859-1 -*-
2 """
3 MoinMoin - Matlab Source Parser
4
5 Copyleft 2005 Trausti Kristjansson
6 No rights reserved.
7
8 Based on Pascal Source Parser by Johannes Berg
9
10 """
11
12 from MoinMoin.util.ParserBase import ParserBase
13
14 Dependencies = []
15
16 class Parser(ParserBase):
17
18 parsername = 'ColorizedMatlab'
19 extensions = ['.m']
20 Dependencies = []
21
22 def __init__(self, raw, request, **kw):
23 ParserBase.__init__(self,raw,request,**kw)
24 self._ignore_case = 1
25
26 def setupRules(self):
27 ParserBase.setupRules(self)
28
29 self.addRule("Comment","%.*$")
30 self.addRulePair("String",'\'','\'')
31 self.addRule("Char",r"'\\.'|#[a-f0-9][a-f0-9]")
32 self.addRule("Number",r"[0-9](\.[0-9]*)?(eE[+-][0-9])?|\$[0-9a-fA-F]+")
33 self.addRule("ID","[a-zA-Z_][0-9a-zA-Z_]*")
34 self.addRule("SPChar",r"[~!%^&*()+=|\[\]:;,.<>/?{}-]")
35
36 reserved_words = [ 'break'
37 ,'case'
38 ,'catch'
39 ,'continue'
40 ,'else'
41 ,'elseif'
42 ,'end'
43 ,'for'
44 ,'function'
45 ,'global'
46 ,'if'
47 ,'otherwise'
48 ,'persistent'
49 ,'return'
50 ,'switch'
51 ,'try'
52 ,'while']
53
54 self.addReserved(reserved_words)
55
56 constant_words = ['true','false','nil']
57
58 self.addConstant(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.You are not allowed to attach a file to this page.