diff options
author | Jean Abou-Samra <jean@abou-samra.fr> | 2022-03-02 06:41:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-02 06:41:47 +0100 |
commit | 4752b7d9af7d47ffc993edb48ebe222bfba919b9 (patch) | |
tree | ea642cda9bf499aa768d4b8486f0fada5e3c942f /doc/docs | |
parent | 8d2e31d1966f42808595bccc3384062c2942fc74 (diff) | |
download | pygments-git-4752b7d9af7d47ffc993edb48ebe222bfba919b9.tar.gz |
Add notes to Contributing.md about common mistakes in lexers (#2075)
Diffstat (limited to 'doc/docs')
-rw-r--r-- | doc/docs/lexerdevelopment.rst | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/doc/docs/lexerdevelopment.rst b/doc/docs/lexerdevelopment.rst index 720a804b..b883d3e6 100644 --- a/doc/docs/lexerdevelopment.rst +++ b/doc/docs/lexerdevelopment.rst @@ -291,7 +291,7 @@ and single-line with ``//`` until end of line):: (r'/', Text) ], 'comment': [ - (r'[^*/]', Comment.Multiline), + (r'[^*/]+', Comment.Multiline), (r'/\*', Comment.Multiline, '#push'), (r'\*/', Comment.Multiline, '#pop'), (r'[*/]', Comment.Multiline) @@ -346,7 +346,7 @@ There are a few more things you can do with states: ... ], 'directive': [ - (r'[^>]*', Comment.Directive), + (r'[^>]+', Comment.Directive), (r'>', Comment, '#pop'), ], 'comment': [ @@ -376,20 +376,20 @@ There are a few more things you can do with states: class ExampleLexer(RegexLexer): tokens = { 'comments': [ - (r'/\*.*?\*/', Comment), + (r'(?s)/\*.*?\*/', Comment), (r'//.*?\n', Comment), ], 'root': [ include('comments'), - (r'(function )(\w+)( {)', - bygroups(Keyword, Name, Keyword), 'function'), - (r'.', Text), + (r'(function)( )(\w+)( )({)', + bygroups(Keyword, Whitespace, Name, Whitespace, Punctuation), 'function'), + (r'.*\n', Text), ], 'function': [ (r'[^}/]+', Text), include('comments'), (r'/', Text), - (r'\}', Keyword, '#pop'), + (r'\}', Punctuation, '#pop'), ] } @@ -455,7 +455,7 @@ defined in the parent and child class are merged. For example:: ('[a-z]+', Name), (r'/\*', Comment, 'comment'), ('"', String, 'string'), - ('\s+', Text), + (r'\s+', Text), ], 'string': [ ('[^"]+', String), |