diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
commit | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch) | |
tree | 012bb94d777798f1f56ac1cec429509766d05181 /contrib/python/Pygments/py3/pygments/lexers/grammar_notation.py | |
parent | 6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff) | |
download | ydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/python/Pygments/py3/pygments/lexers/grammar_notation.py')
-rw-r--r-- | contrib/python/Pygments/py3/pygments/lexers/grammar_notation.py | 120 |
1 files changed, 60 insertions, 60 deletions
diff --git a/contrib/python/Pygments/py3/pygments/lexers/grammar_notation.py b/contrib/python/Pygments/py3/pygments/lexers/grammar_notation.py index ff57c99917..f62898d7c4 100644 --- a/contrib/python/Pygments/py3/pygments/lexers/grammar_notation.py +++ b/contrib/python/Pygments/py3/pygments/lexers/grammar_notation.py @@ -2,9 +2,9 @@ pygments.lexers.grammar_notation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Lexers for grammar notations like BNF. + Lexers for grammar notations like BNF. - :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS. + :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ @@ -14,12 +14,12 @@ from pygments.lexer import RegexLexer, bygroups, include, this, using, words from pygments.token import Comment, Keyword, Literal, Name, Number, \ Operator, Punctuation, String, Text, Whitespace -__all__ = ['BnfLexer', 'AbnfLexer', 'JsgfLexer', 'PegLexer'] +__all__ = ['BnfLexer', 'AbnfLexer', 'JsgfLexer', 'PegLexer'] class BnfLexer(RegexLexer): """ - This lexer is for grammar notations which are similar to + This lexer is for grammar notations which are similar to original BNF. In order to maximize a number of targets of this lexer, @@ -210,60 +210,60 @@ class JsgfLexer(RegexLexer): (r'.', Comment.Multiline), ], } - - -class PegLexer(RegexLexer): - """ - This lexer is for `Parsing Expression Grammars - <https://bford.info/pub/lang/peg.pdf>`_ (PEG). - - Various implementations of PEG have made different decisions - regarding the syntax, so let's try to be accommodating: - - * `<-`, `←`, `:`, and `=` are all accepted as rule operators. - - * Both `|` and `/` are choice operators. - - * `^`, `↑`, and `~` are cut operators. - - * A single `a-z` character immediately before a string, or - multiple `a-z` characters following a string, are part of the - string (e.g., `r"..."` or `"..."ilmsuxa`). - - .. versionadded:: 2.6 - """ - - name = 'PEG' - aliases = ['peg'] - filenames = ['*.peg'] - mimetypes = ['text/x-peg'] - - tokens = { - 'root': [ - # Comments + + +class PegLexer(RegexLexer): + """ + This lexer is for `Parsing Expression Grammars + <https://bford.info/pub/lang/peg.pdf>`_ (PEG). + + Various implementations of PEG have made different decisions + regarding the syntax, so let's try to be accommodating: + + * `<-`, `←`, `:`, and `=` are all accepted as rule operators. + + * Both `|` and `/` are choice operators. + + * `^`, `↑`, and `~` are cut operators. + + * A single `a-z` character immediately before a string, or + multiple `a-z` characters following a string, are part of the + string (e.g., `r"..."` or `"..."ilmsuxa`). + + .. versionadded:: 2.6 + """ + + name = 'PEG' + aliases = ['peg'] + filenames = ['*.peg'] + mimetypes = ['text/x-peg'] + + tokens = { + 'root': [ + # Comments (r'#.*$', Comment.Single), - - # All operators - (r'<-|[←:=/|&!?*+^↑~]', Operator), - - # Other punctuation - (r'[()]', Punctuation), - - # Keywords - (r'\.', Keyword), - - # Character classes - (r'(\[)([^\]]*(?:\\.[^\]\\]*)*)(\])', - bygroups(Punctuation, String, Punctuation)), - - # Single and double quoted strings (with optional modifiers) - (r'[a-z]?"[^"\\]*(?:\\.[^"\\]*)*"[a-z]*', String.Double), - (r"[a-z]?'[^'\\]*(?:\\.[^'\\]*)*'[a-z]*", String.Single), - - # Nonterminals are not whitespace, operators, or punctuation - (r'[^\s<←:=/|&!?*+\^↑~()\[\]"\'#]+', Name.Class), - - # Fallback - (r'.', Text), - ], - } + + # All operators + (r'<-|[←:=/|&!?*+^↑~]', Operator), + + # Other punctuation + (r'[()]', Punctuation), + + # Keywords + (r'\.', Keyword), + + # Character classes + (r'(\[)([^\]]*(?:\\.[^\]\\]*)*)(\])', + bygroups(Punctuation, String, Punctuation)), + + # Single and double quoted strings (with optional modifiers) + (r'[a-z]?"[^"\\]*(?:\\.[^"\\]*)*"[a-z]*', String.Double), + (r"[a-z]?'[^'\\]*(?:\\.[^'\\]*)*'[a-z]*", String.Single), + + # Nonterminals are not whitespace, operators, or punctuation + (r'[^\s<←:=/|&!?*+\^↑~()\[\]"\'#]+', Name.Class), + + # Fallback + (r'.', Text), + ], + } |