Added support for Cypher (#2459)
This commit is contained in:
parent
4f55052f6a
commit
398e2943a9
File diff suppressed because one or more lines are too long
|
@ -257,6 +257,10 @@
|
|||
"modify": "css",
|
||||
"owner": "milesj"
|
||||
},
|
||||
"cypher": {
|
||||
"title": "Cypher",
|
||||
"owner": "RunDevelopment"
|
||||
},
|
||||
"d": {
|
||||
"title": "D",
|
||||
"require": "clike",
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
Prism.languages.cypher = {
|
||||
// https://neo4j.com/docs/cypher-manual/current/syntax/comments/
|
||||
'comment': /\/\/.*/,
|
||||
'string': {
|
||||
pattern: /"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/,
|
||||
greedy: true
|
||||
},
|
||||
'class-name': {
|
||||
pattern: /(:\s*)(?:\w+|`(?:[^`\\\r\n])*`)(?=\s*[{):])/,
|
||||
lookbehind: true,
|
||||
greedy: true
|
||||
},
|
||||
'relationship': {
|
||||
pattern: /(-\[\s*(?:\w+\s*|`(?:[^`\\\r\n])*`\s*)?:\s*|\|\s*:\s*)(?:\w+|`(?:[^`\\\r\n])*`)/,
|
||||
lookbehind: true,
|
||||
greedy: true,
|
||||
alias: 'property'
|
||||
},
|
||||
'identifier': {
|
||||
pattern: /`(?:[^`\\\r\n])*`/,
|
||||
greedy: true,
|
||||
alias: 'symbol'
|
||||
},
|
||||
|
||||
'variable': /\$\w+/,
|
||||
|
||||
// https://neo4j.com/docs/cypher-manual/current/syntax/reserved/
|
||||
'keyword': /\b(?:ADD|ALL|AND|AS|ASC|ASCENDING|ASSERT|BY|CALL|CASE|COMMIT|CONSTRAINT|CONTAINS|CREATE|CSV|DELETE|DESC|DESCENDING|DETACH|DISTINCT|DO|DROP|ELSE|END|ENDS|EXISTS|FOR|FOREACH|IN|INDEX|IS|JOIN|KEY|LIMIT|LOAD|MANDATORY|MATCH|MERGE|NODE|NOT|OF|ON|OPTIONAL|OR|ORDER(?=\s+BY)|PERIODIC|REMOVE|REQUIRE|RETURN|SCALAR|SCAN|SET|SKIP|START|STARTS|THEN|UNION|UNIQUE|UNWIND|USING|WHEN|WHERE|WITH|XOR|YIELD)\b/i,
|
||||
|
||||
'function': /\b\w+\b(?=\s*\()/,
|
||||
|
||||
'boolean': /\b(?:true|false|null)\b/i,
|
||||
'number': /\b(?:0x[\da-fA-F]+|\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\b/,
|
||||
// https://neo4j.com/docs/cypher-manual/current/syntax/operators/
|
||||
'operator': /:|<--?|--?>?|<>|=~?|[<>]=?|[+*/%^|]|\.\.\.?/,
|
||||
'punctuation': /[()[\]{},;.]/
|
||||
};
|
|
@ -0,0 +1 @@
|
|||
Prism.languages.cypher={comment:/\/\/.*/,string:{pattern:/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/,greedy:!0},"class-name":{pattern:/(:\s*)(?:\w+|`(?:[^`\\\r\n])*`)(?=\s*[{):])/,lookbehind:!0,greedy:!0},relationship:{pattern:/(-\[\s*(?:\w+\s*|`(?:[^`\\\r\n])*`\s*)?:\s*|\|\s*:\s*)(?:\w+|`(?:[^`\\\r\n])*`)/,lookbehind:!0,greedy:!0,alias:"property"},identifier:{pattern:/`(?:[^`\\\r\n])*`/,greedy:!0,alias:"symbol"},variable:/\$\w+/,keyword:/\b(?:ADD|ALL|AND|AS|ASC|ASCENDING|ASSERT|BY|CALL|CASE|COMMIT|CONSTRAINT|CONTAINS|CREATE|CSV|DELETE|DESC|DESCENDING|DETACH|DISTINCT|DO|DROP|ELSE|END|ENDS|EXISTS|FOR|FOREACH|IN|INDEX|IS|JOIN|KEY|LIMIT|LOAD|MANDATORY|MATCH|MERGE|NODE|NOT|OF|ON|OPTIONAL|OR|ORDER(?=\s+BY)|PERIODIC|REMOVE|REQUIRE|RETURN|SCALAR|SCAN|SET|SKIP|START|STARTS|THEN|UNION|UNIQUE|UNWIND|USING|WHEN|WHERE|WITH|XOR|YIELD)\b/i,function:/\b\w+\b(?=\s*\()/,boolean:/\b(?:true|false|null)\b/i,number:/\b(?:0x[\da-fA-F]+|\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\b/,operator:/:|<--?|--?>?|<>|=~?|[<>]=?|[+*/%^|]|\.\.\.?/,punctuation:/[()[\]{},;.]/};
|
|
@ -0,0 +1,8 @@
|
|||
<h2>Full example</h2>
|
||||
<pre><code>MATCH (person:Person)-[:WORKS_FOR]->(company)
|
||||
WHERE company.name STARTS WITH "Company"
|
||||
AND EXISTS {
|
||||
MATCH (person)-[:LIKES]->(t:Technology)
|
||||
WHERE size((t)<-[:LIKES]-()) >= 3
|
||||
}
|
||||
RETURN person.name as person, company.name AS company;</code></pre>
|
|
@ -0,0 +1,17 @@
|
|||
true TRUE
|
||||
false FALSE
|
||||
null
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["boolean", "true"],
|
||||
["boolean", "TRUE"],
|
||||
["boolean", "false"],
|
||||
["boolean", "FALSE"],
|
||||
["boolean", "null"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for booleans and null.
|
|
@ -0,0 +1,114 @@
|
|||
(p:Student)
|
||||
(p:Student { name: "John" })
|
||||
(:`Student`)
|
||||
(:`Student` { name: "John"})
|
||||
|
||||
(p:Student:Teacher)
|
||||
(p:Student { name: "John" }:Teacher)
|
||||
(:`Student`:`Teacher`)
|
||||
(:`Student` { name: "John"}:`Teacher` { classes: "..." })
|
||||
|
||||
// no class names but still interesting cases
|
||||
|
||||
(p { name: "John" })
|
||||
({ name: "John" })
|
||||
()
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["punctuation", "("],
|
||||
"p",
|
||||
["operator", ":"],
|
||||
["class-name", "Student"],
|
||||
["punctuation", ")"],
|
||||
["punctuation", "("],
|
||||
"p",
|
||||
["operator", ":"],
|
||||
["class-name", "Student"],
|
||||
["punctuation", "{"],
|
||||
" name",
|
||||
["operator", ":"],
|
||||
["string", "\"John\""],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ")"],
|
||||
["punctuation", "("],
|
||||
["operator", ":"],
|
||||
["class-name", "`Student`"],
|
||||
["punctuation", ")"],
|
||||
["punctuation", "("],
|
||||
["operator", ":"],
|
||||
["class-name", "`Student`"],
|
||||
["punctuation", "{"],
|
||||
" name",
|
||||
["operator", ":"],
|
||||
["string", "\"John\""],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ")"],
|
||||
|
||||
["punctuation", "("],
|
||||
"p",
|
||||
["operator", ":"],
|
||||
["class-name", "Student"],
|
||||
["operator", ":"],
|
||||
["class-name", "Teacher"],
|
||||
["punctuation", ")"],
|
||||
["punctuation", "("],
|
||||
"p",
|
||||
["operator", ":"],
|
||||
["class-name", "Student"],
|
||||
["punctuation", "{"],
|
||||
" name",
|
||||
["operator", ":"],
|
||||
["string", "\"John\""],
|
||||
["punctuation", "}"],
|
||||
["operator", ":"],
|
||||
["class-name", "Teacher"],
|
||||
["punctuation", ")"],
|
||||
["punctuation", "("],
|
||||
["operator", ":"],
|
||||
["class-name", "`Student`"],
|
||||
["operator", ":"],
|
||||
["class-name", "`Teacher`"],
|
||||
["punctuation", ")"],
|
||||
["punctuation", "("],
|
||||
["operator", ":"],
|
||||
["class-name", "`Student`"],
|
||||
["punctuation", "{"],
|
||||
" name",
|
||||
["operator", ":"],
|
||||
["string", "\"John\""],
|
||||
["punctuation", "}"],
|
||||
["operator", ":"],
|
||||
["class-name", "`Teacher`"],
|
||||
["punctuation", "{"],
|
||||
" classes",
|
||||
["operator", ":"],
|
||||
["string", "\"...\""],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ")"],
|
||||
|
||||
["comment", "// no class names but still interesting cases"],
|
||||
|
||||
["punctuation", "("],
|
||||
"p ",
|
||||
["punctuation", "{"],
|
||||
" name",
|
||||
["operator", ":"],
|
||||
["string", "\"John\""],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ")"],
|
||||
["punctuation", "("],
|
||||
["punctuation", "{"],
|
||||
" name",
|
||||
["operator", ":"],
|
||||
["string", "\"John\""],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ")"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for class names.
|
|
@ -0,0 +1,11 @@
|
|||
//comment
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["comment", "//comment"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for comments.
|
|
@ -0,0 +1,13 @@
|
|||
foo()
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["function", "foo"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for function names.
|
|
@ -0,0 +1,138 @@
|
|||
ADD
|
||||
ALL
|
||||
AND
|
||||
AS
|
||||
ASC
|
||||
ASCENDING
|
||||
ASSERT
|
||||
CALL
|
||||
CASE
|
||||
COMMIT
|
||||
CONSTRAINT
|
||||
CONTAINS
|
||||
CREATE
|
||||
CSV
|
||||
DELETE
|
||||
DESC
|
||||
DESCENDING
|
||||
DETACH
|
||||
DISTINCT
|
||||
DO
|
||||
DROP
|
||||
ELSE
|
||||
END
|
||||
ENDS
|
||||
EXISTS
|
||||
FOR
|
||||
FOREACH
|
||||
IN
|
||||
INDEX
|
||||
IS
|
||||
JOIN
|
||||
KEY
|
||||
LIMIT
|
||||
LOAD
|
||||
MANDATORY
|
||||
MATCH
|
||||
MERGE
|
||||
NODE
|
||||
NOT
|
||||
OF
|
||||
ON
|
||||
OPTIONAL
|
||||
OR
|
||||
ORDER BY
|
||||
PERIODIC
|
||||
REMOVE
|
||||
REQUIRE
|
||||
RETURN
|
||||
SCALAR
|
||||
SCAN
|
||||
SET
|
||||
SKIP
|
||||
START
|
||||
STARTS
|
||||
THEN
|
||||
UNION
|
||||
UNIQUE
|
||||
UNWIND
|
||||
USING
|
||||
WHEN
|
||||
WHERE
|
||||
WITH
|
||||
XOR
|
||||
YIELD
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["keyword", "ADD"],
|
||||
["keyword", "ALL"],
|
||||
["keyword", "AND"],
|
||||
["keyword", "AS"],
|
||||
["keyword", "ASC"],
|
||||
["keyword", "ASCENDING"],
|
||||
["keyword", "ASSERT"],
|
||||
["keyword", "CALL"],
|
||||
["keyword", "CASE"],
|
||||
["keyword", "COMMIT"],
|
||||
["keyword", "CONSTRAINT"],
|
||||
["keyword", "CONTAINS"],
|
||||
["keyword", "CREATE"],
|
||||
["keyword", "CSV"],
|
||||
["keyword", "DELETE"],
|
||||
["keyword", "DESC"],
|
||||
["keyword", "DESCENDING"],
|
||||
["keyword", "DETACH"],
|
||||
["keyword", "DISTINCT"],
|
||||
["keyword", "DO"],
|
||||
["keyword", "DROP"],
|
||||
["keyword", "ELSE"],
|
||||
["keyword", "END"],
|
||||
["keyword", "ENDS"],
|
||||
["keyword", "EXISTS"],
|
||||
["keyword", "FOR"],
|
||||
["keyword", "FOREACH"],
|
||||
["keyword", "IN"],
|
||||
["keyword", "INDEX"],
|
||||
["keyword", "IS"],
|
||||
["keyword", "JOIN"],
|
||||
["keyword", "KEY"],
|
||||
["keyword", "LIMIT"],
|
||||
["keyword", "LOAD"],
|
||||
["keyword", "MANDATORY"],
|
||||
["keyword", "MATCH"],
|
||||
["keyword", "MERGE"],
|
||||
["keyword", "NODE"],
|
||||
["keyword", "NOT"],
|
||||
["keyword", "OF"],
|
||||
["keyword", "ON"],
|
||||
["keyword", "OPTIONAL"],
|
||||
["keyword", "OR"],
|
||||
["keyword", "ORDER"],
|
||||
["keyword", "BY"],
|
||||
["keyword", "PERIODIC"],
|
||||
["keyword", "REMOVE"],
|
||||
["keyword", "REQUIRE"],
|
||||
["keyword", "RETURN"],
|
||||
["keyword", "SCALAR"],
|
||||
["keyword", "SCAN"],
|
||||
["keyword", "SET"],
|
||||
["keyword", "SKIP"],
|
||||
["keyword", "START"],
|
||||
["keyword", "STARTS"],
|
||||
["keyword", "THEN"],
|
||||
["keyword", "UNION"],
|
||||
["keyword", "UNIQUE"],
|
||||
["keyword", "UNWIND"],
|
||||
["keyword", "USING"],
|
||||
["keyword", "WHEN"],
|
||||
["keyword", "WHERE"],
|
||||
["keyword", "WITH"],
|
||||
["keyword", "XOR"],
|
||||
["keyword", "YIELD"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for keywords.
|
|
@ -0,0 +1,35 @@
|
|||
123
|
||||
123E45
|
||||
|
||||
3.14
|
||||
6.022E23
|
||||
|
||||
0x13af
|
||||
0xFC3A9
|
||||
0x66eff
|
||||
|
||||
01372
|
||||
02127
|
||||
05671
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["number", "123"],
|
||||
["number", "123E45"],
|
||||
|
||||
["number", "3.14"],
|
||||
["number", "6.022E23"],
|
||||
|
||||
["number", "0x13af"],
|
||||
["number", "0xFC3A9"],
|
||||
["number", "0x66eff"],
|
||||
|
||||
["number", "01372"],
|
||||
["number", "02127"],
|
||||
["number", "05671"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for numbers.
|
|
@ -0,0 +1,49 @@
|
|||
+ - * / % ^
|
||||
|
||||
= <> > >= < <=
|
||||
|
||||
=~ | : ..
|
||||
|
||||
- ->
|
||||
<- -
|
||||
- -
|
||||
--
|
||||
<--
|
||||
-->
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["operator", "+"],
|
||||
["operator", "-"],
|
||||
["operator", "*"],
|
||||
["operator", "/"],
|
||||
["operator", "%"],
|
||||
["operator", "^"],
|
||||
|
||||
["operator", "="],
|
||||
["operator", "<>"],
|
||||
["operator", ">"],
|
||||
["operator", ">="],
|
||||
["operator", "<"],
|
||||
["operator", "<="],
|
||||
|
||||
["operator", "=~"],
|
||||
["operator", "|"],
|
||||
["operator", ":"],
|
||||
["operator", ".."],
|
||||
|
||||
["operator", "-"],
|
||||
["operator", "->"],
|
||||
["operator", "<-"],
|
||||
["operator", "-"],
|
||||
["operator", "-"],
|
||||
["operator", "-"],
|
||||
["operator", "--"],
|
||||
["operator", "<--"],
|
||||
["operator", "-->"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for operators.
|
|
@ -0,0 +1,19 @@
|
|||
( ) [ ] { } ; , .
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["punctuation", "["],
|
||||
["punctuation", "]"],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ";"],
|
||||
["punctuation", ","],
|
||||
["punctuation", "."]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for punctuation.
|
|
@ -0,0 +1,79 @@
|
|||
-[r:REL_TYPE]->
|
||||
|
||||
-[:REL_TYPE]->
|
||||
|
||||
<-[:LIKES]-
|
||||
|
||||
-[{blocked: false}]->
|
||||
|
||||
-[:KNOWS*1..2]-
|
||||
|
||||
-[*]->
|
||||
|
||||
-[*3..5]->
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["operator", "-"],
|
||||
["punctuation", "["],
|
||||
"r",
|
||||
["operator", ":"],
|
||||
["relationship", "REL_TYPE"],
|
||||
["punctuation", "]"],
|
||||
["operator", "->"],
|
||||
|
||||
["operator", "-"],
|
||||
["punctuation", "["],
|
||||
["operator", ":"],
|
||||
["relationship", "REL_TYPE"],
|
||||
["punctuation", "]"],
|
||||
["operator", "->"],
|
||||
|
||||
["operator", "<-"],
|
||||
["punctuation", "["],
|
||||
["operator", ":"],
|
||||
["relationship", "LIKES"],
|
||||
["punctuation", "]"],
|
||||
["operator", "-"],
|
||||
|
||||
["operator", "-"],
|
||||
["punctuation", "["],
|
||||
["punctuation", "{"],
|
||||
"blocked",
|
||||
["operator", ":"],
|
||||
["boolean", "false"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", "]"],
|
||||
["operator", "->"],
|
||||
|
||||
["operator", "-"],
|
||||
["punctuation", "["],
|
||||
["operator", ":"],
|
||||
["relationship", "KNOWS"],
|
||||
["operator", "*"],
|
||||
["number", "1"],
|
||||
["operator", ".."],
|
||||
["number", "2"],
|
||||
["punctuation", "]"],
|
||||
["operator", "-"],
|
||||
|
||||
["operator", "-"],
|
||||
["punctuation", "["],
|
||||
["operator", "*"],
|
||||
["punctuation", "]"],
|
||||
["operator", "->"],
|
||||
|
||||
["operator", "-"],
|
||||
["punctuation", "["],
|
||||
["operator", "*"],
|
||||
["number", "3"],
|
||||
["operator", ".."],
|
||||
["number", "5"],
|
||||
["punctuation", "]"],
|
||||
["operator", "->"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for relationships.
|
|
@ -0,0 +1,19 @@
|
|||
""
|
||||
"foo"
|
||||
''
|
||||
'foo'
|
||||
"\foo//'\bar"
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["string", "\"\""],
|
||||
["string", "\"foo\""],
|
||||
["string", "''"],
|
||||
["string", "'foo'"],
|
||||
["string", "\"\\foo//'\\bar\""]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for strings.
|
|
@ -0,0 +1,15 @@
|
|||
$name
|
||||
a.$name
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["variable", "$name"],
|
||||
"\na",
|
||||
["punctuation", "."],
|
||||
["variable", "$name"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for variables.
|
Loading…
Reference in New Issue