diff options
author | Sebastian Engel <dev@sebastianengel.eu> | 2021-11-21 18:44:44 +0100 |
---|---|---|
committer | Sebastian Engel <dev@sebastianengel.eu> | 2021-11-21 18:44:44 +0100 |
commit | a6a0da0e079bcc4a9e108d3641f42d78c01b4f48 (patch) | |
tree | 46bdfd7e3b3145102a94165b18e369c7ea2b008b /pygments/lexers/graph.py | |
parent | 76ad35c62c7f9daed519292c90ff7de00000dff4 (diff) | |
download | pygments-git-a6a0da0e079bcc4a9e108d3641f42d78c01b4f48.tar.gz |
Modernize Whitespace token in lexer: graph
Diffstat (limited to 'pygments/lexers/graph.py')
-rw-r--r-- | pygments/lexers/graph.py | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/pygments/lexers/graph.py b/pygments/lexers/graph.py index bd82f761..163cf804 100644 --- a/pygments/lexers/graph.py +++ b/pygments/lexers/graph.py @@ -36,15 +36,15 @@ class CypherLexer(RegexLexer): tokens = { 'root': [ include('comment'), - include('keywords'), include('clauses'), + include('keywords'), include('relations'), include('strings'), include('whitespace'), include('barewords'), ], 'comment': [ - (r'^.*//.*\n', Comment.Single), + (r'^.*//.*$', Comment.Single), ], 'keywords': [ (r'(create|order|match|limit|set|skip|start|return|with|where|' @@ -52,15 +52,35 @@ class CypherLexer(RegexLexer): ], 'clauses': [ # based on https://neo4j.com/docs/cypher-refcard/3.3/ + (r'(create)(\s+)(index|unique)\b', + bygroups(Keyword, Whitespace, Keyword)), + (r'(drop)(\s+)(contraint|index)(\s+)(on)\b', + bygroups(Keyword, Whitespace, Keyword, Whitespace, Keyword)), + (r'(ends)(\s+)(with)\b', + bygroups(Keyword, Whitespace, Keyword)), + (r'(is)(\s+)(node)(\s+)(key)\b', + bygroups(Keyword, Whitespace, Keyword, Whitespace, Keyword)), + (r'(is)(\s+)(null|unique)\b', + bygroups(Keyword, Whitespace, Keyword)), + (r'(load)(\s+)(csv)(\s+)(from)\b', + bygroups(Keyword, Whitespace, Keyword, Whitespace, Keyword)), + (r'(on)(\s+)(match|create)\b', + bygroups(Keyword, Whitespace, Keyword)), + (r'(optional)(\s+)(match)\b', + bygroups(Keyword, Whitespace, Keyword)), + (r'(order)(\s+)(by)\b', + bygroups(Keyword, Whitespace, Keyword)), + (r'(starts)(\s+)(with)\b', + bygroups(Keyword, Whitespace, Keyword)), + (r'(union)(\s+)(all)\b', + bygroups(Keyword, Whitespace, Keyword)), + (r'(using)(\s+)(periodic)(\s+)(commit)\b', + bygroups(Keyword, Whitespace, Keyword, Whitespace, Keyword)), (r'(all|any|as|asc|ascending|assert|call|case|create|' - r'create\s+index|create\s+unique|delete|desc|descending|' - r'distinct|drop\s+constraint\s+on|drop\s+index\s+on|end|' - r'ends\s+with|fieldterminator|foreach|in|is\s+node\s+key|' - r'is\s+null|is\s+unique|limit|load\s+csv\s+from|match|merge|none|' - r'not|null|on\s+match|on\s+create|optional\s+match|order\s+by|' - r'remove|return|set|skip|single|start|starts\s+with|then|union|' - r'union\s+all|unwind|using\s+periodic\s+commit|yield|where|when|' - r'with)\b', Keyword), + r'delete|desc|descending|distinct|end|fieldterminator|' + r'foreach|in|limit|match|merge|none|not|null|' + r'remove|return|set|skip|single|start|then|union|' + r'unwind|yield|where|when|with)\b', Keyword), ], 'relations': [ (r'(-\[)(.*?)(\]->)', bygroups(Operator, using(this), Operator)), |