Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 112:ec8767cc5493 | 113:9aea2fd5f037 |
|---|---|
| 191 yield match.start(), toktype, value | 191 yield match.start(), toktype, value |
| 192 if ctx: | 192 if ctx: |
| 193 ctx.pos = match.end() | 193 ctx.pos = match.end() |
| 194 | 194 |
| 195 return _op_opt_ignore_or_fixed | 195 return _op_opt_ignore_or_fixed |
| 196 | |
| 197 def op_gets(lexer, match, ctx=None): | |
| 198 yield match.start(), Operator, lexer.symbol_gets | |
| 196 | 199 |
| 197 def op_symbol(toktype): | 200 def op_symbol(toktype): |
| 198 | 201 |
| 199 def _op_symbol(lexer, match, ctx=None): | 202 def _op_symbol(lexer, match, ctx=None): |
| 200 kw = match.group().upper() | 203 kw = match.group().upper() |
| 344 include("ascii-punctuation"), | 347 include("ascii-punctuation"), |
| 345 include("unicode-punctuation"), | 348 include("unicode-punctuation"), |
| 346 include("escaped-string-start"), | 349 include("escaped-string-start"), |
| 347 include("py-strings"), | 350 include("py-strings"), |
| 348 include("py-numbers"), | 351 include("py-numbers"), |
| 352 (r"(?i)\\gets\b", op_gets), | |
| 349 (r"(?i)\\text[ \t]*\{", LexBase.op_ignore, "text-in-expr"), | 353 (r"(?i)\\text[ \t]*\{", LexBase.op_ignore, "text-in-expr"), |
| 350 include("explicit-tokentype"), | 354 include("explicit-tokentype"), |
| 351 include("remark"), | 355 include("remark"), |
| 352 include("keyword-constants"), | 356 include("keyword-constants"), |
| 353 include("word-operators"), | 357 include("word-operators"), |
| 359 include("ascii-punctuation-in-braces"), | 363 include("ascii-punctuation-in-braces"), |
| 360 include("unicode-punctuation"), | 364 include("unicode-punctuation"), |
| 361 include("escaped-string-start"), | 365 include("escaped-string-start"), |
| 362 include("py-strings"), | 366 include("py-strings"), |
| 363 include("py-numbers"), | 367 include("py-numbers"), |
| 368 (r"(?i)\\gets\b", op_gets), | |
| 364 (r"(?i)\\text[ \t]*\{", LexBase.op_ignore, "text-in-expr"), | 369 (r"(?i)\\text[ \t]*\{", LexBase.op_ignore, "text-in-expr"), |
| 365 include("explicit-tokentype"), | 370 include("explicit-tokentype"), |
| 366 include("remark"), | 371 include("remark"), |
| 367 include("keyword-constants"), | 372 include("keyword-constants"), |
| 368 include("word-operators"), | 373 include("word-operators"), |
| 496 } | 501 } |
| 497 | 502 |
| 498 def __init__(self, **options): | 503 def __init__(self, **options): |
| 499 val = pygments.util.get_bool_opt(options, "no_end", default=False) | 504 val = pygments.util.get_bool_opt(options, "no_end", default=False) |
| 500 self.no_end = val | 505 self.no_end = val |
| 506 self.symbol_gets = options.get("gets", "←") | |
| 501 LexBase.__init__(self, **options) | 507 LexBase.__init__(self, **options) |
| 502 | 508 |
| 503 | 509 |
| 504 class AlgPseudocodeLexer_DE(AlgPseudocodeLexer): | 510 class AlgPseudocodeLexer_DE(AlgPseudocodeLexer): |
| 505 | 511 |
| 544 "IN": "IN", | 550 "IN": "IN", |
| 545 "STEP": "SCHRITTWEITE", | 551 "STEP": "SCHRITTWEITE", |
| 546 # "LOOP": XXX TBD # noqa | 552 # "LOOP": XXX TBD # noqa |
| 547 "REPEAT": "WIEDERHOLE", | 553 "REPEAT": "WIEDERHOLE", |
| 548 "UNTIL": "BIS", | 554 "UNTIL": "BIS", |
| 549 # "RETURN": XXX TBD # noqa | 555 # "RETURN": XXX TBD # noqa |
| 550 "BEGIN": "START", | 556 "BEGIN": "START", |
| 551 "END": "ENDE", | 557 "END": "ENDE", |
| 552 }) | 558 }) |
| 553 END_TRANSLATIONS = AlgPseudocodeLexer.END_TRANSLATIONS.copy() | 559 END_TRANSLATIONS = AlgPseudocodeLexer.END_TRANSLATIONS.copy() |
| 554 END_TRANSLATIONS.update({ | 560 END_TRANSLATIONS.update({ |
