prism-cypher.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. Prism.languages.cypher = {
  2. // https://neo4j.com/docs/cypher-manual/current/syntax/comments/
  3. 'comment': /\/\/.*/,
  4. 'string': {
  5. pattern: /"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/,
  6. greedy: true
  7. },
  8. 'class-name': {
  9. pattern: /(:\s*)(?:\w+|`(?:[^`\\\r\n])*`)(?=\s*[{):])/,
  10. lookbehind: true,
  11. greedy: true
  12. },
  13. 'relationship': {
  14. pattern: /(-\[\s*(?:\w+\s*|`(?:[^`\\\r\n])*`\s*)?:\s*|\|\s*:\s*)(?:\w+|`(?:[^`\\\r\n])*`)/,
  15. lookbehind: true,
  16. greedy: true,
  17. alias: 'property'
  18. },
  19. 'identifier': {
  20. pattern: /`(?:[^`\\\r\n])*`/,
  21. greedy: true
  22. },
  23. 'variable': /\$\w+/,
  24. // https://neo4j.com/docs/cypher-manual/current/syntax/reserved/
  25. '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,
  26. 'function': /\b\w+\b(?=\s*\()/,
  27. 'boolean': /\b(?:false|null|true)\b/i,
  28. 'number': /\b(?:0x[\da-fA-F]+|\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\b/,
  29. // https://neo4j.com/docs/cypher-manual/current/syntax/operators/
  30. 'operator': /:|<--?|--?>?|<>|=~?|[<>]=?|[+*/%^|]|\.\.\.?/,
  31. 'punctuation': /[()[\]{},;.]/
  32. };