Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
diff pygments_lexer_pseudocode2/algpseudocode.py @ 97:dd4eb937485c
A couple of new keywords
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 03 May 2026 15:18:35 +0200 |
| parents | 98cd0787f62f |
| children | c1f93e109798 |
line wrap: on
line diff
--- a/pygments_lexer_pseudocode2/algpseudocode.py Sun May 03 15:15:34 2026 +0200 +++ b/pygments_lexer_pseudocode2/algpseudocode.py Sun May 03 15:18:35 2026 +0200 @@ -64,6 +64,22 @@ "CLASS": "CLASS", "IS": "IS", "WITH": "WITH", + "IF": "IF", + "THEN": "THEN", + "ELSE": "ELSE", + "ELSEIF": "ELSE IF", + "ELSIF": "ELSE IF", + "ELIF": "ELSE IF", + "DO": "DO", + "WHILE": "WHILE", + "FOR": "FOR", + "FORALL": "FOR ALL", + "STEP": "STEP", + "LOOP": "LOOP", + "REPEAT": "REPEAT", + "UNTIL": "UNTIL", + "BEGIN": "BEGIN", + "END": "END", # not in END_TRANSLATIONS } END_TRANSLATIONS = { "PROG": "END OF PROGRAM", @@ -76,6 +92,11 @@ "FUNCTION": "END OF FUNCTION", "FN": "END OF FUNCTION", "CLASS": "END OF CLASS", + "IF": "END IF", + "WHILE": "END WHILE", + "FOR": "END FOR", + "FORALL": "END FOR ALL", + "LOOP": "END LOOP", } DEFAULT_END_PREFIX = "END OF " SYMBOL_REMARK = "▷" # U+25B7: Unicode 1.0 (Geometric Shapes) @@ -192,6 +213,21 @@ r")[ \t]*(\{)", bygroups(op_symbol(Text), LexBase.op_fixed(Whitespace, " ")), "text-statement"), + (r"(?i)\\(" + r"(?:if)" + r"|(?:then)" + r"|(?:else)" + r"|(?:el(?:s(?:e)?)?if)" + r"|(?:do)" + r"|(?:while)" + r"|(?:forall)" + r"|(?:for)" + r"|(?:step)" + r"|(?:loop)" + r"|(?:repeat)" + r"|(?:until)" + r")\b", + bygroups(op_translate(Keyword))), (r"\\\n", Text), (r"(?i)\\(" r"(?:prog(?:ram)?)" @@ -225,8 +261,19 @@ r"|(?:func(?:tion)?)" r"|(?:fn)" r"|(?:class)" + r"|(?:if)" + r"|(?:while)" + r"|(?:for)" + r"|(?:forall)" + r"|(?:loop)" r")\b", bygroups(op_opt_end_translate(Keyword))), + # + # A single begin or end that is never suppressed because + # it is supposed to be paired with begin + # + (r"(?i)\\(begin|end)\b", + bygroups(op_translate(Keyword))), # Keywords (r"(?i)\\(" r"(?:is)"
