-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f55052
commit 398e294
Showing
16 changed files
with
560 additions
and
1 deletion.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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': /[()[\]{},;.]/ | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
true TRUE | ||
false FALSE | ||
null | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["boolean", "true"], | ||
["boolean", "TRUE"], | ||
["boolean", "false"], | ||
["boolean", "FALSE"], | ||
["boolean", "null"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for booleans and null. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//comment | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["comment", "//comment"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for comments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
foo() | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["function", "foo"], | ||
["punctuation", "("], | ||
["punctuation", ")"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for function names. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
Oops, something went wrong.