diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
commit | 2d37894b1b037cf24231090eda8589bbb44fb6fc (patch) | |
tree | be835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/python/Pygments/py3/pygments/lexers/grammar_notation.py | |
parent | 718c552901d703c502ccbefdfc3c9028d608b947 (diff) | |
download | ydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 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 | 152 |
1 files changed, 76 insertions, 76 deletions
diff --git a/contrib/python/Pygments/py3/pygments/lexers/grammar_notation.py b/contrib/python/Pygments/py3/pygments/lexers/grammar_notation.py index 5bc93263cd..ff57c99917 100644 --- a/contrib/python/Pygments/py3/pygments/lexers/grammar_notation.py +++ b/contrib/python/Pygments/py3/pygments/lexers/grammar_notation.py @@ -8,15 +8,15 @@ :license: BSD, see LICENSE for details. """ -import re +import re -from pygments.lexer import RegexLexer, bygroups, include, this, using, words -from pygments.token import Comment, Keyword, Literal, Name, Number, \ +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'] - + class BnfLexer(RegexLexer): """ This lexer is for grammar notations which are similar to @@ -130,86 +130,86 @@ class AbnfLexer(RegexLexer): (r'.', Text), ], } - - -class JsgfLexer(RegexLexer): - """ - For `JSpeech Grammar Format <https://www.w3.org/TR/jsgf/>`_ - grammars. - - .. versionadded:: 2.2 - """ - name = 'JSGF' - aliases = ['jsgf'] - filenames = ['*.jsgf'] - mimetypes = ['application/jsgf', 'application/x-jsgf', 'text/jsgf'] - - flags = re.MULTILINE | re.UNICODE - - tokens = { - 'root': [ - include('comments'), - include('non-comments'), - ], - 'comments': [ - (r'/\*\*(?!/)', Comment.Multiline, 'documentation comment'), - (r'/\*[\w\W]*?\*/', Comment.Multiline), + + +class JsgfLexer(RegexLexer): + """ + For `JSpeech Grammar Format <https://www.w3.org/TR/jsgf/>`_ + grammars. + + .. versionadded:: 2.2 + """ + name = 'JSGF' + aliases = ['jsgf'] + filenames = ['*.jsgf'] + mimetypes = ['application/jsgf', 'application/x-jsgf', 'text/jsgf'] + + flags = re.MULTILINE | re.UNICODE + + tokens = { + 'root': [ + include('comments'), + include('non-comments'), + ], + 'comments': [ + (r'/\*\*(?!/)', Comment.Multiline, 'documentation comment'), + (r'/\*[\w\W]*?\*/', Comment.Multiline), (r'//.*$', Comment.Single), - ], - 'non-comments': [ - (r'\A#JSGF[^;]*', Comment.Preproc), + ], + 'non-comments': [ + (r'\A#JSGF[^;]*', Comment.Preproc), (r'\s+', Whitespace), - (r';', Punctuation), - (r'[=|()\[\]*+]', Operator), - (r'/[^/]+/', Number.Float), - (r'"', String.Double, 'string'), - (r'\{', String.Other, 'tag'), - (words(('import', 'public'), suffix=r'\b'), Keyword.Reserved), - (r'grammar\b', Keyword.Reserved, 'grammar name'), - (r'(<)(NULL|VOID)(>)', - bygroups(Punctuation, Name.Builtin, Punctuation)), - (r'<', Punctuation, 'rulename'), - (r'\w+|[^\s;=|()\[\]*+/"{<\w]+', Text), - ], - 'string': [ - (r'"', String.Double, '#pop'), - (r'\\.', String.Escape), - (r'[^\\"]+', String.Double), - ], - 'tag': [ - (r'\}', String.Other, '#pop'), - (r'\\.', String.Escape), - (r'[^\\}]+', String.Other), - ], - 'grammar name': [ - (r';', Punctuation, '#pop'), + (r';', Punctuation), + (r'[=|()\[\]*+]', Operator), + (r'/[^/]+/', Number.Float), + (r'"', String.Double, 'string'), + (r'\{', String.Other, 'tag'), + (words(('import', 'public'), suffix=r'\b'), Keyword.Reserved), + (r'grammar\b', Keyword.Reserved, 'grammar name'), + (r'(<)(NULL|VOID)(>)', + bygroups(Punctuation, Name.Builtin, Punctuation)), + (r'<', Punctuation, 'rulename'), + (r'\w+|[^\s;=|()\[\]*+/"{<\w]+', Text), + ], + 'string': [ + (r'"', String.Double, '#pop'), + (r'\\.', String.Escape), + (r'[^\\"]+', String.Double), + ], + 'tag': [ + (r'\}', String.Other, '#pop'), + (r'\\.', String.Escape), + (r'[^\\}]+', String.Other), + ], + 'grammar name': [ + (r';', Punctuation, '#pop'), (r'\s+', Whitespace), - (r'\.', Punctuation), - (r'[^;\s.]+', Name.Namespace), - ], - 'rulename': [ - (r'>', Punctuation, '#pop'), - (r'\*', Punctuation), + (r'\.', Punctuation), + (r'[^;\s.]+', Name.Namespace), + ], + 'rulename': [ + (r'>', Punctuation, '#pop'), + (r'\*', Punctuation), (r'\s+', Whitespace), - (r'([^.>]+)(\s*)(\.)', bygroups(Name.Namespace, Text, Punctuation)), - (r'[^.>]+', Name.Constant), - ], - 'documentation comment': [ - (r'\*/', Comment.Multiline, '#pop'), + (r'([^.>]+)(\s*)(\.)', bygroups(Name.Namespace, Text, Punctuation)), + (r'[^.>]+', Name.Constant), + ], + 'documentation comment': [ + (r'\*/', Comment.Multiline, '#pop'), (r'^(\s*)(\*?)(\s*)(@(?:example|see))(\s+)' - r'([\w\W]*?(?=(?:^\s*\*?\s*@|\*/)))', + r'([\w\W]*?(?=(?:^\s*\*?\s*@|\*/)))', bygroups(Whitespace,Comment.Multiline, Whitespace, Comment.Special, Whitespace, using(this, state='example'))), - (r'(^\s*\*?\s*)(@\S*)', - bygroups(Comment.Multiline, Comment.Special)), - (r'[^*\n@]+|\w|\W', Comment.Multiline), - ], - 'example': [ + (r'(^\s*\*?\s*)(@\S*)', + bygroups(Comment.Multiline, Comment.Special)), + (r'[^*\n@]+|\w|\W', Comment.Multiline), + ], + 'example': [ (r'(\n\s*)(\*)', bygroups(Whitespace, Comment.Multiline)), - include('non-comments'), - (r'.', Comment.Multiline), - ], - } + include('non-comments'), + (r'.', Comment.Multiline), + ], + } class PegLexer(RegexLexer): |