Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
annotate pygments_lexer_pseudocode2/lexers/algpseudocode.py @ 288:298841bc4dee
Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 22 May 2026 12:32:38 +0200 |
| parents | 051c8877ee22 |
| children | 6fc7f9c1d89d |
| rev | line source |
|---|---|
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2 # :- |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
3 # SPDX-FileCopyrightText: © 2026 Franz Glasner |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
4 # SPDX-License-Identifier: MIT |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
5 # :- |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
6 r"""A pseudocode lexer along the lines of CTAN's algpseudocode or |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
7 algpseudocodex. |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
8 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
9 """ |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
10 |
|
53
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
11 __all__ = ["AlgPseudocodeLexer", |
|
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
12 "AlgPseudocodeLexer_DE", "AlgPseudocodeLexer_FR"] |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
13 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
14 |
|
89
7414eed7b275
Introduce logging for unhandled explicit token types
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
15 import logging |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
16 import re |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
17 |
| 57 | 18 import pygments.util |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
19 from pygments.lexer import bygroups, include, words |
|
160
b4028838e0c8
Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
20 from pygments.token import (Comment, Error, Generic, Keyword, Name, Operator, |
|
286
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
21 Punctuation, Text, Whitespace, |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
22 string_to_tokentype) |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
23 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
24 # |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
25 # Relative imports do not work with pygments.lexers.load_lexer_from_file() |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
26 # in all of our supported Python releases. |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
27 # |
|
164
a4317957148b
Move all lexers into a subpackage pygments_lexer_pseudocode2.lexers.
Franz Glasner <fzglas.hg@dom66.de>
parents:
162
diff
changeset
|
28 from pygments_lexer_pseudocode2.lexers.bases import LexBase |
|
288
298841bc4dee
Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
286
diff
changeset
|
29 from pygments_lexer_pseudocode2.utils import ( |
|
298841bc4dee
Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
286
diff
changeset
|
30 REVERSED_STANDARD_TYPES, string_to_defined_tokentype) |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
31 from pygments_lexer_pseudocode2 import uniprops |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
32 |
|
89
7414eed7b275
Introduce logging for unhandled explicit token types
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
33 # |
|
7414eed7b275
Introduce logging for unhandled explicit token types
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
34 # As in the local imports: use an explicit name because __name__ is |
|
7414eed7b275
Introduce logging for unhandled explicit token types
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
35 # __builtins__ |
|
7414eed7b275
Introduce logging for unhandled explicit token types
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
36 # |
|
7414eed7b275
Introduce logging for unhandled explicit token types
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
37 _logger = logging.getLogger("pygments_lexer_pseudocode2.algpseudocode") |
|
7414eed7b275
Introduce logging for unhandled explicit token types
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
38 |
|
7414eed7b275
Introduce logging for unhandled explicit token types
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
39 |
|
53
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
40 class AlgPseudocodeLexer(LexBase): |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
41 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
42 """A pseudocode lexer along the lines of CTAN's algpseudocode or |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
43 algpseudocodex. |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
44 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
45 Some ideas (e.g. strings) are borrowed from Pygment's Python lexer. |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
46 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
47 """ |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
48 |
|
53
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
49 name = "AlgPseudocode" |
|
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
50 aliases = ["algpseudocode", "algpseudo"] |
|
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
51 filenames = ["*.algpseudo", "*.algpseudocode"] |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
52 mimetypes = [] |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
53 flags = re.MULTILINE |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
54 |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
55 LANG = "en" |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
56 TRANSLATIONS = { |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
57 "PROG": "PROGRAM", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
58 "PROGRAM": "PROGRAM", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
59 "ALGO": "ALGORITHM", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
60 "ALGORITHM": "ALGORITHM", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
61 "PROC": "PROCEDURE", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
62 "PROCEDURE": "PROCEDURE", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
63 "FUNC": "FUNCTION", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
64 "FUNCTION": "FUNCTION", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
65 "FN": "FUNCTION", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
66 "CLASS": "CLASS", |
|
99
857df2064831
\INPUT, \INPUTS, \OUTPUT, \OUTPUTS, \RETURN and \RETURNS as new commands (keywords)
Franz Glasner <fzglas.hg@dom66.de>
parents:
98
diff
changeset
|
67 "INPUT": "Input:", |
|
857df2064831
\INPUT, \INPUTS, \OUTPUT, \OUTPUTS, \RETURN and \RETURNS as new commands (keywords)
Franz Glasner <fzglas.hg@dom66.de>
parents:
98
diff
changeset
|
68 "INPUTS": "Inputs:", |
|
857df2064831
\INPUT, \INPUTS, \OUTPUT, \OUTPUTS, \RETURN and \RETURNS as new commands (keywords)
Franz Glasner <fzglas.hg@dom66.de>
parents:
98
diff
changeset
|
69 "OUTPUT": "Output:", |
|
857df2064831
\INPUT, \INPUTS, \OUTPUT, \OUTPUTS, \RETURN and \RETURNS as new commands (keywords)
Franz Glasner <fzglas.hg@dom66.de>
parents:
98
diff
changeset
|
70 "OUTPUTS": "Outputs:", |
|
857df2064831
\INPUT, \INPUTS, \OUTPUT, \OUTPUTS, \RETURN and \RETURNS as new commands (keywords)
Franz Glasner <fzglas.hg@dom66.de>
parents:
98
diff
changeset
|
71 "RETURNS": "Returns:", |
| 106 | 72 "ENSURE": "Ensure:", |
|
124
f916251d5647
Implement the "\REQUIRE" command from algpseudocodex
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
73 "REQUIRE": "Require:", |
|
61
392745b66969
The "\IS" keyword expansion
Franz Glasner <fzglas.hg@dom66.de>
parents:
58
diff
changeset
|
74 "IS": "IS", |
| 82 | 75 "WITH": "WITH", |
| 97 | 76 "IF": "IF", |
| 77 "THEN": "THEN", | |
| 78 "ELSE": "ELSE", | |
| 79 "ELSEIF": "ELSE IF", | |
| 80 "ELSIF": "ELSE IF", | |
| 81 "ELIF": "ELSE IF", | |
|
111
d6f3a1d1bedd
Some more keywords (\FROM, \TO, \IN)
Franz Glasner <fzglas.hg@dom66.de>
parents:
109
diff
changeset
|
82 "DO": "DO", # in WHILE ... DO |
| 97 | 83 "WHILE": "WHILE", |
| 84 "FOR": "FOR", | |
| 85 "FORALL": "FOR ALL", | |
|
111
d6f3a1d1bedd
Some more keywords (\FROM, \TO, \IN)
Franz Glasner <fzglas.hg@dom66.de>
parents:
109
diff
changeset
|
86 "FROM": "FROM", |
|
d6f3a1d1bedd
Some more keywords (\FROM, \TO, \IN)
Franz Glasner <fzglas.hg@dom66.de>
parents:
109
diff
changeset
|
87 "TO": "TO", |
|
d6f3a1d1bedd
Some more keywords (\FROM, \TO, \IN)
Franz Glasner <fzglas.hg@dom66.de>
parents:
109
diff
changeset
|
88 "IN": "IN", # as in FOR ... IN |
| 97 | 89 "STEP": "STEP", |
| 90 "LOOP": "LOOP", | |
| 91 "REPEAT": "REPEAT", | |
| 92 "UNTIL": "UNTIL", | |
|
104
ffe6ea2cf69b
Allow "\RETURN" and "\RETURNS" commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
103
diff
changeset
|
93 "RETURN": "RETURN", |
| 97 | 94 "BEGIN": "BEGIN", |
| 95 "END": "END", # not in END_TRANSLATIONS | |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
96 } |
| 57 | 97 END_TRANSLATIONS = { |
| 98 "PROG": "END OF PROGRAM", | |
| 99 "PROGRAM": "END OF PROGRAM", | |
| 100 "ALGO": "END OF ALGORITHM", | |
| 101 "ALGORITHM": "END OF ALGORITHM", | |
| 102 "PROC": "END OF PROCEDURE", | |
| 103 "PROCEDURE": "END OF PROCEDURE", | |
| 104 "FUNC": "END OF FUNCTION", | |
| 105 "FUNCTION": "END OF FUNCTION", | |
| 106 "FN": "END OF FUNCTION", | |
| 107 "CLASS": "END OF CLASS", | |
| 97 | 108 "IF": "END IF", |
| 109 "WHILE": "END WHILE", | |
| 110 "FOR": "END FOR", | |
| 111 "FORALL": "END FOR ALL", | |
| 112 "LOOP": "END LOOP", | |
| 57 | 113 } |
| 114 DEFAULT_END_PREFIX = "END OF " | |
|
123
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
115 SYMBOL_REMARK = u"▷" # U+25B7: Unicode 1.0 (Geometric Shapes) |
|
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
116 # SYMBOL_REMARK = u"▻" # U+25BB: Unicode 1.0 (Geometric Shapes) |
|
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
117 # SYMBOL_REMARK = u"⍝" # U+235D: Unicode 1.1 (Misc. Technical, APL) |
|
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
118 SYMBOL_BLOCK = u"◆" # U+25C6: Unicode 1.0 (Geometric Shapes) |
|
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
119 # SYMBOL_BLOCK = u"┃" # U+2503: Unicode 1.0 (Bow Drawing) |
|
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
120 # SYMBOL_BLOCK = u"●" # U+25CF: Unicode 1.0 (Geometric Shapes) |
|
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
121 SYMBOL_TEXTSTATEMENT = u"▪" # U+25AA: Unicode 1.0 (Geometric Shapes) |
|
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
122 # SYMBOL_TEXTSTATEMENT = u"■" # U+25A0: Unicode 1.0 (Geometric Shapes) |
|
39
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
38
diff
changeset
|
123 SYMBOLS = { |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
124 # Group REMARK |
|
58
be065e5c8042
Prepare symbols for a statement which defaults to token type "Text".
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
125 "REMARK": SYMBOL_REMARK, |
|
be065e5c8042
Prepare symbols for a statement which defaults to token type "Text".
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
126 "REM": SYMBOL_REMARK, |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
127 # Group STATEMENT |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
128 "STATEMENT": SYMBOL_BLOCK, |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
129 "STATE": SYMBOL_BLOCK, |
|
58
be065e5c8042
Prepare symbols for a statement which defaults to token type "Text".
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
130 "BLOCK": SYMBOL_BLOCK, |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
131 # Group TEXTSTATEMENT |
|
58
be065e5c8042
Prepare symbols for a statement which defaults to token type "Text".
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
132 "TEXTSTATEMENT": SYMBOL_TEXTSTATEMENT, |
|
78
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
133 "TEXTSTATE": SYMBOL_TEXTSTATEMENT, |
|
58
be065e5c8042
Prepare symbols for a statement which defaults to token type "Text".
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
134 "TSTATEMENT": SYMBOL_TEXTSTATEMENT, |
|
be065e5c8042
Prepare symbols for a statement which defaults to token type "Text".
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
135 "TSTATE": SYMBOL_TEXTSTATEMENT, |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
136 "TEXTBLOCK": SYMBOL_TEXTSTATEMENT, |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
137 "TBLOCK": SYMBOL_TEXTSTATEMENT, |
|
123
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
138 "<-": u"⟵", # U+27F5: Unicode 3.2 (Supplemental Arrows-A) |
|
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
139 "->": u"⟶", # U+27F6: Unicode 3.2 (Supplemental Arrows-A) |
|
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
140 "<->": u"⟷", # U+27F7: Unicode 3.2 (Supplemental Arrows-A) |
|
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
141 # "=>": u"⟹", # U+27F9: Unicode 3.2 (Supplemental Arrows-A) |
|
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
142 # "<=>": u"⟺", # U+27FA: Unicode 3.2 (Supplemental Arrows-A) |
|
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
143 # "<-": u"←", # U+2190: Unicode 1.0 (Arrows) |
|
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
144 # "->": u"→", # U+2192: Unicode 1.0 (Arrows) |
|
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
145 # "<->": u"↔", # U+2194: Unicode 1.0 (Arrows) |
|
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
146 "=>": u"⇒", # U+21D2: Unicode 1.0 (Arrows) |
|
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
147 "<=>": u"⇔", # U+21D4: Unicode 1.0 (Arrows) |
|
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
148 "<=": u"≤", # U+2264: Unicode 1.0 (Mathematical Operators) |
|
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
149 ">=": u"≥", # U+2265: Unicode 1.0 (Mathematical Operators) |
|
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
150 "<>": u"≠", # U+2260: Unicode 1.0 (Mathematical Operators) |
|
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
151 "!=": u"≠", # U+2260: Unicode 1.0 (Mathematical Operators) |
|
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
152 ":=": u"∶=", # "≔" U+2254 not recognizable in my (small) mono font |
|
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
153 "=:": u"=∶", # "≕" U+2255 not recognizable in my (small) mono font |
|
4d96ace53ba1
Make it work on Python2 too with all tests by explicitely declaring some strings to be Unicode strings.
Franz Glasner <fzglas.hg@dom66.de>
parents:
122
diff
changeset
|
154 "?=": u"≟", # U+225F: Unicode 1.0 (Mathematical Operators) |
|
39
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
38
diff
changeset
|
155 } |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
156 |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
157 def op_translate(toktype): |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
158 |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
159 def _op_translate(lexer, match, ctx=None): |
|
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
160 kw = match.group().upper() |
|
38
69522d4cafac
Remove another unneeded local variable
Franz Glasner <fzglas.hg@dom66.de>
parents:
35
diff
changeset
|
161 yield match.start(), toktype, lexer.TRANSLATIONS.get(kw, kw) |
|
83
cd79d2c76347
If a Pygments callback gets a "Context" it must set the new position explicitely.
Franz Glasner <fzglas.hg@dom66.de>
parents:
82
diff
changeset
|
162 if ctx: |
|
cd79d2c76347
If a Pygments callback gets a "Context" it must set the new position explicitely.
Franz Glasner <fzglas.hg@dom66.de>
parents:
82
diff
changeset
|
163 ctx.pos = match.end() |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
164 |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
165 return _op_translate |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
166 |
| 57 | 167 def op_opt_end_translate(toktype): |
| 168 | |
| 169 def _op_end_translate(lexer, match, ctx=None): | |
| 170 if not lexer.no_end: | |
| 171 kw = match.group().upper() | |
| 172 yield (match.start(), | |
| 173 toktype, | |
| 174 lexer.END_TRANSLATIONS.get( | |
| 175 kw, | |
| 176 lexer.DEFAULT_END_PREFIX + kw)) | |
|
83
cd79d2c76347
If a Pygments callback gets a "Context" it must set the new position explicitely.
Franz Glasner <fzglas.hg@dom66.de>
parents:
82
diff
changeset
|
177 if ctx: |
|
cd79d2c76347
If a Pygments callback gets a "Context" it must set the new position explicitely.
Franz Glasner <fzglas.hg@dom66.de>
parents:
82
diff
changeset
|
178 ctx.pos = match.end() |
| 57 | 179 |
| 180 return _op_end_translate | |
| 181 | |
|
62
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
61
diff
changeset
|
182 def op_opt_ignore(toktype): |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
61
diff
changeset
|
183 |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
61
diff
changeset
|
184 def _op_opt_ignore(lexer, match, ctx=None): |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
61
diff
changeset
|
185 if not lexer.no_end: |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
61
diff
changeset
|
186 yield match.start(), toktype, match.group() |
|
83
cd79d2c76347
If a Pygments callback gets a "Context" it must set the new position explicitely.
Franz Glasner <fzglas.hg@dom66.de>
parents:
82
diff
changeset
|
187 if ctx: |
|
cd79d2c76347
If a Pygments callback gets a "Context" it must set the new position explicitely.
Franz Glasner <fzglas.hg@dom66.de>
parents:
82
diff
changeset
|
188 ctx.pos = match.end() |
|
62
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
61
diff
changeset
|
189 |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
61
diff
changeset
|
190 return _op_opt_ignore |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
61
diff
changeset
|
191 |
|
72
206017a08ed7
Refactor: Make the "op_space()" and related methods more flexible and allow a given fixed token type and value
Franz Glasner <fzglas.hg@dom66.de>
parents:
70
diff
changeset
|
192 def op_opt_ignore_or_fixed(toktype, value): |
|
206017a08ed7
Refactor: Make the "op_space()" and related methods more flexible and allow a given fixed token type and value
Franz Glasner <fzglas.hg@dom66.de>
parents:
70
diff
changeset
|
193 """Yield a fixed given token type and value or -- if the lexer's |
|
206017a08ed7
Refactor: Make the "op_space()" and related methods more flexible and allow a given fixed token type and value
Franz Glasner <fzglas.hg@dom66.de>
parents:
70
diff
changeset
|
194 `no_end` setting evals to ``True`` nothing. |
|
65
3f4223a79d2b
Normalize whitespace handling for entity names
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
195 |
|
3f4223a79d2b
Normalize whitespace handling for entity names
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
196 """ |
|
72
206017a08ed7
Refactor: Make the "op_space()" and related methods more flexible and allow a given fixed token type and value
Franz Glasner <fzglas.hg@dom66.de>
parents:
70
diff
changeset
|
197 |
|
206017a08ed7
Refactor: Make the "op_space()" and related methods more flexible and allow a given fixed token type and value
Franz Glasner <fzglas.hg@dom66.de>
parents:
70
diff
changeset
|
198 def _op_opt_ignore_or_fixed(lexer, match, ctx=None): |
|
206017a08ed7
Refactor: Make the "op_space()" and related methods more flexible and allow a given fixed token type and value
Franz Glasner <fzglas.hg@dom66.de>
parents:
70
diff
changeset
|
199 if not lexer.no_end: |
|
206017a08ed7
Refactor: Make the "op_space()" and related methods more flexible and allow a given fixed token type and value
Franz Glasner <fzglas.hg@dom66.de>
parents:
70
diff
changeset
|
200 yield match.start(), toktype, value |
|
83
cd79d2c76347
If a Pygments callback gets a "Context" it must set the new position explicitely.
Franz Glasner <fzglas.hg@dom66.de>
parents:
82
diff
changeset
|
201 if ctx: |
|
cd79d2c76347
If a Pygments callback gets a "Context" it must set the new position explicitely.
Franz Glasner <fzglas.hg@dom66.de>
parents:
82
diff
changeset
|
202 ctx.pos = match.end() |
|
72
206017a08ed7
Refactor: Make the "op_space()" and related methods more flexible and allow a given fixed token type and value
Franz Glasner <fzglas.hg@dom66.de>
parents:
70
diff
changeset
|
203 |
|
206017a08ed7
Refactor: Make the "op_space()" and related methods more flexible and allow a given fixed token type and value
Franz Glasner <fzglas.hg@dom66.de>
parents:
70
diff
changeset
|
204 return _op_opt_ignore_or_fixed |
|
65
3f4223a79d2b
Normalize whitespace handling for entity names
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
205 |
| 113 | 206 def op_gets(lexer, match, ctx=None): |
| 207 yield match.start(), Operator, lexer.symbol_gets | |
|
283
5eba722df93e
FIX: Some missing context position updates if a context is given
Franz Glasner <fzglas.hg@dom66.de>
parents:
282
diff
changeset
|
208 if ctx: |
|
5eba722df93e
FIX: Some missing context position updates if a context is given
Franz Glasner <fzglas.hg@dom66.de>
parents:
282
diff
changeset
|
209 ctx.pos = match.end() |
| 113 | 210 |
|
117
d84f1fd10e64
Allow to customize the symbol for a remark
Franz Glasner <fzglas.hg@dom66.de>
parents:
116
diff
changeset
|
211 def op_remark(lexer, match, ctx=None): |
|
d84f1fd10e64
Allow to customize the symbol for a remark
Franz Glasner <fzglas.hg@dom66.de>
parents:
116
diff
changeset
|
212 yield match.start(), Comment.Single, lexer.symbol_remark |
|
283
5eba722df93e
FIX: Some missing context position updates if a context is given
Franz Glasner <fzglas.hg@dom66.de>
parents:
282
diff
changeset
|
213 if ctx: |
|
5eba722df93e
FIX: Some missing context position updates if a context is given
Franz Glasner <fzglas.hg@dom66.de>
parents:
282
diff
changeset
|
214 ctx.pos = match.end() |
|
117
d84f1fd10e64
Allow to customize the symbol for a remark
Franz Glasner <fzglas.hg@dom66.de>
parents:
116
diff
changeset
|
215 |
|
39
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
38
diff
changeset
|
216 def op_symbol(toktype): |
|
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
38
diff
changeset
|
217 |
|
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
38
diff
changeset
|
218 def _op_symbol(lexer, match, ctx=None): |
|
64
05c53e431c88
Simplify case-handling for "BLOCK" and "REMARK"
Franz Glasner <fzglas.hg@dom66.de>
parents:
62
diff
changeset
|
219 kw = match.group().upper() |
|
39
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
38
diff
changeset
|
220 yield match.start(), toktype, lexer.SYMBOLS.get(kw, kw) |
|
83
cd79d2c76347
If a Pygments callback gets a "Context" it must set the new position explicitely.
Franz Glasner <fzglas.hg@dom66.de>
parents:
82
diff
changeset
|
221 if ctx: |
|
cd79d2c76347
If a Pygments callback gets a "Context" it must set the new position explicitely.
Franz Glasner <fzglas.hg@dom66.de>
parents:
82
diff
changeset
|
222 ctx.pos = match.end() |
|
39
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
38
diff
changeset
|
223 |
|
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
38
diff
changeset
|
224 return _op_symbol |
|
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
38
diff
changeset
|
225 |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
226 def op_explicit_tokentype(lexer, match, ctx=None): |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
227 needed_css = match.group("type") |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
228 toktype = REVERSED_STANDARD_TYPES.get(needed_css, None) |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
229 if toktype is None: |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
230 # Be more error friendly |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
231 toktype = Generic.Error |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
232 val = match.group() |
|
89
7414eed7b275
Introduce logging for unhandled explicit token types
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
233 _logger.warning("Unhandled explicit token type: %s", val) |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
234 else: |
|
282
90946f87d77d
Rename RE group "character" -> "characters"
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
235 val = match.group("characters") |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
236 yield match.start(), toktype, val |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
237 if ctx: |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
238 ctx.pos = match.end() |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
239 |
|
285
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
240 def op_explicit_tokentype_ex_start(lexer, match, ctx): |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
241 needed_css = match.group("type") |
|
286
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
242 toktype = REVERSED_STANDARD_TYPES.get(needed_css, None) |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
243 if toktype is None: |
|
288
298841bc4dee
Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
286
diff
changeset
|
244 if lexer.strict_tokentype: |
|
298841bc4dee
Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
286
diff
changeset
|
245 toktype = string_to_defined_tokentype(needed_css) |
|
298841bc4dee
Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
286
diff
changeset
|
246 if toktype is None: |
|
298841bc4dee
Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
286
diff
changeset
|
247 _logger.warning( |
|
298841bc4dee
Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
286
diff
changeset
|
248 "Unhandled explicit token type: %s", needed_css) |
|
298841bc4dee
Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
286
diff
changeset
|
249 else: |
|
286
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
250 toktype = string_to_tokentype(needed_css) |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
251 if toktype is None: |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
252 _logger.warning( |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
253 "Unhandled explicit token type: %s", needed_css) |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
254 else: |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
255 _logger.debug( |
|
288
298841bc4dee
Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
286
diff
changeset
|
256 "New token type may have been synthesized: %s", |
|
298841bc4dee
Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
286
diff
changeset
|
257 needed_css) |
|
286
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
258 if toktype is None: |
|
285
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
259 # Be more error friendly |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
260 ctx.explicit_token_type = Generic.Error |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
261 yield match.start(), ctx.explicit_token_type, match.group() |
|
286
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
262 else: |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
263 ctx.explicit_token_type = toktype |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
264 # Nothing to yield: just record the required token type |
|
285
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
265 ctx.pos = match.end() |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
266 |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
267 def op_explicit_tokentype_ex_value(lexer, match, ctx): |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
268 yield match.start(), ctx.explicit_token_type, match.group(1) |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
269 ctx.pos = match.end() |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
270 |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
271 def op_explicit_tokentype_ex_end(lexer, match, ctx): |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
272 if ctx.explicit_token_type is Generic.Error: |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
273 yield match.start(), ctx.explicit_token_type, match.group() |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
274 ctx.pos = match.end() |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
275 ctx.explicit_token_type = None |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
276 |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
277 tokens = { |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
278 "root": [ |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
279 (r"\n", Whitespace), |
|
39
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
38
diff
changeset
|
280 (r"/\*", Comment.Multiline, "multiline-nested-comment"), |
|
115
e1663ac707b0
An alternate multiline comment syntax using "(* ... *)".
Franz Glasner <fzglas.hg@dom66.de>
parents:
114
diff
changeset
|
281 (r"\(\*", Comment.Multiline, "multiline-nested-comment-alt"), |
|
100
7cfad325d3bb
Allow also `#' to start single-line comments
Franz Glasner <fzglas.hg@dom66.de>
parents:
99
diff
changeset
|
282 (r"(//|#).*$", Comment.Single), |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
283 include("remark"), |
|
90
2af4684c8e78
Restrict whitespace before required and optional arguments.
Franz Glasner <fzglas.hg@dom66.de>
parents:
89
diff
changeset
|
284 (r"(?i)\\(block|state(?:ment)?)[ \t]*(\{)", |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
285 bygroups(op_symbol(Text), LexBase.op_fixed(Whitespace, " ")), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
286 "block-expr"), |
|
78
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
287 (r"(?i)\\(" |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
288 r"(?:textstate(?:ment)?)" |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
289 r"|(?:tstate(?:ment)?)" |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
290 r"|(?:textblock)" |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
291 r"|(?:tblock)" |
|
90
2af4684c8e78
Restrict whitespace before required and optional arguments.
Franz Glasner <fzglas.hg@dom66.de>
parents:
89
diff
changeset
|
292 r")[ \t]*(\{)", |
|
78
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
293 bygroups(op_symbol(Text), LexBase.op_fixed(Whitespace, " ")), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
294 "text-statement"), |
| 97 | 295 (r"(?i)\\(" |
|
99
857df2064831
\INPUT, \INPUTS, \OUTPUT, \OUTPUTS, \RETURN and \RETURNS as new commands (keywords)
Franz Glasner <fzglas.hg@dom66.de>
parents:
98
diff
changeset
|
296 r"(?:input(?:s)?)" |
|
857df2064831
\INPUT, \INPUTS, \OUTPUT, \OUTPUTS, \RETURN and \RETURNS as new commands (keywords)
Franz Glasner <fzglas.hg@dom66.de>
parents:
98
diff
changeset
|
297 r"|(?:output(?:s)?)" |
|
108
6cebd3e7bc97
Also allow \REM within a \TEXT{}
Franz Glasner <fzglas.hg@dom66.de>
parents:
106
diff
changeset
|
298 r"|(?:ensure)" |
|
124
f916251d5647
Implement the "\REQUIRE" command from algpseudocodex
Franz Glasner <fzglas.hg@dom66.de>
parents:
123
diff
changeset
|
299 r"|(?:require)" |
|
104
ffe6ea2cf69b
Allow "\RETURN" and "\RETURNS" commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
103
diff
changeset
|
300 r"|(?:returns)" |
|
99
857df2064831
\INPUT, \INPUTS, \OUTPUT, \OUTPUTS, \RETURN and \RETURNS as new commands (keywords)
Franz Glasner <fzglas.hg@dom66.de>
parents:
98
diff
changeset
|
301 r")[ \t]*(\{)", |
|
857df2064831
\INPUT, \INPUTS, \OUTPUT, \OUTPUTS, \RETURN and \RETURNS as new commands (keywords)
Franz Glasner <fzglas.hg@dom66.de>
parents:
98
diff
changeset
|
302 bygroups(op_translate(Keyword), |
|
857df2064831
\INPUT, \INPUTS, \OUTPUT, \OUTPUTS, \RETURN and \RETURNS as new commands (keywords)
Franz Glasner <fzglas.hg@dom66.de>
parents:
98
diff
changeset
|
303 LexBase.op_fixed(Whitespace, " ")), |
|
857df2064831
\INPUT, \INPUTS, \OUTPUT, \OUTPUTS, \RETURN and \RETURNS as new commands (keywords)
Franz Glasner <fzglas.hg@dom66.de>
parents:
98
diff
changeset
|
304 "text-statement"), |
|
857df2064831
\INPUT, \INPUTS, \OUTPUT, \OUTPUTS, \RETURN and \RETURNS as new commands (keywords)
Franz Glasner <fzglas.hg@dom66.de>
parents:
98
diff
changeset
|
305 (r"(?i)\\(" |
| 97 | 306 r"(?:if)" |
| 307 r"|(?:then)" | |
| 308 r"|(?:else)" | |
| 309 r"|(?:el(?:s(?:e)?)?if)" | |
|
111
d6f3a1d1bedd
Some more keywords (\FROM, \TO, \IN)
Franz Glasner <fzglas.hg@dom66.de>
parents:
109
diff
changeset
|
310 r"|(?:do)" # as in WHILE ... DO not DO ... UNTIL |
| 97 | 311 r"|(?:while)" |
| 312 r"|(?:forall)" | |
| 313 r"|(?:for)" | |
|
111
d6f3a1d1bedd
Some more keywords (\FROM, \TO, \IN)
Franz Glasner <fzglas.hg@dom66.de>
parents:
109
diff
changeset
|
314 r"|(?:from)" |
|
d6f3a1d1bedd
Some more keywords (\FROM, \TO, \IN)
Franz Glasner <fzglas.hg@dom66.de>
parents:
109
diff
changeset
|
315 r"|(?:to)" |
| 97 | 316 r"|(?:step)" |
|
111
d6f3a1d1bedd
Some more keywords (\FROM, \TO, \IN)
Franz Glasner <fzglas.hg@dom66.de>
parents:
109
diff
changeset
|
317 r"|(?:in)" |
| 97 | 318 r"|(?:loop)" |
| 319 r"|(?:repeat)" | |
| 320 r"|(?:until)" | |
|
104
ffe6ea2cf69b
Allow "\RETURN" and "\RETURNS" commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
103
diff
changeset
|
321 r"|(?:return)" |
| 97 | 322 r")\b", |
| 323 bygroups(op_translate(Keyword))), | |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
324 (r"\\\n", Text), |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
325 (r"(?i)\\(" |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
326 r"(?:prog(?:ram)?)" |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
327 r"|(?:algo(?:rithm)?)" |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
328 r"|(?:proc(?:edure)?)" |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
329 r"|(?:func(?:tion)?|(?:fn))" |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
330 r"|(?:class)" |
|
90
2af4684c8e78
Restrict whitespace before required and optional arguments.
Franz Glasner <fzglas.hg@dom66.de>
parents:
89
diff
changeset
|
331 r")[ \t]*(\{)", |
|
72
206017a08ed7
Refactor: Make the "op_space()" and related methods more flexible and allow a given fixed token type and value
Franz Glasner <fzglas.hg@dom66.de>
parents:
70
diff
changeset
|
332 bygroups(op_translate(Keyword), |
|
206017a08ed7
Refactor: Make the "op_space()" and related methods more flexible and allow a given fixed token type and value
Franz Glasner <fzglas.hg@dom66.de>
parents:
70
diff
changeset
|
333 LexBase.op_fixed(Whitespace, " ")), |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
334 "entity-name"), |
| 94 | 335 # ENDxxx keywords with optional entity name in two parts: |
| 336 # 1. with name | |
| 337 (r"(?i)\\end(?:[_\-]|(?:[ \t]+))?(" | |
| 57 | 338 r"(?:prog(?:ram)?)" |
| 339 r"|(?:algo(?:rithm)?)" | |
| 340 r"|(?:proc(?:edure)?)" | |
| 341 r"|(?:func(?:tion)?)" | |
|
96
98cd0787f62f
FIX: FN alias for function
Franz Glasner <fzglas.hg@dom66.de>
parents:
94
diff
changeset
|
342 r"|(?:fn)" |
| 57 | 343 r"|(?:class)" |
| 94 | 344 r")(?:[_\-]|(?:[\t ]+))?(\{)", |
|
62
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
61
diff
changeset
|
345 bygroups(op_opt_end_translate(Keyword), |
|
72
206017a08ed7
Refactor: Make the "op_space()" and related methods more flexible and allow a given fixed token type and value
Franz Glasner <fzglas.hg@dom66.de>
parents:
70
diff
changeset
|
346 op_opt_ignore_or_fixed(Whitespace, " ")), |
|
62
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
61
diff
changeset
|
347 "entity-name-end"), |
| 94 | 348 # 2. without name |
| 349 # 3. AND keywords that do not allow a param (e.g. endif) | |
| 350 (r"(?i)\\end(?:[_\-]|(?:[ \t]+))?(" | |
| 57 | 351 r"(?:prog(?:ram)?)" |
| 352 r"|(?:algo(?:rithm)?)" | |
| 353 r"|(?:proc(?:edure)?)" | |
| 354 r"|(?:func(?:tion)?)" | |
|
96
98cd0787f62f
FIX: FN alias for function
Franz Glasner <fzglas.hg@dom66.de>
parents:
94
diff
changeset
|
355 r"|(?:fn)" |
| 57 | 356 r"|(?:class)" |
| 97 | 357 r"|(?:if)" |
| 358 r"|(?:while)" | |
| 359 r"|(?:for)" | |
| 360 r"|(?:forall)" | |
| 361 r"|(?:loop)" | |
|
62
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
61
diff
changeset
|
362 r")\b", |
| 57 | 363 bygroups(op_opt_end_translate(Keyword))), |
| 97 | 364 # |
| 365 # A single begin or end that is never suppressed because | |
| 366 # it is supposed to be paired with begin | |
| 367 # | |
| 368 (r"(?i)\\(begin|end)\b", | |
| 369 bygroups(op_translate(Keyword))), | |
|
61
392745b66969
The "\IS" keyword expansion
Franz Glasner <fzglas.hg@dom66.de>
parents:
58
diff
changeset
|
370 # Keywords |
|
392745b66969
The "\IS" keyword expansion
Franz Glasner <fzglas.hg@dom66.de>
parents:
58
diff
changeset
|
371 (r"(?i)\\(" |
|
392745b66969
The "\IS" keyword expansion
Franz Glasner <fzglas.hg@dom66.de>
parents:
58
diff
changeset
|
372 r"(?:is)" |
| 82 | 373 r"|(?:with)" |
|
61
392745b66969
The "\IS" keyword expansion
Franz Glasner <fzglas.hg@dom66.de>
parents:
58
diff
changeset
|
374 r")\b", |
|
392745b66969
The "\IS" keyword expansion
Franz Glasner <fzglas.hg@dom66.de>
parents:
58
diff
changeset
|
375 bygroups(op_translate(Keyword))), |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
376 include("expr"), |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
377 include("unicode-separators"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
378 include("unicode-other"), |
|
91
feb41c8d72d2
Instead of "\s+" use "[^\S\n]+" because a \n is not wanted really in this match.
Franz Glasner <fzglas.hg@dom66.de>
parents:
90
diff
changeset
|
379 (r"[^\S\n]+", Text), |
|
160
b4028838e0c8
Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
380 # (r".", Generic.Error), # tolerance for errors |
|
b4028838e0c8
Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
381 (r".", Error), |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
382 ], |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
383 "remark": [ |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
384 (r"(?i)\\(remark|rem)\b(.*)$", |
|
117
d84f1fd10e64
Allow to customize the symbol for a remark
Franz Glasner <fzglas.hg@dom66.de>
parents:
116
diff
changeset
|
385 bygroups(op_remark, Comment.Single)), |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
386 ], |
|
62
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
61
diff
changeset
|
387 "entity-name": [ # may be multiline |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
388 (r"[^\\}]+", Name.Entity), |
|
77
1a5e192aa950
Move popping states consistently more to the begin
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
389 (r"\}", LexBase.op_ignore, "#pop"), |
|
74
c1357674622d
Remove an escaping backslash where appropriate
Franz Glasner <fzglas.hg@dom66.de>
parents:
72
diff
changeset
|
390 (r"\\\}", LexBase.op_fixed(Name.Entity, "}")), |
|
76
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
391 (r"\\\\", LexBase.op_fixed(Name.Entity, "\\")), |
|
162
11ce0903ff8b
Yield lone backslash characters in expressions that not really escape anything as "Generic.Error" now.
Franz Glasner <fzglas.hg@dom66.de>
parents:
161
diff
changeset
|
392 (r"\\", LexBase.op_fixed(Generic.Error, "\\")), |
|
62
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
61
diff
changeset
|
393 ], |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
61
diff
changeset
|
394 "entity-name-end": [ # may be multiline -- suppressed if no_end |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
61
diff
changeset
|
395 (r"[^\\}]+", op_opt_ignore(Name.Entity)), |
|
77
1a5e192aa950
Move popping states consistently more to the begin
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
396 (r"\}", LexBase.op_ignore, "#pop"), |
|
74
c1357674622d
Remove an escaping backslash where appropriate
Franz Glasner <fzglas.hg@dom66.de>
parents:
72
diff
changeset
|
397 (r"\\\}", op_opt_ignore_or_fixed(Name.Entity, "}")), |
|
76
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
398 (r"\\\\", op_opt_ignore_or_fixed(Name.Entity, "\\")), |
|
162
11ce0903ff8b
Yield lone backslash characters in expressions that not really escape anything as "Generic.Error" now.
Franz Glasner <fzglas.hg@dom66.de>
parents:
161
diff
changeset
|
399 (r"\\", op_opt_ignore_or_fixed(Generic.Error, "\\")), |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
400 ], |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
401 "expr": [ |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
402 include("math-symbols"), # must be before punctuation |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
403 include("ascii-punctuation"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
404 include("unicode-punctuation"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
405 include("escaped-string-start"), |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
406 include("py-strings"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
407 include("py-numbers"), |
|
149
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
124
diff
changeset
|
408 (r"(?i)\\(call|name)[ \t]*(\{)", LexBase.op_ignore, "entity-name"), |
| 113 | 409 (r"(?i)\\gets\b", op_gets), |
|
281
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
410 (r"(?i)\\e(?:xpr(?:ession)?)?[ \t]*\{", |
|
212
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
411 LexBase.op_ignore, |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
412 "block-expr"), |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
413 include("explicit-tokentype"), |
|
281
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
414 (r"(?i)\\t(?:ext)?[ \t]*\{", LexBase.op_ignore, "text-statement"), |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
415 include("remark"), |
|
81
6d8b813fb296
Keyword constants like "True", "False", "Nil", "None", "Null" and "Empty"
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
416 include("keyword-constants"), |
|
93
84c0f761c836
Renamed "text-operators" to "word-operators" and allow more case-variants
Franz Glasner <fzglas.hg@dom66.de>
parents:
92
diff
changeset
|
417 include("word-operators"), |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
418 include("math-builtins"), |
|
52
5bfa9113d3c4
First tests with "py-name": names from the Python lexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
41
diff
changeset
|
419 include("py-name"), |
|
70
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
65
diff
changeset
|
420 ], |
|
80
f487f0d322a5
Move "expr-in-braces" up to "expr".
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
421 "expr-in-braces": [ |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
422 include("math-symbols"), # must be before punctuation |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
423 include("ascii-punctuation-in-braces"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
424 include("unicode-punctuation"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
425 include("escaped-string-start"), |
|
80
f487f0d322a5
Move "expr-in-braces" up to "expr".
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
426 include("py-strings"), |
|
f487f0d322a5
Move "expr-in-braces" up to "expr".
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
427 include("py-numbers"), |
|
149
380d2607d5c7
Implement the "\NAME" command.
Franz Glasner <fzglas.hg@dom66.de>
parents:
124
diff
changeset
|
428 (r"(?i)\\(call|name)[ \t]*(\{)", LexBase.op_ignore, "entity-name"), |
| 113 | 429 (r"(?i)\\gets\b", op_gets), |
|
281
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
430 (r"(?i)\\e(?:xpr(?:ession)?)?[ \t]*\{", |
|
212
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
431 LexBase.op_ignore, |
|
18553f595b34
Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
432 "block-expr"), |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
433 include("explicit-tokentype"), |
|
281
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
434 (r"(?i)\\t(?:ext)?[ \t]*\{", LexBase.op_ignore, "text-statement"), |
|
80
f487f0d322a5
Move "expr-in-braces" up to "expr".
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
435 include("remark"), |
|
81
6d8b813fb296
Keyword constants like "True", "False", "Nil", "None", "Null" and "Empty"
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
436 include("keyword-constants"), |
|
93
84c0f761c836
Renamed "text-operators" to "word-operators" and allow more case-variants
Franz Glasner <fzglas.hg@dom66.de>
parents:
92
diff
changeset
|
437 include("word-operators"), |
|
80
f487f0d322a5
Move "expr-in-braces" up to "expr".
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
438 include("math-builtins"), |
|
f487f0d322a5
Move "expr-in-braces" up to "expr".
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
439 include("py-name"), |
|
f487f0d322a5
Move "expr-in-braces" up to "expr".
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
440 ], |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
441 "block-expr": [ # somewhat similar to "root" |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
442 (r"\}", LexBase.op_ignore, "#pop"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
443 (r"\n", Whitespace), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
444 include("expr-in-braces"), |
|
76
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
445 (r"\\\\", LexBase.op_fixed(Text, "\\")), |
|
162
11ce0903ff8b
Yield lone backslash characters in expressions that not really escape anything as "Generic.Error" now.
Franz Glasner <fzglas.hg@dom66.de>
parents:
161
diff
changeset
|
446 (r"\\", LexBase.op_fixed(Generic.Error, "\\")), |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
447 include("unicode-separators"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
448 include("unicode-other"), |
|
91
feb41c8d72d2
Instead of "\s+" use "[^\S\n]+" because a \n is not wanted really in this match.
Franz Glasner <fzglas.hg@dom66.de>
parents:
90
diff
changeset
|
449 (r"[^\S\n]+", Text), |
|
160
b4028838e0c8
Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
450 (r".", Error), |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
451 ], |
|
78
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
452 "text-statement": [ # like block but default to text-mode |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
453 (r"[^\\}\n]+", Text), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
454 (r"\}", LexBase.op_ignore, "#pop"), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
455 (r"\n", Whitespace), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
456 (r"\\\}", LexBase.op_fixed(Text, "}")), |
|
281
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
457 (r"(?i)\\e(?:xpr(?:ession)?)?[ \t]*\{", |
|
78
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
458 LexBase.op_ignore, |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
459 "block-expr"), |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
460 include("explicit-tokentype"), |
|
281
ee512932d603
Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents:
276
diff
changeset
|
461 (r"(?i)\\t(?:ext)?[ \t]*\{", LexBase.op_ignore, "#push"), |
|
78
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
462 include("remark"), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
463 (r"\\\\", LexBase.op_fixed(Text, "\\")), |
|
162
11ce0903ff8b
Yield lone backslash characters in expressions that not really escape anything as "Generic.Error" now.
Franz Glasner <fzglas.hg@dom66.de>
parents:
161
diff
changeset
|
464 (r"\\", LexBase.op_fixed(Text, "\\")), # in text-mode: leave Text |
|
160
b4028838e0c8
Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
465 (r".", Error), |
|
78
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
466 ], |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
467 "math-builtins": [ |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
468 (words(("sqrt", "pow", "cos", "sin", "tan", "arcos", "arcsin", |
|
102
d8368294413a
"min" and "max" as automatic mathematical operators
Franz Glasner <fzglas.hg@dom66.de>
parents:
100
diff
changeset
|
469 "arctan", "arctan2", "mod", "exp", "ln", "log", |
|
d8368294413a
"min" and "max" as automatic mathematical operators
Franz Glasner <fzglas.hg@dom66.de>
parents:
100
diff
changeset
|
470 "min", "max"), |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
471 prefix=r"(?<!\.)", |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
472 suffix=r"\b"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
473 Name.Builtin), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
474 ], |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
475 "math-symbols": [ |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
476 (r"<=>|<->|<-|->|=>|<=|>=|<>|!=|:=|=:|\?=", op_symbol(Operator)), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
477 (r"[!&<>=+\-*/%|~]", Operator), # ASCII |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
478 (u"[%s]" % (uniprops.Sm,), Operator), # other Unicode |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
479 ], |
|
93
84c0f761c836
Renamed "text-operators" to "word-operators" and allow more case-variants
Franz Glasner <fzglas.hg@dom66.de>
parents:
92
diff
changeset
|
480 "word-operators": [ |
|
84c0f761c836
Renamed "text-operators" to "word-operators" and allow more case-variants
Franz Glasner <fzglas.hg@dom66.de>
parents:
92
diff
changeset
|
481 (words(("IN", "In", "in", |
|
84c0f761c836
Renamed "text-operators" to "word-operators" and allow more case-variants
Franz Glasner <fzglas.hg@dom66.de>
parents:
92
diff
changeset
|
482 "IS", "Is", "is", |
|
84c0f761c836
Renamed "text-operators" to "word-operators" and allow more case-variants
Franz Glasner <fzglas.hg@dom66.de>
parents:
92
diff
changeset
|
483 "AND", "And", "and", |
|
84c0f761c836
Renamed "text-operators" to "word-operators" and allow more case-variants
Franz Glasner <fzglas.hg@dom66.de>
parents:
92
diff
changeset
|
484 "OR", "Or", "or", |
|
84c0f761c836
Renamed "text-operators" to "word-operators" and allow more case-variants
Franz Glasner <fzglas.hg@dom66.de>
parents:
92
diff
changeset
|
485 "XOR", "Xor", "xor", |
|
84c0f761c836
Renamed "text-operators" to "word-operators" and allow more case-variants
Franz Glasner <fzglas.hg@dom66.de>
parents:
92
diff
changeset
|
486 "NOT", "Not", "not"), |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
487 prefix=r"(?<!\.)", |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
488 suffix=r"\b"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
489 Operator.Word), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
490 ], |
|
81
6d8b813fb296
Keyword constants like "True", "False", "Nil", "None", "Null" and "Empty"
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
491 "keyword-constants": [ |
|
6d8b813fb296
Keyword constants like "True", "False", "Nil", "None", "Null" and "Empty"
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
492 (words(("True", "TRUE", "true", "False", "FALSE", "false", |
|
103
af97692501ea
FIX: Typo: "non" -> "none"
Franz Glasner <fzglas.hg@dom66.de>
parents:
102
diff
changeset
|
493 "None", "NONE", "none", "Nil", "NIL", "nil", |
|
81
6d8b813fb296
Keyword constants like "True", "False", "Nil", "None", "Null" and "Empty"
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
494 "Null", "NULL", "null", |
|
6d8b813fb296
Keyword constants like "True", "False", "Nil", "None", "Null" and "Empty"
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
495 "Empty", "EMPTY", "empty"), |
|
6d8b813fb296
Keyword constants like "True", "False", "Nil", "None", "Null" and "Empty"
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
496 prefix=r"(?<!\.)", |
|
6d8b813fb296
Keyword constants like "True", "False", "Nil", "None", "Null" and "Empty"
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
497 suffix=r"\b"), |
|
6d8b813fb296
Keyword constants like "True", "False", "Nil", "None", "Null" and "Empty"
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
498 Keyword.Constant), |
|
6d8b813fb296
Keyword constants like "True", "False", "Nil", "None", "Null" and "Empty"
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
499 ], |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
500 "ascii-punctuation": [ |
|
159
4ee0b1536ea6
Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
149
diff
changeset
|
501 (r"\.+", Punctuation), |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
502 (r"[{}:(),;[\]?@]", Punctuation), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
503 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
504 "ascii-punctuation-in-braces": [ |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
505 # |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
506 # Like "punctuation" but needs an escaped curly brace for } because |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
507 # a single closing curly brace pops the current state here. |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
508 # |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
509 (r"\\\}", LexBase.op_fixed(Punctuation, "}")), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
510 (r"[{:(),;[\]?@]", Punctuation), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
511 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
512 "unicode-separators": [ |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
513 (u"[%s]" % (uniprops.Zl,), Whitespace), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
514 (u"[%s]" % (uniprops.Zp,), Whitespace), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
515 (u"[%s]" % (uniprops.Zs,), Whitespace), |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
516 ], |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
517 "unicode-punctuation": [ |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
518 (u"[%s]" % (uniprops.Pc,), Punctuation), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
519 (u"[%s]" % (uniprops.Pd,), Punctuation), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
520 (u"[%s]" % (uniprops.Ps,), Punctuation), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
521 (u"[%s]" % (uniprops.Pe,), Punctuation), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
522 (u"[%s]" % (uniprops.Pi,), Punctuation), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
523 (u"[%s]" % (uniprops.Pf,), Punctuation), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
524 (u"[%s]" % (uniprops.Po,), Punctuation), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
525 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
526 "unicode-other": [ |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
527 (u"[%s]" % (uniprops.Sc,), Text), # Currency |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
528 (u"[%s]" % (uniprops.So,), Text), # Other symbols |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
529 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
530 "escaped-string-start": [ |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
531 (r"""\\(['"])""", bygroups(Punctuation)), |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
532 ], |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
533 "explicit-tokentype": [ |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
534 # All these REs are CASE-SENSITIVE! |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
535 |
|
285
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
536 # |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
537 # New extended (more flexible, allows escaping) |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
538 # |
|
288
298841bc4dee
Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents:
286
diff
changeset
|
539 (r"""\\ttX[ \t]*\{(?P<type>[^}]*)\}[ \t]*\{""", |
|
285
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
540 op_explicit_tokentype_ex_start, |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
541 "extended-explicit-tokentype"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
542 |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
543 # |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
544 # Old variants |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
545 # |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
546 |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
547 # Multiple characters possible, but no escaping! |
|
276
397ed930a5ba
Allow more separator characters for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
275
diff
changeset
|
548 (r"""\\ttx\-(?P<type>[a-zA-Z0-9_-]+?)""" |
|
397ed930a5ba
Allow more separator characters for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
275
diff
changeset
|
549 r"""(?P<sep>[/?.,:;%|=*+!\\$~"'#@_-])""" |
|
282
90946f87d77d
Rename RE group "character" -> "characters"
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
550 r"""(?P<characters>(.|\n)+?)(?P=sep)""", |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
551 op_explicit_tokentype), |
|
282
90946f87d77d
Rename RE group "character" -> "characters"
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
552 (r"\\ttx\-(?P<type>[a-zA-Z0-9_-]+?)\{(?P<characters>[^}]+?)\}", |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
553 op_explicit_tokentype), |
|
282
90946f87d77d
Rename RE group "character" -> "characters"
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
554 (r"\\ttx\-(?P<type>[a-zA-Z0-9_-]+?)\((?P<characters>[^)]+?)\)", |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
555 op_explicit_tokentype), |
|
282
90946f87d77d
Rename RE group "character" -> "characters"
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
556 (r"\\ttx\-(?P<type>[a-zA-Z0-9_-]+?)<(?P<characters>[^>]+?)>", |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
557 op_explicit_tokentype), |
|
282
90946f87d77d
Rename RE group "character" -> "characters"
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
558 (r"\\ttx\-(?P<type>[a-zA-Z0-9_-]+?)\[(?P<characters>[^\]]+?)\]", |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
559 op_explicit_tokentype), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
560 |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
561 # Every character is possible: no escaping needed! |
|
282
90946f87d77d
Rename RE group "character" -> "characters"
Franz Glasner <fzglas.hg@dom66.de>
parents:
281
diff
changeset
|
562 (r"\\tt-(?P<type>[^/]+?)/(?P<characters>(?:.|\n))", |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
563 op_explicit_tokentype), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
564 ], |
|
285
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
565 "extended-explicit-tokentype": [ |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
566 (r"([^\\}]+)", op_explicit_tokentype_ex_value), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
567 (r"\}", op_explicit_tokentype_ex_end, "#pop"), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
568 (r"\\(\})", op_explicit_tokentype_ex_value), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
569 (r"\\(\\)", op_explicit_tokentype_ex_value), |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
570 (r"\\", LexBase.op_fixed(Generic.Error, "\\")), # weak error |
|
afbca50b7dc1
Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents:
283
diff
changeset
|
571 ], |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
572 } |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
573 |
| 57 | 574 def __init__(self, **options): |
|
116
9bfd87544902
Use arrows from Supplemental Arrows-A Unicode block where appropriate: better readability
Franz Glasner <fzglas.hg@dom66.de>
parents:
115
diff
changeset
|
575 self.no_end = pygments.util.get_bool_opt( |
|
9bfd87544902
Use arrows from Supplemental Arrows-A Unicode block where appropriate: better readability
Franz Glasner <fzglas.hg@dom66.de>
parents:
115
diff
changeset
|
576 options, "no_end", default=False) |
|
286
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
577 self.strict_tokentype = pygments.util.get_bool_opt( |
|
051c8877ee22
Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents:
285
diff
changeset
|
578 options, "strict_tokentype", default=True) |
|
116
9bfd87544902
Use arrows from Supplemental Arrows-A Unicode block where appropriate: better readability
Franz Glasner <fzglas.hg@dom66.de>
parents:
115
diff
changeset
|
579 self.symbol_gets = options.get("gets", None) |
|
9bfd87544902
Use arrows from Supplemental Arrows-A Unicode block where appropriate: better readability
Franz Glasner <fzglas.hg@dom66.de>
parents:
115
diff
changeset
|
580 if self.symbol_gets is None: |
|
9bfd87544902
Use arrows from Supplemental Arrows-A Unicode block where appropriate: better readability
Franz Glasner <fzglas.hg@dom66.de>
parents:
115
diff
changeset
|
581 self.symbol_gets = self.SYMBOLS["<-"] # Default: "⟵" # U+27F5 |
|
117
d84f1fd10e64
Allow to customize the symbol for a remark
Franz Glasner <fzglas.hg@dom66.de>
parents:
116
diff
changeset
|
582 self.symbol_remark = options.get("remark", None) |
|
d84f1fd10e64
Allow to customize the symbol for a remark
Franz Glasner <fzglas.hg@dom66.de>
parents:
116
diff
changeset
|
583 if self.symbol_remark is None: |
|
d84f1fd10e64
Allow to customize the symbol for a remark
Franz Glasner <fzglas.hg@dom66.de>
parents:
116
diff
changeset
|
584 self.symbol_remark = self.SYMBOLS["REM"] # Default: "▷" # U+25B7 |
| 57 | 585 LexBase.__init__(self, **options) |
|
160
b4028838e0c8
Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
586 # |
|
b4028838e0c8
Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
587 # Do this after calling the base because a "filters" option should be |
|
b4028838e0c8
Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
588 # allowed to set **any** filter. |
|
b4028838e0c8
Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
589 # |
|
b4028838e0c8
Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
590 self.prohibit_raiseonerror_filter = pygments.util.get_bool_opt( |
|
b4028838e0c8
Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
591 options, "prohibit_raiseonerror_filter", default=False) |
|
b4028838e0c8
Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
592 |
|
b4028838e0c8
Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
593 def add_filter(self, filter_, **options): |
|
b4028838e0c8
Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
594 # |
| 161 | 595 # May be called by Lexer.__init__ when |
| 596 # self.prohibit_raiseonerror_filter is not yet set. | |
| 597 # This is intentionally so. | |
|
160
b4028838e0c8
Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
598 # |
|
b4028838e0c8
Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
599 if getattr(self, "prohibit_raiseonerror_filter", False): |
|
b4028838e0c8
Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
600 if filter_ in ("raiseonerror",): |
|
b4028838e0c8
Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
601 return |
|
b4028838e0c8
Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents:
159
diff
changeset
|
602 LexBase.add_filter(self, filter_, **options) |
| 57 | 603 |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
604 |
|
53
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
605 class AlgPseudocodeLexer_DE(AlgPseudocodeLexer): |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
606 |
|
112
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
607 """ |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
608 |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
609 .. seealso:: |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
610 - https://de.wikipedia.org/wiki/Pseudocode |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
611 |
|
122
e39ca08b0609
Move some TODOs into the class docstrings
Franz Glasner <fzglas.hg@dom66.de>
parents:
117
diff
changeset
|
612 .. todo:: Complete german translations |
|
e39ca08b0609
Move some TODOs into the class docstrings
Franz Glasner <fzglas.hg@dom66.de>
parents:
117
diff
changeset
|
613 |
|
112
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
614 """ |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
615 |
|
53
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
616 name = "AlgPseudocodeDE" |
|
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
617 aliases = ["algpseudocode-de", "algpseudo-de"] |
|
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
618 filenames = ["*.algpseudo-de", "*.algpseudocode-de"] |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
619 |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
620 LANG = "de" |
|
53
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
621 TRANSLATIONS = AlgPseudocodeLexer.TRANSLATIONS.copy() |
|
41
4ccf9a8d0bf2
For the german and french PseudocodeLexer: Use en translations as fallback.
Franz Glasner <fzglas.hg@dom66.de>
parents:
40
diff
changeset
|
622 TRANSLATIONS.update({ |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
623 "PROG": "PROGRAMM", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
624 "PROGRAM": "PROGRAMM", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
625 "ALGO": "ALGORITHMUS", |
|
39
a3151d837258
Some basic keywords for programs, algorithms, procedures and functions; also comments (single and multiline) and "remarks"
Franz Glasner <fzglas.hg@dom66.de>
parents:
38
diff
changeset
|
626 "ALGORITHM": "ALGORITHMUS", |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
627 "PROC": "PROZEDUR", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
628 "PROCEDURE": "PROZEDUR", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
629 "FUNC": "FUNKTION", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
630 "FUNCTION": "FUNKTION", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
631 "FN": "FUNKTION", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
632 "CLASS": "KLASSE", |
|
61
392745b66969
The "\IS" keyword expansion
Franz Glasner <fzglas.hg@dom66.de>
parents:
58
diff
changeset
|
633 "IS": "IST", |
| 82 | 634 "WITH": "MIT", |
|
112
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
635 "IF": "WENN", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
636 "THEN": "DANN", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
637 "ELSE": "ANDERNFALLS", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
638 "ELSEIF": "ANDERNFALLS WENN", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
639 "ELSIF": "ANDERNFALLS WENN", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
640 "ELIF": "ANDERNFALLS WENN", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
641 # "DO": # XXX TBD # in WHILE WHILE ... DO # noqa # in WHILE ... DO |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
642 "WHILE": "SOLANGE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
643 "FOR": "FÜR", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
644 "FORALL": "FÜR ALLE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
645 "FROM": "VON", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
646 "TO": "BIS", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
647 "IN": "IN", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
648 "STEP": "SCHRITTWEITE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
649 # "LOOP": XXX TBD # noqa |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
650 "REPEAT": "WIEDERHOLE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
651 "UNTIL": "BIS", |
| 113 | 652 # "RETURN": XXX TBD # noqa |
|
112
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
653 "BEGIN": "START", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
654 "END": "ENDE", |
|
41
4ccf9a8d0bf2
For the german and french PseudocodeLexer: Use en translations as fallback.
Franz Glasner <fzglas.hg@dom66.de>
parents:
40
diff
changeset
|
655 }) |
| 57 | 656 END_TRANSLATIONS = AlgPseudocodeLexer.END_TRANSLATIONS.copy() |
| 657 END_TRANSLATIONS.update({ | |
| 658 "PROG": "ENDE DES PROGRAMMS", | |
|
112
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
659 "PROGRAM": "ENDE DES PROGRAMMS", |
| 57 | 660 "ALGO": "ENDE DES ALGORITHMUS", |
| 661 "ALGORITHM": "ENDE DES ALGORITHMUS", | |
| 662 "PROC": "ENDE DER PROZEDUR", | |
| 663 "PROCEDURE": "ENDE DER PROZEDUR", | |
| 664 "FUNC": "ENDE DER FUNKTION", | |
| 665 "FUNCTION": "ENDE DER FUNKTION", | |
| 666 "FN": "ENDE DER FUNKTION", | |
| 667 "CLASS": "ENDE DER KLASSE", | |
|
112
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
668 "IF": "ENDE WENN", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
669 "WHILE": "ENDE SOLANGE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
670 "FOR": "ENDE FÜR", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
671 "FORALL": "ENDE FÜR ALLE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
672 # "LOOP": "ENDE XXX", # XXX TBD # noqa |
| 57 | 673 }) |
| 674 DEFAULT_END_PREFIX = "ENDE VON " | |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
675 |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
676 |
|
53
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
677 class AlgPseudocodeLexer_FR(AlgPseudocodeLexer): |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
678 |
|
112
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
679 """ |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
680 |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
681 .. seealso:: |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
682 - https://info.blaisepascal.fr/pseudo-code/ |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
683 - https://fr.wikipedia.org/wiki/Pseudo-code |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
684 - https://fr.wikipedia.org/wiki/Structure_de_contr%C3%B4le |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
685 |
|
122
e39ca08b0609
Move some TODOs into the class docstrings
Franz Glasner <fzglas.hg@dom66.de>
parents:
117
diff
changeset
|
686 .. todo:: Complete french translations |
|
e39ca08b0609
Move some TODOs into the class docstrings
Franz Glasner <fzglas.hg@dom66.de>
parents:
117
diff
changeset
|
687 |
|
112
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
688 """ |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
689 |
|
53
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
690 name = "AlgPseudocodeFR" |
|
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
691 aliases = ["algpseudocode-fr", "algpseudo-fr"] |
|
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
692 filenames = ["*.algpseudo-fr", "*.algpseudocode-fr"] |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
693 |
|
109
49e5aa89095f
FIX: LANG for the french lexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
108
diff
changeset
|
694 LANG = "fr" |
|
53
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
695 TRANSLATIONS = AlgPseudocodeLexer.TRANSLATIONS.copy() |
|
41
4ccf9a8d0bf2
For the german and french PseudocodeLexer: Use en translations as fallback.
Franz Glasner <fzglas.hg@dom66.de>
parents:
40
diff
changeset
|
696 TRANSLATIONS.update({ |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
697 "PROG": "PROGRAMME", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
698 "PROGRAM": "PROGRAMME", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
699 "ALGO": "ALGORITHME", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
700 "ALGORITHM": "ALGORITHME", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
701 "PROC": "PROCÉDURE", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
702 "PROCEDURE": "PROCÉDURE", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
703 "FUNC": "FONCTION", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
704 "FUNCTION": "FOUNCTION", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
705 "FN": "FONCTION", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
706 "CLASS": "CLASSE", |
|
61
392745b66969
The "\IS" keyword expansion
Franz Glasner <fzglas.hg@dom66.de>
parents:
58
diff
changeset
|
707 "IS": "EST", |
| 82 | 708 "WITH": "AVEC", |
|
112
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
709 "IF": "SI", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
710 "THEN": "ALORS", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
711 "ELSE": "SINON", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
712 "ELSEIF": "SINONSI", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
713 "ELSIF": "SINONSI", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
714 "ELIF": "SINONSI", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
715 "DO": "FAIRE", # as in in WHILE ... DO (not DO ... UNTIL) |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
716 "WHILE": "TANTQUE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
717 "FOR": "POUR", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
718 "FORALL": "POUR CHAQUE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
719 "FROM": "DE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
720 "TO": "JUSQU'À", # or just "À", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
721 "IN": "DANS", # as in FOR ... IN |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
722 "STEP": "PAR PAS DE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
723 "LOOP": "BOUCLE", # XXX FIXME??? |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
724 "REPEAT": "RÉPÉTER", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
725 "UNTIL": "JUSQUACEQUE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
726 "RETURN": "RENVOYER", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
727 "BEGIN": "DÉBUT", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
728 "END": "FIN", |
|
41
4ccf9a8d0bf2
For the german and french PseudocodeLexer: Use en translations as fallback.
Franz Glasner <fzglas.hg@dom66.de>
parents:
40
diff
changeset
|
729 }) |
| 57 | 730 END_TRANSLATIONS = AlgPseudocodeLexer.END_TRANSLATIONS.copy() |
| 731 END_TRANSLATIONS.update({ | |
| 732 "PROG": "FIN DE PROGRAMME", | |
| 733 "PROGRAM": "FIN DE PROGRAMME", | |
| 734 "ALGO": "FIN D'ALGORITHME", | |
| 735 "ALGORITHM": "FIN D'ALGORITHME", | |
| 736 "PROC": "FIN DE PROCÉDURE", | |
| 737 "PROCEDURE": "FIN DE PROCÉDURE", | |
| 738 "FUNC": "FIN DE FONCTION", | |
| 739 "FUNCTION": "FIN DE FOUNCTION", | |
| 740 "FN": "FIN DE FONCTION", | |
| 741 "CLASS": "FIN DE CLASSE", | |
|
112
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
742 "SI": "FIN SI", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
743 "FOR": "FIN POUR", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
744 "FORALL": "FIN POUR CHAQUE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
745 "WHILE": "FIN TANTQUE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
746 "LOOP": "FIN BOUCLE", |
| 57 | 747 }) |
| 748 DEFAULT_END_PREFIX = "FIN DE " |
