changeset 114:be50fe0687d6

The \CALL command
author Franz Glasner <fzglas.hg@dom66.de>
date Wed, 06 May 2026 01:10:11 +0200
parents 9aea2fd5f037
children e1663ac707b0
files pygments_lexer_pseudocode2/algpseudocode.py tests/test_algpseudo.py
diffstat 2 files changed, 32 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/pygments_lexer_pseudocode2/algpseudocode.py	Tue May 05 20:51:20 2026 +0200
+++ b/pygments_lexer_pseudocode2/algpseudocode.py	Wed May 06 01:10:11 2026 +0200
@@ -349,6 +349,7 @@
             include("escaped-string-start"),
             include("py-strings"),
             include("py-numbers"),
+            (r"(?i)\\call[ \t]*(\{)", LexBase.op_ignore, "entity-name"),
             (r"(?i)\\gets\b", op_gets),
             (r"(?i)\\text[ \t]*\{", LexBase.op_ignore, "text-in-expr"),
             include("explicit-tokentype"),
@@ -365,6 +366,7 @@
             include("escaped-string-start"),
             include("py-strings"),
             include("py-numbers"),
+            (r"(?i)\\call[ \t]*(\{)", LexBase.op_ignore, "entity-name"),
             (r"(?i)\\gets\b", op_gets),
             (r"(?i)\\text[ \t]*\{", LexBase.op_ignore, "text-in-expr"),
             include("explicit-tokentype"),
--- a/tests/test_algpseudo.py	Tue May 05 20:51:20 2026 +0200
+++ b/tests/test_algpseudo.py	Wed May 06 01:10:11 2026 +0200
@@ -899,6 +899,36 @@
              ],
             pygments.lex(r"a \gets 2.7", lexer))
 
+    def test_call(self):
+        self.assertTokenStreamEqualComplete(
+            [("Name.Entity", "a function"),
+             ("Punctuation", "("),
+             ("Name.Entity", "p1"),
+             ("Punctuation", ","),
+             ("Text", " "),
+             ("Name.Entity", "p2"),
+             ("Punctuation", ")"),
+             ("Text.Whitespace", "\n"),
+             ],
+            pygments.lex(r"\CALL{a function}(p1, p2)", self.lexer))
+
+    def test_call_in_expr(self):
+        self.assertTokenStreamEqualComplete(
+            [("Name.Entity", "a procedure"),
+             ("Punctuation", "("),
+             ("Name.Entity", "arg1"),
+             ("Punctuation", ","),
+             ("Text", " "),
+             ("Name.Entity", "arg2"),
+             ("Punctuation", ","),
+             ("Text", " "),
+             ("Name.Entity", "arg3"),
+             ("Punctuation", ")"),
+             ("Text.Whitespace", "\n"),
+             ],
+            pygments.lex(r"\TEXT{\EXPR{\CALL{a procedure}(arg1, arg2, arg3)}}",
+                         self.lexer))
+
 
 class PygmentizeCompletely(unittest.TestCase):