~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to MoinMoin/parser/pascal.py

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mfrom: (0.9.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080622211713-fpo2zrq3s5dfecxg
Tags: 1.7.0-3
Simplify /etc/moin/wikilist format: "USER URL" (drop unneeded middle
CONFIG_DIR that was wrongly advertised as DATA_DIR).  Make
moin-mass-migrate handle both formats and warn about deprecation of
the old one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: iso-8859-1 -*-
2
 
"""
3
 
        MoinMoin - Pascal Source Parser
4
 
 
5
 
    @copyright: 2004-2005 by Johannes Berg <johannes@sipsolutions.net>
6
 
    @license: GNU GPL, see COPYING for details.
7
 
"""
8
 
 
9
 
from MoinMoin.util.ParserBase import ParserBase
10
 
 
11
 
Dependencies = []
12
 
 
13
 
class Parser(ParserBase):
14
 
 
15
 
    parsername = 'ColorizedPascal'
16
 
    extensions = ['.pas']
17
 
    Dependencies = []
18
 
 
19
 
    def __init__(self, raw, request, **kw):
20
 
        ParserBase.__init__(self,raw,request,**kw)
21
 
        self._ignore_case = 1
22
 
 
23
 
    def setupRules(self):
24
 
        ParserBase.setupRules(self)
25
 
        
26
 
        self.addRulePair("Comment","\(\*","\*\)")
27
 
        self.addRulePair("Comment","\{","\}")
28
 
        self.addRule("Comment","//.*$")
29
 
        self.addRulePair("String",'\'','\'')
30
 
        self.addRule("Char",r"'\\.'|#[a-f0-9][a-f0-9]")
31
 
        self.addRule("Number",r"[0-9](\.[0-9]*)?(eE[+-][0-9])?|\$[0-9a-fA-F]+")
32
 
        self.addRule("ID","[a-zA-Z_][0-9a-zA-Z_]*")
33
 
        self.addRule("SPChar",r"[~!%^&*()+=|\[\]:;,.<>/?{}-]")
34
 
        
35
 
        reserved_words = ['class','interface','set','uses','unit',
36
 
                          'byte','integer','longint','float','double',
37
 
                          'extended','char','shortint','boolean',
38
 
                          'var','const','private','public','protected',
39
 
                          'new','this','super','abstract','native',
40
 
                          'synchronized','transient','volatile','strictfp',
41
 
                          'if','else','while','for','do','case','default',
42
 
                          'try','except','finally','raise','continue','break',
43
 
                          'begin','end','type','class','implementation',
44
 
                          'procedure','function','constructor','destructor']
45
 
        
46
 
        self.addReserved(reserved_words)
47
 
        
48
 
        constant_words = ['true','false','nil']
49
 
        
50
 
        self.addConstant(constant_words)