comparison pygments_lexer_pseudocode2/__init__.py @ 21:5705ac8a4fd5

Arrow "=>" -> "⇒"
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 20 Apr 2026 15:59:32 +0200
parents 3db60b64abf6
children b42168cc9884
comparison
equal deleted inserted replaced
20:3db60b64abf6 21:5705ac8a4fd5
38 38
39 REPLACEMENTS = { 39 REPLACEMENTS = {
40 '<=': '≤', 40 '<=': '≤',
41 '>=': '≥', 41 '>=': '≥',
42 '<>': '≠', 42 '<>': '≠',
43 '!=': '≠', 43 '!=': '≠',
44 '<-': '←', 44 '<-': '←',
45 '->': '→',
46 '=>': '⇒',
45 '^': '↑', 47 '^': '↑',
46 } 48 }
47 49
48 def op_replace(lexer, match): 50 def op_replace(lexer, match):
49 op = match.group(0) 51 op = match.group(0)
59 61
60 directives = ['passage par copie', 'passage par valeur', 'passage par référence', 'passage par reference', 'passage par adresse', 've', 'vs', 've/s'] 62 directives = ['passage par copie', 'passage par valeur', 'passage par référence', 'passage par reference', 'passage par adresse', 've', 'vs', 've/s']
61 63
62 if s in directives: 64 if s in directives:
63 c = Comment.Special 65 c = Comment.Special
64 66
65 yield match.start(), c, match.group(0) 67 yield match.start(), c, match.group(0)
66 68
67 tokens = { 69 tokens = {
68 'root': [ 70 'root': [
69 (r'\/\*.*\*\/', Comment), 71 (r'\/\*.*\*\/', Comment),
70 (r'(\/\/|#).*\n', Comment), 72 (r'(\/\/|#).*\n', Comment),
71 (r'\|', Comment), 73 (r'\|', Comment),
83 r'classe' 85 r'classe'
84 r')\s*\b', Keyword), 86 r')\s*\b', Keyword),
85 87
86 # Data Types 88 # Data Types
87 (r'\b(entiers?|chaines?|chaînes?|réels?|reels?|caractères?|caracteres?|booléens?|' 89 (r'\b(entiers?|chaines?|chaînes?|réels?|reels?|caractères?|caracteres?|booléens?|'
88 r'booleens?|tableaux?|rien)\s*\b', 90 r'booleens?|tableaux?|rien)\s*\b',
89 Keyword.Type), 91 Keyword.Type),
90 92
91 (r'\b(vrai|faux|nil)\s*\b', 93 (r'\b(vrai|faux|nil)\s*\b',
92 Name.Constant), 94 Name.Constant),
93 95
94 # Operators 96 # Operators
95 (r'(<=|>=|<>|!=|<-|\^|\*|\+|-|\/|<|>|=|\\\\|mod|←|↑|≤|≥|≠|÷|×|\.\.|\[|\]|\.|non|xou|et|ou)', 97 (r'(<=|>=|<>|!=|<-|->|=>|\^|\*|\+|-|\/|<|>|=|\\\\|mod|←|↑|≤|≥|≠|÷|×|\.\.|\[|\]|\.|non|xou|et|ou)',
96 op_replace), 98 op_replace),
97 99
98 (r'(\(|\)|\,|\;|:)', 100 (r'(\(|\)|\,|\;|:)',
99 Punctuation), 101 Punctuation),
100 102
101 #(r'\b(\[(VE|VS|VE/S)\])\s*\b', 103 #(r'\b(\[(VE|VS|VE/S)\])\s*\b',
102 # Keyword.Declaration), 104 # Keyword.Declaration),
103 105
104 # Intrinsics 106 # Intrinsics
105 (r'\b(sqrt|pow|cos|sin|tan|arccos|arcsin|arctan|arctan2|lire|ecrire|écrire|' 107 (r'\b(sqrt|pow|cos|sin|tan|arccos|arcsin|arctan|arctan2|lire|ecrire|écrire|'
116 (r'\d+(?![.Ee])', Number.Integer), 118 (r'\d+(?![.Ee])', Number.Integer),
117 (r'[+-]?\d*\.\d+([eE][-+]?\d+)?', Number.Float), 119 (r'[+-]?\d*\.\d+([eE][-+]?\d+)?', Number.Float),
118 (r'[+-]?\d+\.\d*([eE][-+]?\d+)?', Number.Float) 120 (r'[+-]?\d+\.\d*([eE][-+]?\d+)?', Number.Float)
119 ], 121 ],
120 } 122 }
121