Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
changeset 149:380d2607d5c7
Implement the "\NAME" command.
Implemented just as \CALL it is better named for just highlighting entity names
properly. \CALL suggests a function or procedure call.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Thu, 07 May 2026 15:49:13 +0200 |
| parents | b4688f6cc7b1 |
| children | 4acf578ae93f |
| files | pygments_lexer_pseudocode2/algpseudocode.py tests/test_algpseudo.py |
| diffstat | 2 files changed, 32 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/pygments_lexer_pseudocode2/algpseudocode.py Thu May 07 14:35:48 2026 +0200 +++ b/pygments_lexer_pseudocode2/algpseudocode.py Thu May 07 15:49:13 2026 +0200 @@ -361,7 +361,7 @@ include("escaped-string-start"), include("py-strings"), include("py-numbers"), - (r"(?i)\\call[ \t]*(\{)", LexBase.op_ignore, "entity-name"), + (r"(?i)\\(call|name)[ \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"), @@ -378,7 +378,7 @@ include("escaped-string-start"), include("py-strings"), include("py-numbers"), - (r"(?i)\\call[ \t]*(\{)", LexBase.op_ignore, "entity-name"), + (r"(?i)\\(call|name)[ \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 Thu May 07 14:35:48 2026 +0200 +++ b/tests/test_algpseudo.py Thu May 07 15:49:13 2026 +0200 @@ -938,6 +938,36 @@ pygments.lex(r"\TEXT{\EXPR{\CALL{a procedure}(arg1, arg2, arg3)}}", self.lexer)) + def test_name(self): + self.assertTokenStreamEqualComplete( + [("Name.Entity", "an entity"), + ("Punctuation", "("), + ("Name.Entity", "p1"), + ("Punctuation", ","), + ("Text", " "), + ("Name.Entity", "p2"), + ("Punctuation", ")"), + ("Text.Whitespace", "\n"), + ], + pygments.lex(r"\NAME{an entity}(p1, p2)", self.lexer)) + + def test_name_in_expr(self): + self.assertTokenStreamEqualComplete( + [("Name.Entity", "an entity"), + ("Punctuation", "("), + ("Name.Entity", "arg1"), + ("Punctuation", ","), + ("Text", " "), + ("Name.Entity", "arg2"), + ("Punctuation", ","), + ("Text", " "), + ("Name.Entity", "arg3"), + ("Punctuation", ")"), + ("Text.Whitespace", "\n"), + ], + pygments.lex(r"\TEXT{\EXPR{\NAME{an entity}(arg1, arg2, arg3)}}", + self.lexer)) + def test_comment_multi(self): self.assertTokenStreamEqualComplete( [("Comment.Multiline", "/*"),
