Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
annotate pygments_lexer_pseudocode2/algpseudocode.py @ 113:9aea2fd5f037
The \GETS command.
Its output is customizable with the lexer's "gets" option.
It defaults to `←'.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Tue, 05 May 2026 20:51:20 +0200 |
| parents | ec8767cc5493 |
| children | be50fe0687d6 |
| 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 |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
20 from pygments.token import (Comment, Generic, Keyword, Name, Operator, |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
21 Punctuation, Text, Whitespace) |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
22 |
|
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 # 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
|
25 # 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
|
26 # |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
27 from pygments_lexer_pseudocode2.bases import LexBase |
|
85
ae5e741d2a9b
Optimize op_explicit_tokentype(): use a pref-computed reversed pygments.token.STANDARD_TYPES
Franz Glasner <fzglas.hg@dom66.de>
parents:
84
diff
changeset
|
28 from pygments_lexer_pseudocode2.utils import REVERSED_STANDARD_TYPES |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
29 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
|
30 |
|
89
7414eed7b275
Introduce logging for unhandled explicit token types
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
31 # |
|
7414eed7b275
Introduce logging for unhandled explicit token types
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
32 # 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
|
33 # __builtins__ |
|
7414eed7b275
Introduce logging for unhandled explicit token types
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
34 # |
|
7414eed7b275
Introduce logging for unhandled explicit token types
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
35 _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
|
36 |
|
7414eed7b275
Introduce logging for unhandled explicit token types
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
37 |
|
53
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
38 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
|
39 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
40 """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
|
41 algpseudocodex. |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
42 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
43 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
|
44 |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
45 """ |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
46 |
|
53
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
47 name = "AlgPseudocode" |
|
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
48 aliases = ["algpseudocode", "algpseudo"] |
|
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
49 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
|
50 mimetypes = [] |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
51 flags = re.MULTILINE |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
52 |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
53 LANG = "en" |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
54 TRANSLATIONS = { |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
55 "PROG": "PROGRAM", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
56 "PROGRAM": "PROGRAM", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
57 "ALGO": "ALGORITHM", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
58 "ALGORITHM": "ALGORITHM", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
59 "PROC": "PROCEDURE", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
60 "PROCEDURE": "PROCEDURE", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
61 "FUNC": "FUNCTION", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
62 "FUNCTION": "FUNCTION", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
63 "FN": "FUNCTION", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
64 "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
|
65 "INPUT": "Input:", |
|
857df2064831
\INPUT, \INPUTS, \OUTPUT, \OUTPUTS, \RETURN and \RETURNS as new commands (keywords)
Franz Glasner <fzglas.hg@dom66.de>
parents:
98
diff
changeset
|
66 "INPUTS": "Inputs:", |
|
857df2064831
\INPUT, \INPUTS, \OUTPUT, \OUTPUTS, \RETURN and \RETURNS as new commands (keywords)
Franz Glasner <fzglas.hg@dom66.de>
parents:
98
diff
changeset
|
67 "OUTPUT": "Output:", |
|
857df2064831
\INPUT, \INPUTS, \OUTPUT, \OUTPUTS, \RETURN and \RETURNS as new commands (keywords)
Franz Glasner <fzglas.hg@dom66.de>
parents:
98
diff
changeset
|
68 "OUTPUTS": "Outputs:", |
|
857df2064831
\INPUT, \INPUTS, \OUTPUT, \OUTPUTS, \RETURN and \RETURNS as new commands (keywords)
Franz Glasner <fzglas.hg@dom66.de>
parents:
98
diff
changeset
|
69 "RETURNS": "Returns:", |
| 106 | 70 "ENSURE": "Ensure:", |
|
61
392745b66969
The "\IS" keyword expansion
Franz Glasner <fzglas.hg@dom66.de>
parents:
58
diff
changeset
|
71 "IS": "IS", |
| 82 | 72 "WITH": "WITH", |
| 97 | 73 "IF": "IF", |
| 74 "THEN": "THEN", | |
| 75 "ELSE": "ELSE", | |
| 76 "ELSEIF": "ELSE IF", | |
| 77 "ELSIF": "ELSE IF", | |
| 78 "ELIF": "ELSE IF", | |
|
111
d6f3a1d1bedd
Some more keywords (\FROM, \TO, \IN)
Franz Glasner <fzglas.hg@dom66.de>
parents:
109
diff
changeset
|
79 "DO": "DO", # in WHILE ... DO |
| 97 | 80 "WHILE": "WHILE", |
| 81 "FOR": "FOR", | |
| 82 "FORALL": "FOR ALL", | |
|
111
d6f3a1d1bedd
Some more keywords (\FROM, \TO, \IN)
Franz Glasner <fzglas.hg@dom66.de>
parents:
109
diff
changeset
|
83 "FROM": "FROM", |
|
d6f3a1d1bedd
Some more keywords (\FROM, \TO, \IN)
Franz Glasner <fzglas.hg@dom66.de>
parents:
109
diff
changeset
|
84 "TO": "TO", |
|
d6f3a1d1bedd
Some more keywords (\FROM, \TO, \IN)
Franz Glasner <fzglas.hg@dom66.de>
parents:
109
diff
changeset
|
85 "IN": "IN", # as in FOR ... IN |
| 97 | 86 "STEP": "STEP", |
| 87 "LOOP": "LOOP", | |
| 88 "REPEAT": "REPEAT", | |
| 89 "UNTIL": "UNTIL", | |
|
104
ffe6ea2cf69b
Allow "\RETURN" and "\RETURNS" commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
103
diff
changeset
|
90 "RETURN": "RETURN", |
| 97 | 91 "BEGIN": "BEGIN", |
| 92 "END": "END", # not in END_TRANSLATIONS | |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
93 } |
| 57 | 94 END_TRANSLATIONS = { |
| 95 "PROG": "END OF PROGRAM", | |
| 96 "PROGRAM": "END OF PROGRAM", | |
| 97 "ALGO": "END OF ALGORITHM", | |
| 98 "ALGORITHM": "END OF ALGORITHM", | |
| 99 "PROC": "END OF PROCEDURE", | |
| 100 "PROCEDURE": "END OF PROCEDURE", | |
| 101 "FUNC": "END OF FUNCTION", | |
| 102 "FUNCTION": "END OF FUNCTION", | |
| 103 "FN": "END OF FUNCTION", | |
| 104 "CLASS": "END OF CLASS", | |
| 97 | 105 "IF": "END IF", |
| 106 "WHILE": "END WHILE", | |
| 107 "FOR": "END FOR", | |
| 108 "FORALL": "END FOR ALL", | |
| 109 "LOOP": "END LOOP", | |
| 57 | 110 } |
| 111 DEFAULT_END_PREFIX = "END OF " | |
|
58
be065e5c8042
Prepare symbols for a statement which defaults to token type "Text".
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
112 SYMBOL_REMARK = "▷" # U+25B7: Unicode 1.0 (Geometric Shapes) |
|
be065e5c8042
Prepare symbols for a statement which defaults to token type "Text".
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
113 # SYMBOL_REMARK = "▻" # U+25BB: Unicode 1.0 (Geometric Shapes) |
|
be065e5c8042
Prepare symbols for a statement which defaults to token type "Text".
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
114 SYMBOL_BLOCK = "◆" # U+25C6: Unicode 1.0 (Geometric Shapes) |
|
be065e5c8042
Prepare symbols for a statement which defaults to token type "Text".
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
115 # SYMBOL_BLOCK = "┃" # U+2503: Unicode 1.0 (Bow Drawing) |
|
be065e5c8042
Prepare symbols for a statement which defaults to token type "Text".
Franz Glasner <fzglas.hg@dom66.de>
parents:
57
diff
changeset
|
116 # SYMBOL_BLOCK = "●" # U+25CF: Unicode 1.0 (Geometric Shapes) |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
117 SYMBOL_TEXTSTATEMENT = "▪" # U+25AA: Unicode 1.0 (Geometric Shapes) |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
118 # SYMBOL_TEXTSTATEMENT = "■" # 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
|
119 SYMBOLS = { |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
120 # 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
|
121 "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
|
122 "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
|
123 # Group STATEMENT |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
124 "STATEMENT": SYMBOL_BLOCK, |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
125 "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
|
126 "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
|
127 # 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
|
128 "TEXTSTATEMENT": SYMBOL_TEXTSTATEMENT, |
|
78
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
129 "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
|
130 "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
|
131 "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
|
132 "TEXTBLOCK": SYMBOL_TEXTSTATEMENT, |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
133 "TBLOCK": SYMBOL_TEXTSTATEMENT, |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
134 "<-": "←", |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
135 "->": "→", |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
136 "=>": "⇒", |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
137 "<=": "≤", |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
138 ">=": "≥", |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
139 "<>": "≠", |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
140 "!=": "≠", |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
141 ":=": "∶=", # "≔" not recognizable |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
142 "=:": "=∶", # "≕", not recognizable |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
143 "<=>": "⇔", |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
144 "<->": "↔", |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
145 "?=": "≟", |
|
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
|
146 } |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
147 |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
148 def op_translate(toktype): |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
149 |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
150 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
|
151 kw = match.group().upper() |
|
38
69522d4cafac
Remove another unneeded local variable
Franz Glasner <fzglas.hg@dom66.de>
parents:
35
diff
changeset
|
152 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
|
153 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
|
154 ctx.pos = match.end() |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
155 |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
156 return _op_translate |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
157 |
| 57 | 158 def op_opt_end_translate(toktype): |
| 159 | |
| 160 def _op_end_translate(lexer, match, ctx=None): | |
| 161 if not lexer.no_end: | |
| 162 kw = match.group().upper() | |
| 163 yield (match.start(), | |
| 164 toktype, | |
| 165 lexer.END_TRANSLATIONS.get( | |
| 166 kw, | |
| 167 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
|
168 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
|
169 ctx.pos = match.end() |
| 57 | 170 |
| 171 return _op_end_translate | |
| 172 | |
|
62
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
61
diff
changeset
|
173 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
|
174 |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
61
diff
changeset
|
175 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
|
176 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
|
177 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
|
178 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
|
179 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
|
180 |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
61
diff
changeset
|
181 return _op_opt_ignore |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
61
diff
changeset
|
182 |
|
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
|
183 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
|
184 """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
|
185 `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
|
186 |
|
3f4223a79d2b
Normalize whitespace handling for entity names
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
187 """ |
|
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
|
188 |
|
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
|
189 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
|
190 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
|
191 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
|
192 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
|
193 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
|
194 |
|
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
|
195 return _op_opt_ignore_or_fixed |
|
65
3f4223a79d2b
Normalize whitespace handling for entity names
Franz Glasner <fzglas.hg@dom66.de>
parents:
64
diff
changeset
|
196 |
| 113 | 197 def op_gets(lexer, match, ctx=None): |
| 198 yield match.start(), Operator, lexer.symbol_gets | |
| 199 | |
|
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
|
200 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
|
201 |
|
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
|
202 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
|
203 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
|
204 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
|
205 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
|
206 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
|
207 |
|
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
|
208 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
|
209 |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
210 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
|
211 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
|
212 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
|
213 if toktype is None: |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
214 # Be more error friendly |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
215 toktype = Generic.Error |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
216 val = match.group() |
|
89
7414eed7b275
Introduce logging for unhandled explicit token types
Franz Glasner <fzglas.hg@dom66.de>
parents:
87
diff
changeset
|
217 _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
|
218 else: |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
219 val = match.group("character") |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
220 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
|
221 if ctx: |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
222 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
|
223 |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
224 tokens = { |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
225 "root": [ |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
226 (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
|
227 (r"/\*", Comment.Multiline, "multiline-nested-comment"), |
|
100
7cfad325d3bb
Allow also `#' to start single-line comments
Franz Glasner <fzglas.hg@dom66.de>
parents:
99
diff
changeset
|
228 (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
|
229 include("remark"), |
|
90
2af4684c8e78
Restrict whitespace before required and optional arguments.
Franz Glasner <fzglas.hg@dom66.de>
parents:
89
diff
changeset
|
230 (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
|
231 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
|
232 "block-expr"), |
|
78
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
233 (r"(?i)\\(" |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
234 r"(?:textstate(?:ment)?)" |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
235 r"|(?:tstate(?:ment)?)" |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
236 r"|(?:textblock)" |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
237 r"|(?:tblock)" |
|
90
2af4684c8e78
Restrict whitespace before required and optional arguments.
Franz Glasner <fzglas.hg@dom66.de>
parents:
89
diff
changeset
|
238 r")[ \t]*(\{)", |
|
78
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
239 bygroups(op_symbol(Text), LexBase.op_fixed(Whitespace, " ")), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
240 "text-statement"), |
| 97 | 241 (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
|
242 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
|
243 r"|(?:output(?:s)?)" |
|
108
6cebd3e7bc97
Also allow \REM within a \TEXT{}
Franz Glasner <fzglas.hg@dom66.de>
parents:
106
diff
changeset
|
244 r"|(?:ensure)" |
|
104
ffe6ea2cf69b
Allow "\RETURN" and "\RETURNS" commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
103
diff
changeset
|
245 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
|
246 r")[ \t]*(\{)", |
|
857df2064831
\INPUT, \INPUTS, \OUTPUT, \OUTPUTS, \RETURN and \RETURNS as new commands (keywords)
Franz Glasner <fzglas.hg@dom66.de>
parents:
98
diff
changeset
|
247 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
|
248 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
|
249 "text-statement"), |
|
857df2064831
\INPUT, \INPUTS, \OUTPUT, \OUTPUTS, \RETURN and \RETURNS as new commands (keywords)
Franz Glasner <fzglas.hg@dom66.de>
parents:
98
diff
changeset
|
250 (r"(?i)\\(" |
| 97 | 251 r"(?:if)" |
| 252 r"|(?:then)" | |
| 253 r"|(?:else)" | |
| 254 r"|(?:el(?:s(?:e)?)?if)" | |
|
111
d6f3a1d1bedd
Some more keywords (\FROM, \TO, \IN)
Franz Glasner <fzglas.hg@dom66.de>
parents:
109
diff
changeset
|
255 r"|(?:do)" # as in WHILE ... DO not DO ... UNTIL |
| 97 | 256 r"|(?:while)" |
| 257 r"|(?:forall)" | |
| 258 r"|(?:for)" | |
|
111
d6f3a1d1bedd
Some more keywords (\FROM, \TO, \IN)
Franz Glasner <fzglas.hg@dom66.de>
parents:
109
diff
changeset
|
259 r"|(?:from)" |
|
d6f3a1d1bedd
Some more keywords (\FROM, \TO, \IN)
Franz Glasner <fzglas.hg@dom66.de>
parents:
109
diff
changeset
|
260 r"|(?:to)" |
| 97 | 261 r"|(?:step)" |
|
111
d6f3a1d1bedd
Some more keywords (\FROM, \TO, \IN)
Franz Glasner <fzglas.hg@dom66.de>
parents:
109
diff
changeset
|
262 r"|(?:in)" |
| 97 | 263 r"|(?:loop)" |
| 264 r"|(?:repeat)" | |
| 265 r"|(?:until)" | |
|
104
ffe6ea2cf69b
Allow "\RETURN" and "\RETURNS" commands.
Franz Glasner <fzglas.hg@dom66.de>
parents:
103
diff
changeset
|
266 r"|(?:return)" |
| 97 | 267 r")\b", |
| 268 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
|
269 (r"\\\n", Text), |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
270 (r"(?i)\\(" |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
271 r"(?:prog(?:ram)?)" |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
272 r"|(?:algo(?:rithm)?)" |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
273 r"|(?:proc(?:edure)?)" |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
274 r"|(?:func(?:tion)?|(?:fn))" |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
275 r"|(?:class)" |
|
90
2af4684c8e78
Restrict whitespace before required and optional arguments.
Franz Glasner <fzglas.hg@dom66.de>
parents:
89
diff
changeset
|
276 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
|
277 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
|
278 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
|
279 "entity-name"), |
| 94 | 280 # ENDxxx keywords with optional entity name in two parts: |
| 281 # 1. with name | |
| 282 (r"(?i)\\end(?:[_\-]|(?:[ \t]+))?(" | |
| 57 | 283 r"(?:prog(?:ram)?)" |
| 284 r"|(?:algo(?:rithm)?)" | |
| 285 r"|(?:proc(?:edure)?)" | |
| 286 r"|(?:func(?:tion)?)" | |
|
96
98cd0787f62f
FIX: FN alias for function
Franz Glasner <fzglas.hg@dom66.de>
parents:
94
diff
changeset
|
287 r"|(?:fn)" |
| 57 | 288 r"|(?:class)" |
| 94 | 289 r")(?:[_\-]|(?:[\t ]+))?(\{)", |
|
62
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
61
diff
changeset
|
290 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
|
291 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
|
292 "entity-name-end"), |
| 94 | 293 # 2. without name |
| 294 # 3. AND keywords that do not allow a param (e.g. endif) | |
| 295 (r"(?i)\\end(?:[_\-]|(?:[ \t]+))?(" | |
| 57 | 296 r"(?:prog(?:ram)?)" |
| 297 r"|(?:algo(?:rithm)?)" | |
| 298 r"|(?:proc(?:edure)?)" | |
| 299 r"|(?:func(?:tion)?)" | |
|
96
98cd0787f62f
FIX: FN alias for function
Franz Glasner <fzglas.hg@dom66.de>
parents:
94
diff
changeset
|
300 r"|(?:fn)" |
| 57 | 301 r"|(?:class)" |
| 97 | 302 r"|(?:if)" |
| 303 r"|(?:while)" | |
| 304 r"|(?:for)" | |
| 305 r"|(?:forall)" | |
| 306 r"|(?:loop)" | |
|
62
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
61
diff
changeset
|
307 r")\b", |
| 57 | 308 bygroups(op_opt_end_translate(Keyword))), |
| 97 | 309 # |
| 310 # A single begin or end that is never suppressed because | |
| 311 # it is supposed to be paired with begin | |
| 312 # | |
| 313 (r"(?i)\\(begin|end)\b", | |
| 314 bygroups(op_translate(Keyword))), | |
|
61
392745b66969
The "\IS" keyword expansion
Franz Glasner <fzglas.hg@dom66.de>
parents:
58
diff
changeset
|
315 # Keywords |
|
392745b66969
The "\IS" keyword expansion
Franz Glasner <fzglas.hg@dom66.de>
parents:
58
diff
changeset
|
316 (r"(?i)\\(" |
|
392745b66969
The "\IS" keyword expansion
Franz Glasner <fzglas.hg@dom66.de>
parents:
58
diff
changeset
|
317 r"(?:is)" |
| 82 | 318 r"|(?:with)" |
|
61
392745b66969
The "\IS" keyword expansion
Franz Glasner <fzglas.hg@dom66.de>
parents:
58
diff
changeset
|
319 r")\b", |
|
392745b66969
The "\IS" keyword expansion
Franz Glasner <fzglas.hg@dom66.de>
parents:
58
diff
changeset
|
320 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
|
321 include("expr"), |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
322 include("unicode-separators"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
323 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
|
324 (r"[^\S\n]+", Text), |
|
98
c1f93e109798
More tolerance for errors: yield more Generic.Error tokens
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
325 (r".", Generic.Error), # tolerance for errors |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
326 ], |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
327 "remark": [ |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
328 (r"(?i)\\(remark|rem)\b(.*)$", |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
329 bygroups(op_symbol(Comment.Single), Comment.Single)), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
330 ], |
|
62
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
61
diff
changeset
|
331 "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
|
332 (r"[^\\}]+", Name.Entity), |
|
77
1a5e192aa950
Move popping states consistently more to the begin
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
333 (r"\}", LexBase.op_ignore, "#pop"), |
|
74
c1357674622d
Remove an escaping backslash where appropriate
Franz Glasner <fzglas.hg@dom66.de>
parents:
72
diff
changeset
|
334 (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
|
335 (r"\\\\", LexBase.op_fixed(Name.Entity, "\\")), |
|
74
c1357674622d
Remove an escaping backslash where appropriate
Franz Glasner <fzglas.hg@dom66.de>
parents:
72
diff
changeset
|
336 (r"\\", LexBase.op_fixed(Name.Entity, "\\")), |
|
62
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
61
diff
changeset
|
337 ], |
|
7153e945a3d6
Implement ignoring of \ENDxxx including its optional name parts
Franz Glasner <fzglas.hg@dom66.de>
parents:
61
diff
changeset
|
338 "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
|
339 (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
|
340 (r"\}", LexBase.op_ignore, "#pop"), |
|
74
c1357674622d
Remove an escaping backslash where appropriate
Franz Glasner <fzglas.hg@dom66.de>
parents:
72
diff
changeset
|
341 (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
|
342 (r"\\\\", op_opt_ignore_or_fixed(Name.Entity, "\\")), |
|
74
c1357674622d
Remove an escaping backslash where appropriate
Franz Glasner <fzglas.hg@dom66.de>
parents:
72
diff
changeset
|
343 (r"\\", op_opt_ignore_or_fixed(Name.Entity, "\\")), |
|
40
df08226a6984
Names for some entities (program, algorithm, function, procedure, class).
Franz Glasner <fzglas.hg@dom66.de>
parents:
39
diff
changeset
|
344 ], |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
345 "expr": [ |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
346 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
|
347 include("ascii-punctuation"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
348 include("unicode-punctuation"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
349 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
|
350 include("py-strings"), |
|
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
351 include("py-numbers"), |
| 113 | 352 (r"(?i)\\gets\b", op_gets), |
|
90
2af4684c8e78
Restrict whitespace before required and optional arguments.
Franz Glasner <fzglas.hg@dom66.de>
parents:
89
diff
changeset
|
353 (r"(?i)\\text[ \t]*\{", LexBase.op_ignore, "text-in-expr"), |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
354 include("explicit-tokentype"), |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
355 include("remark"), |
|
81
6d8b813fb296
Keyword constants like "True", "False", "Nil", "None", "Null" and "Empty"
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
356 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
|
357 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
|
358 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
|
359 include("py-name"), |
|
70
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
65
diff
changeset
|
360 ], |
|
80
f487f0d322a5
Move "expr-in-braces" up to "expr".
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
361 "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
|
362 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
|
363 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
|
364 include("unicode-punctuation"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
365 include("escaped-string-start"), |
|
80
f487f0d322a5
Move "expr-in-braces" up to "expr".
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
366 include("py-strings"), |
|
f487f0d322a5
Move "expr-in-braces" up to "expr".
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
367 include("py-numbers"), |
| 113 | 368 (r"(?i)\\gets\b", op_gets), |
|
90
2af4684c8e78
Restrict whitespace before required and optional arguments.
Franz Glasner <fzglas.hg@dom66.de>
parents:
89
diff
changeset
|
369 (r"(?i)\\text[ \t]*\{", LexBase.op_ignore, "text-in-expr"), |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
370 include("explicit-tokentype"), |
|
80
f487f0d322a5
Move "expr-in-braces" up to "expr".
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
371 include("remark"), |
|
81
6d8b813fb296
Keyword constants like "True", "False", "Nil", "None", "Null" and "Empty"
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
372 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
|
373 include("word-operators"), |
|
80
f487f0d322a5
Move "expr-in-braces" up to "expr".
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
374 include("math-builtins"), |
|
f487f0d322a5
Move "expr-in-braces" up to "expr".
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
375 include("py-name"), |
|
f487f0d322a5
Move "expr-in-braces" up to "expr".
Franz Glasner <fzglas.hg@dom66.de>
parents:
78
diff
changeset
|
376 ], |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
377 "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
|
378 (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
|
379 (r"\n", Whitespace), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
380 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
|
381 (r"\\\\", LexBase.op_fixed(Text, "\\")), |
|
27e12387154d
FIX: Handle escape character more thoroughly: also explicitely handle "\\"
Franz Glasner <fzglas.hg@dom66.de>
parents:
75
diff
changeset
|
382 (r"\\", LexBase.op_fixed(Text, "\\")), |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
383 include("unicode-separators"), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
384 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
|
385 (r"[^\S\n]+", Text), |
|
98
c1f93e109798
More tolerance for errors: yield more Generic.Error tokens
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
386 (r".", Generic.Error), # tolerance for errors |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
387 ], |
|
78
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
388 "text-statement": [ # like block but default to text-mode |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
389 (r"[^\\}\n]+", Text), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
390 (r"\}", LexBase.op_ignore, "#pop"), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
391 (r"\n", Whitespace), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
392 (r"\\\}", LexBase.op_fixed(Text, "}")), |
|
90
2af4684c8e78
Restrict whitespace before required and optional arguments.
Franz Glasner <fzglas.hg@dom66.de>
parents:
89
diff
changeset
|
393 (r"(?i)\\expr(?:ession)?[ \t]*\{", |
|
78
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
394 LexBase.op_ignore, |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
395 "block-expr"), |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
396 include("explicit-tokentype"), |
|
78
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
397 include("remark"), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
398 (r"\\\\", LexBase.op_fixed(Text, "\\")), |
|
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
399 (r"\\", LexBase.op_fixed(Text, "\\")), |
|
98
c1f93e109798
More tolerance for errors: yield more Generic.Error tokens
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
400 (r".", Generic.Error), # tolerance for errors |
|
78
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
401 ], |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
402 "text-in-expr": [ |
|
77
1a5e192aa950
Move popping states consistently more to the begin
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
403 (r"[^\\}\n]+", Text), |
|
1a5e192aa950
Move popping states consistently more to the begin
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
404 (r"\}", LexBase.op_ignore, "#pop"), |
|
1a5e192aa950
Move popping states consistently more to the begin
Franz Glasner <fzglas.hg@dom66.de>
parents:
76
diff
changeset
|
405 (r"\n", Whitespace), |
|
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
|
406 (r"\\\}", LexBase.op_fixed(Text, "}")), |
|
92
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
91
diff
changeset
|
407 (r"(?i)\\expr(?:ession)?[ \t]*\{", |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
91
diff
changeset
|
408 LexBase.op_ignore, |
|
3f37832c405d
FIX: Wrong state for \TEXT command
Franz Glasner <fzglas.hg@dom66.de>
parents:
91
diff
changeset
|
409 "block-expr"), |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
410 include("explicit-tokentype"), |
|
108
6cebd3e7bc97
Also allow \REM within a \TEXT{}
Franz Glasner <fzglas.hg@dom66.de>
parents:
106
diff
changeset
|
411 include("remark"), |
|
78
abb2e8c65d0f
Implement "TEXTSTATEMENT"
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
412 (r"\\\\", LexBase.op_fixed(Text, "\\")), |
|
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
|
413 (r"\\", LexBase.op_fixed(Text, "\\")), |
|
98
c1f93e109798
More tolerance for errors: yield more Generic.Error tokens
Franz Glasner <fzglas.hg@dom66.de>
parents:
97
diff
changeset
|
414 (r".", Generic.Error), # tolerance for errors |
|
70
5517b0be67f0
Basic "\TEXT" escape for expressions
Franz Glasner <fzglas.hg@dom66.de>
parents:
65
diff
changeset
|
415 ], |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
416 "math-builtins": [ |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
417 (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
|
418 "arctan", "arctan2", "mod", "exp", "ln", "log", |
|
d8368294413a
"min" and "max" as automatic mathematical operators
Franz Glasner <fzglas.hg@dom66.de>
parents:
100
diff
changeset
|
419 "min", "max"), |
|
75
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
420 prefix=r"(?<!\.)", |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
421 suffix=r"\b"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
422 Name.Builtin), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
423 ], |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
424 "math-symbols": [ |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
425 (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
|
426 (r"[!&<>=+\-*/%|~]", Operator), # ASCII |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
427 (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
|
428 ], |
|
93
84c0f761c836
Renamed "text-operators" to "word-operators" and allow more case-variants
Franz Glasner <fzglas.hg@dom66.de>
parents:
92
diff
changeset
|
429 "word-operators": [ |
|
84c0f761c836
Renamed "text-operators" to "word-operators" and allow more case-variants
Franz Glasner <fzglas.hg@dom66.de>
parents:
92
diff
changeset
|
430 (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
|
431 "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
|
432 "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
|
433 "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
|
434 "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
|
435 "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
|
436 prefix=r"(?<!\.)", |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
437 suffix=r"\b"), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
438 Operator.Word), |
|
711f8d19e27a
New implementation of "STATEMENT" (also aliased to "STATE" and "BLOCK").
Franz Glasner <fzglas.hg@dom66.de>
parents:
74
diff
changeset
|
439 ], |
|
81
6d8b813fb296
Keyword constants like "True", "False", "Nil", "None", "Null" and "Empty"
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
440 "keyword-constants": [ |
|
6d8b813fb296
Keyword constants like "True", "False", "Nil", "None", "Null" and "Empty"
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
441 (words(("True", "TRUE", "true", "False", "FALSE", "false", |
|
103
af97692501ea
FIX: Typo: "non" -> "none"
Franz Glasner <fzglas.hg@dom66.de>
parents:
102
diff
changeset
|
442 "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
|
443 "Null", "NULL", "null", |
|
6d8b813fb296
Keyword constants like "True", "False", "Nil", "None", "Null" and "Empty"
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
444 "Empty", "EMPTY", "empty"), |
|
6d8b813fb296
Keyword constants like "True", "False", "Nil", "None", "Null" and "Empty"
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
445 prefix=r"(?<!\.)", |
|
6d8b813fb296
Keyword constants like "True", "False", "Nil", "None", "Null" and "Empty"
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
446 suffix=r"\b"), |
|
6d8b813fb296
Keyword constants like "True", "False", "Nil", "None", "Null" and "Empty"
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
447 Keyword.Constant), |
|
6d8b813fb296
Keyword constants like "True", "False", "Nil", "None", "Null" and "Empty"
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
448 ], |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
449 "ascii-punctuation": [ |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
450 (r"[{}:(),;[\]?@]", Punctuation), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
451 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
452 "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
|
453 # |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
454 # 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
|
455 # 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
|
456 # |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
457 (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
|
458 (r"[{:(),;[\]?@]", Punctuation), |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
459 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
460 "unicode-separators": [ |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
461 (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
|
462 (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
|
463 (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
|
464 ], |
|
105
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
465 "unicode-punctuation": [ |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
466 (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
|
467 (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
|
468 (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
|
469 (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
|
470 (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
|
471 (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
|
472 (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
|
473 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
474 "unicode-other": [ |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
475 (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
|
476 (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
|
477 ], |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
478 "escaped-string-start": [ |
|
cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
479 (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
|
480 ], |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
481 "explicit-tokentype": [ |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
482 # 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
|
483 |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
484 # Multiple characters possible, but no escaping! |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
485 (r"\\ttx\-(?P<type>[a-zA-Z0-9_-]+?)(?P<sep>[/:|=*+!\$~])" |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
486 r"(?P<character>(.|\n)+?)(?P=sep)", |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
487 op_explicit_tokentype), |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
488 (r"\\ttx\-(?P<type>[a-zA-Z0-9_-]+?)\{(?P<character>[^}]+?)\}", |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
489 op_explicit_tokentype), |
|
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
490 (r"\\ttx\-(?P<type>[a-zA-Z0-9_-]+?)\((?P<character>[^)]+?)\)", |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
491 op_explicit_tokentype), |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
492 (r"\\ttx\-(?P<type>[a-zA-Z0-9_-]+?)<(?P<character>[^>]+?)>", |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
493 op_explicit_tokentype), |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
494 (r"\\ttx\-(?P<type>[a-zA-Z0-9_-]+?)\[(?P<character>[^\]]+?)\]", |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
495 op_explicit_tokentype), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
496 |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
497 # Every character is possible: no escaping needed! |
|
87
d8ca835c74ea
FIX: Erroneous parsing of \tt-XXX and \ttx-XXX:
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
498 (r"\\tt-(?P<type>[^/]+?)/(?P<character>(?:.|\n))", |
|
84
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
499 op_explicit_tokentype), |
|
3ac1c4502ad0
Implement "\tt-XXX" and "ttx-XXX" for explicit token types.
Franz Glasner <fzglas.hg@dom66.de>
parents:
83
diff
changeset
|
500 ], |
|
34
1f741934205e
Begin a new Pseudocode lexer using numbers and strings from Python
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
501 } |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
502 |
| 57 | 503 def __init__(self, **options): |
| 504 val = pygments.util.get_bool_opt(options, "no_end", default=False) | |
| 505 self.no_end = val | |
| 113 | 506 self.symbol_gets = options.get("gets", "←") |
| 57 | 507 LexBase.__init__(self, **options) |
| 508 | |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
509 |
|
53
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
510 class AlgPseudocodeLexer_DE(AlgPseudocodeLexer): |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
511 |
|
112
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
512 """ |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
513 |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
514 .. seealso:: |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
515 - https://de.wikipedia.org/wiki/Pseudocode |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
516 |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
517 """ |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
518 |
|
53
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
519 name = "AlgPseudocodeDE" |
|
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
520 aliases = ["algpseudocode-de", "algpseudo-de"] |
|
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
521 filenames = ["*.algpseudo-de", "*.algpseudocode-de"] |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
522 |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
523 LANG = "de" |
|
53
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
524 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
|
525 TRANSLATIONS.update({ |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
526 "PROG": "PROGRAMM", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
527 "PROGRAM": "PROGRAMM", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
528 "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
|
529 "ALGORITHM": "ALGORITHMUS", |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
530 "PROC": "PROZEDUR", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
531 "PROCEDURE": "PROZEDUR", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
532 "FUNC": "FUNKTION", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
533 "FUNCTION": "FUNKTION", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
534 "FN": "FUNKTION", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
535 "CLASS": "KLASSE", |
|
61
392745b66969
The "\IS" keyword expansion
Franz Glasner <fzglas.hg@dom66.de>
parents:
58
diff
changeset
|
536 "IS": "IST", |
| 82 | 537 "WITH": "MIT", |
|
112
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
538 "IF": "WENN", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
539 "THEN": "DANN", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
540 "ELSE": "ANDERNFALLS", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
541 "ELSEIF": "ANDERNFALLS WENN", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
542 "ELSIF": "ANDERNFALLS WENN", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
543 "ELIF": "ANDERNFALLS WENN", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
544 # "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
|
545 "WHILE": "SOLANGE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
546 "FOR": "FÜR", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
547 "FORALL": "FÜR ALLE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
548 "FROM": "VON", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
549 "TO": "BIS", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
550 "IN": "IN", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
551 "STEP": "SCHRITTWEITE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
552 # "LOOP": XXX TBD # noqa |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
553 "REPEAT": "WIEDERHOLE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
554 "UNTIL": "BIS", |
| 113 | 555 # "RETURN": XXX TBD # noqa |
|
112
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
556 "BEGIN": "START", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
557 "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
|
558 }) |
| 57 | 559 END_TRANSLATIONS = AlgPseudocodeLexer.END_TRANSLATIONS.copy() |
| 560 END_TRANSLATIONS.update({ | |
| 561 "PROG": "ENDE DES PROGRAMMS", | |
|
112
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
562 "PROGRAM": "ENDE DES PROGRAMMS", |
| 57 | 563 "ALGO": "ENDE DES ALGORITHMUS", |
| 564 "ALGORITHM": "ENDE DES ALGORITHMUS", | |
| 565 "PROC": "ENDE DER PROZEDUR", | |
| 566 "PROCEDURE": "ENDE DER PROZEDUR", | |
| 567 "FUNC": "ENDE DER FUNKTION", | |
| 568 "FUNCTION": "ENDE DER FUNKTION", | |
| 569 "FN": "ENDE DER FUNKTION", | |
| 570 "CLASS": "ENDE DER KLASSE", | |
|
112
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
571 "IF": "ENDE WENN", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
572 "WHILE": "ENDE SOLANGE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
573 "FOR": "ENDE FÜR", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
574 "FORALL": "ENDE FÜR ALLE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
575 # "LOOP": "ENDE XXX", # XXX TBD # noqa |
| 57 | 576 }) |
| 577 DEFAULT_END_PREFIX = "ENDE VON " | |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
578 |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
579 |
|
53
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
580 class AlgPseudocodeLexer_FR(AlgPseudocodeLexer): |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
581 |
|
112
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
582 """ |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
583 |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
584 .. seealso:: |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
585 - https://info.blaisepascal.fr/pseudo-code/ |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
586 - https://fr.wikipedia.org/wiki/Pseudo-code |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
587 - 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
|
588 |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
589 """ |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
590 |
|
53
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
591 name = "AlgPseudocodeFR" |
|
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
592 aliases = ["algpseudocode-fr", "algpseudo-fr"] |
|
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
593 filenames = ["*.algpseudo-fr", "*.algpseudocode-fr"] |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
594 |
|
109
49e5aa89095f
FIX: LANG for the french lexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
108
diff
changeset
|
595 LANG = "fr" |
|
53
39151225fb84
Rename the new pseudocode implementation to AlgPseudocode.
Franz Glasner <fzglas.hg@dom66.de>
parents:
52
diff
changeset
|
596 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
|
597 TRANSLATIONS.update({ |
|
35
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
598 "PROG": "PROGRAMME", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
599 "PROGRAM": "PROGRAMME", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
600 "ALGO": "ALGORITHME", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
601 "ALGORITHM": "ALGORITHME", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
602 "PROC": "PROCÉDURE", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
603 "PROCEDURE": "PROCÉDURE", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
604 "FUNC": "FONCTION", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
605 "FUNCTION": "FOUNCTION", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
606 "FN": "FONCTION", |
|
d9a3551a1038
Basics of translating some keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
34
diff
changeset
|
607 "CLASS": "CLASSE", |
|
61
392745b66969
The "\IS" keyword expansion
Franz Glasner <fzglas.hg@dom66.de>
parents:
58
diff
changeset
|
608 "IS": "EST", |
| 82 | 609 "WITH": "AVEC", |
|
112
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
610 "IF": "SI", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
611 "THEN": "ALORS", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
612 "ELSE": "SINON", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
613 "ELSEIF": "SINONSI", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
614 "ELSIF": "SINONSI", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
615 "ELIF": "SINONSI", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
616 "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
|
617 "WHILE": "TANTQUE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
618 "FOR": "POUR", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
619 "FORALL": "POUR CHAQUE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
620 "FROM": "DE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
621 "TO": "JUSQU'À", # or just "À", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
622 "IN": "DANS", # as in FOR ... IN |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
623 "STEP": "PAR PAS DE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
624 "LOOP": "BOUCLE", # XXX FIXME??? |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
625 "REPEAT": "RÉPÉTER", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
626 "UNTIL": "JUSQUACEQUE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
627 "RETURN": "RENVOYER", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
628 "BEGIN": "DÉBUT", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
629 "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
|
630 }) |
| 57 | 631 END_TRANSLATIONS = AlgPseudocodeLexer.END_TRANSLATIONS.copy() |
| 632 END_TRANSLATIONS.update({ | |
| 633 "PROG": "FIN DE PROGRAMME", | |
| 634 "PROGRAM": "FIN DE PROGRAMME", | |
| 635 "ALGO": "FIN D'ALGORITHME", | |
| 636 "ALGORITHM": "FIN D'ALGORITHME", | |
| 637 "PROC": "FIN DE PROCÉDURE", | |
| 638 "PROCEDURE": "FIN DE PROCÉDURE", | |
| 639 "FUNC": "FIN DE FONCTION", | |
| 640 "FUNCTION": "FIN DE FOUNCTION", | |
| 641 "FN": "FIN DE FONCTION", | |
| 642 "CLASS": "FIN DE CLASSE", | |
|
112
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
643 "SI": "FIN SI", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
644 "FOR": "FIN POUR", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
645 "FORALL": "FIN POUR CHAQUE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
646 "WHILE": "FIN TANTQUE", |
|
ec8767cc5493
More translations (FR and DE)
Franz Glasner <fzglas.hg@dom66.de>
parents:
111
diff
changeset
|
647 "LOOP": "FIN BOUCLE", |
| 57 | 648 }) |
| 649 DEFAULT_END_PREFIX = "FIN DE " |
