eric6/ThirdParty/Pygments/pygments/lexers/graph.py

changeset 6942
2602857055c5
parent 5713
6762afd9f963
child 7547
21b0534faebc
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2 """
3 pygments.lexers.graph
4 ~~~~~~~~~~~~~~~~~~~~~
5
6 Lexers for graph query languages.
7
8 :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details.
10 """
11
12 import re
13
14 from pygments.lexer import RegexLexer, include, bygroups, using, this
15 from pygments.token import Keyword, Punctuation, Comment, Operator, Name,\
16 String, Number, Whitespace
17
18
19 __all__ = ['CypherLexer']
20
21
22 class CypherLexer(RegexLexer):
23 """
24 For `Cypher Query Language
25 <http://docs.neo4j.org/chunked/milestone/cypher-query-lang.html>`_
26
27 For the Cypher version in Neo4J 2.0
28
29 .. versionadded:: 2.0
30 """
31 name = 'Cypher'
32 aliases = ['cypher']
33 filenames = ['*.cyp', '*.cypher']
34
35 flags = re.MULTILINE | re.IGNORECASE
36
37 tokens = {
38 'root': [
39 include('comment'),
40 include('keywords'),
41 include('clauses'),
42 include('relations'),
43 include('strings'),
44 include('whitespace'),
45 include('barewords'),
46 ],
47 'comment': [
48 (r'^.*//.*\n', Comment.Single),
49 ],
50 'keywords': [
51 (r'(create|order|match|limit|set|skip|start|return|with|where|'
52 r'delete|foreach|not|by)\b', Keyword),
53 ],
54 'clauses': [
55 # TODO: many missing ones, see http://docs.neo4j.org/refcard/2.0/
56 (r'(all|any|as|asc|create|create\s+unique|delete|'
57 r'desc|distinct|foreach|in|is\s+null|limit|match|none|'
58 r'order\s+by|return|set|skip|single|start|union|where|with)\b',
59 Keyword),
60 ],
61 'relations': [
62 (r'(-\[)(.*?)(\]->)', bygroups(Operator, using(this), Operator)),
63 (r'(<-\[)(.*?)(\]-)', bygroups(Operator, using(this), Operator)),
64 (r'(-\[)(.*?)(\]-)', bygroups(Operator, using(this), Operator)),
65 (r'-->|<--|\[|\]', Operator),
66 (r'<|>|<>|=|<=|=>|\(|\)|\||:|,|;', Punctuation),
67 (r'[.*{}]', Punctuation),
68 ],
69 'strings': [
70 (r'"(?:\\[tbnrf\'"\\]|[^\\"])*"', String),
71 (r'`(?:``|[^`])+`', Name.Variable),
72 ],
73 'whitespace': [
74 (r'\s+', Whitespace),
75 ],
76 'barewords': [
77 (r'[a-z]\w*', Name),
78 (r'\d+', Number),
79 ],
80 }

eric ide

mercurial