annotate MoinMoin/parser/text_pascal.py @ 5474:a2128aa8b830

merge moin/1.7
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 01 Feb 2010 01:45:22 +0100
parents 348c9b6e0033
children 5eb02932f387
rev   line source
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
2 """
2274
01f6172dabd0 remove tabs from source files, remove excludes from test_tab
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
3 MoinMoin - Pascal Source Parser
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
4
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1645
diff changeset
5 @copyright: 2004-2005 Johannes Berg <johannes@sipsolutions.net>
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
6 @license: GNU GPL, see COPYING for details.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
7 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
8
1128
52b85612832f rename ParserBase module to get it out from parser.modules list (it is no plugin)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 748
diff changeset
9 from MoinMoin.parser._ParserBase import ParserBase
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
10
2873
71d89ce8b878 Fix 'Toggle line numbers' link in code areas, so it gets translated for the current user's language.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
11 Dependencies = ['user'] # the "Toggle line numbers link" depends on user's language
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
12
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
13 class Parser(ParserBase):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
14
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
15 parsername = 'ColorizedPascal'
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
16 extensions = ['.pas']
2873
71d89ce8b878 Fix 'Toggle line numbers' link in code areas, so it gets translated for the current user's language.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
17 Dependencies = Dependencies
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
18
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
19 def __init__(self, raw, request, **kw):
1920
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
20 ParserBase.__init__(self, raw, request, **kw)
3911
348c9b6e0033 ParserBase (and other parsers deriving from it): cleanup / refactorings:
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2873
diff changeset
21 self._ignore_case = True
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
22
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
23 def setupRules(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
24 ParserBase.setupRules(self)
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
25
3911
348c9b6e0033 ParserBase (and other parsers deriving from it): cleanup / refactorings:
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2873
diff changeset
26 self.addRulePair("Comment", r"\(\*", r"\*\)")
348c9b6e0033 ParserBase (and other parsers deriving from it): cleanup / refactorings:
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2873
diff changeset
27 self.addRulePair("Comment", r"\{", r"\}")
348c9b6e0033 ParserBase (and other parsers deriving from it): cleanup / refactorings:
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2873
diff changeset
28 self.addRule("Comment", r"//.*$")
348c9b6e0033 ParserBase (and other parsers deriving from it): cleanup / refactorings:
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2873
diff changeset
29 self.addRulePair("String", r"'", r"'")
1920
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
30 self.addRule("Char", r"'\\.'|#[a-f0-9][a-f0-9]")
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
31 self.addRule("Number", r"[0-9](\.[0-9]*)?(eE[+-][0-9])?|\$[0-9a-fA-F]+")
3911
348c9b6e0033 ParserBase (and other parsers deriving from it): cleanup / refactorings:
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2873
diff changeset
32 self.addRule("ID", r"[a-zA-Z_][0-9a-zA-Z_]*")
1920
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
33 self.addRule("SPChar", r"[~!%^&*()+=|\[\]:;,.<>/?{}-]")
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
34
1920
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
35 reserved_words = ['class', 'interface', 'set', 'uses', 'unit',
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
36 'byte', 'integer', 'longint', 'float', 'double',
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
37 'extended', 'char', 'shortint', 'boolean',
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
38 'var', 'const', 'private', 'public', 'protected',
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
39 'new', 'this', 'super', 'abstract', 'native',
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
40 'synchronized', 'transient', 'volatile', 'strictfp',
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
41 'if', 'else', 'while', 'for', 'do', 'case', 'default',
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
42 'try', 'except', 'finally', 'raise', 'continue', 'break',
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
43 'begin', 'end', 'type', 'class', 'implementation',
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
44 'procedure', 'function', 'constructor', 'destructor', 'program']
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
45
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
46 self.addReserved(reserved_words)
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
47
1920
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
48 constant_words = ['true', 'false', 'nil']
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
49
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
50 self.addConstant(constant_words)
3911
348c9b6e0033 ParserBase (and other parsers deriving from it): cleanup / refactorings:
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2873
diff changeset
51