diff options
author | Tim Hatch <tim@timhatch.com> | 2014-04-24 10:24:21 -0400 |
---|---|---|
committer | Tim Hatch <tim@timhatch.com> | 2014-04-24 10:24:21 -0400 |
commit | a8a8b6565336b78879ede57b47fb889da0d9eaf8 (patch) | |
tree | 9f5b02c9292c9d757bd56fd113832d98c1087ab5 /pygments/lexers/graph.py | |
parent | 9d570b7b00081326289390f12fbd0bf415345c43 (diff) | |
download | pygments-a8a8b6565336b78879ede57b47fb889da0d9eaf8.tar.gz |
Start graph lexers file instead of just cypher
Diffstat (limited to 'pygments/lexers/graph.py')
-rw-r--r-- | pygments/lexers/graph.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/pygments/lexers/graph.py b/pygments/lexers/graph.py new file mode 100644 index 00000000..1abaf6d3 --- /dev/null +++ b/pygments/lexers/graph.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +""" + pygments.lexers.graph + ~~~~~~~~~~~~~~~~~~~~~ + + Lexers for graph query languages. + + :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import re + +from pygments.lexer import RegexLexer, include, bygroups +from pygments.token import Keyword, Punctuation, Text, Comment, Operator, Name,\ +String, Number, Generic + + +__all__ = ['CypherLexer'] + + +class CypherLexer(RegexLexer): + """ + For `Cypher Query Language + <http://docs.neo4j.org/chunked/milestone/cypher-query-lang.html>`_ + + For the Cypher version in Neo4J 2.0 + + .. versionadded:: 2.0 + """ + name = 'Cypher' + aliases = ['cypher'] + filenames = ['*.cyp','*.cypher'] + flags = re.MULTILINE | re.IGNORECASE + + tokens = { + 'root': [ + include('comment'), + include('keywords'), + include('clauses'), + include('relations'), + include('strings') + ], + 'comment': [(r'^.*//.*\n', Comment.Single)], + 'keywords': [ + (r'create|order|match|limit|set|skip|start|return|with|where|delete' + r'|foreach|not| by ', Keyword)], + 'clauses': [(r' all | any | as | asc |create|create unique|delete|' + r'desc |distinct|foreach| in |is null|limit|match|none|' + r'order by|return|set|skip|single|start|union|where|with', + Keyword)], + 'relations': [(r'-->|-\[.*\]->|<-\[.*\]-|<--|\[|\]', Operator), + (r'<|>|<>|=|<=|=>|\(|\)|\||:|,|;', Punctuation)], + 'strings': [(r'\".*\"', String)] + } + + |