cypher.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /*!-----------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Version: 0.38.0(0e330ae453813de4e6cf272460fb79c7117073d0)
  4. * Released under the MIT license
  5. * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
  6. *-----------------------------------------------------------------------------*/
  7. // src/basic-languages/cypher/cypher.ts
  8. var conf = {
  9. comments: {
  10. lineComment: "//",
  11. blockComment: ["/*", "*/"]
  12. },
  13. brackets: [
  14. ["{", "}"],
  15. ["[", "]"],
  16. ["(", ")"]
  17. ],
  18. autoClosingPairs: [
  19. { open: "{", close: "}" },
  20. { open: "[", close: "]" },
  21. { open: "(", close: ")" },
  22. { open: '"', close: '"' },
  23. { open: "'", close: "'" },
  24. { open: "`", close: "`" }
  25. ],
  26. surroundingPairs: [
  27. { open: "{", close: "}" },
  28. { open: "[", close: "]" },
  29. { open: "(", close: ")" },
  30. { open: '"', close: '"' },
  31. { open: "'", close: "'" },
  32. { open: "`", close: "`" }
  33. ]
  34. };
  35. var language = {
  36. defaultToken: "",
  37. tokenPostfix: `.cypher`,
  38. ignoreCase: true,
  39. brackets: [
  40. { open: "{", close: "}", token: "delimiter.curly" },
  41. { open: "[", close: "]", token: "delimiter.bracket" },
  42. { open: "(", close: ")", token: "delimiter.parenthesis" }
  43. ],
  44. keywords: [
  45. "ALL",
  46. "AND",
  47. "AS",
  48. "ASC",
  49. "ASCENDING",
  50. "BY",
  51. "CALL",
  52. "CASE",
  53. "CONTAINS",
  54. "CREATE",
  55. "DELETE",
  56. "DESC",
  57. "DESCENDING",
  58. "DETACH",
  59. "DISTINCT",
  60. "ELSE",
  61. "END",
  62. "ENDS",
  63. "EXISTS",
  64. "IN",
  65. "IS",
  66. "LIMIT",
  67. "MANDATORY",
  68. "MATCH",
  69. "MERGE",
  70. "NOT",
  71. "ON",
  72. "ON",
  73. "OPTIONAL",
  74. "OR",
  75. "ORDER",
  76. "REMOVE",
  77. "RETURN",
  78. "SET",
  79. "SKIP",
  80. "STARTS",
  81. "THEN",
  82. "UNION",
  83. "UNWIND",
  84. "WHEN",
  85. "WHERE",
  86. "WITH",
  87. "XOR",
  88. "YIELD"
  89. ],
  90. builtinLiterals: ["true", "TRUE", "false", "FALSE", "null", "NULL"],
  91. builtinFunctions: [
  92. "abs",
  93. "acos",
  94. "asin",
  95. "atan",
  96. "atan2",
  97. "avg",
  98. "ceil",
  99. "coalesce",
  100. "collect",
  101. "cos",
  102. "cot",
  103. "count",
  104. "degrees",
  105. "e",
  106. "endNode",
  107. "exists",
  108. "exp",
  109. "floor",
  110. "head",
  111. "id",
  112. "keys",
  113. "labels",
  114. "last",
  115. "left",
  116. "length",
  117. "log",
  118. "log10",
  119. "lTrim",
  120. "max",
  121. "min",
  122. "nodes",
  123. "percentileCont",
  124. "percentileDisc",
  125. "pi",
  126. "properties",
  127. "radians",
  128. "rand",
  129. "range",
  130. "relationships",
  131. "replace",
  132. "reverse",
  133. "right",
  134. "round",
  135. "rTrim",
  136. "sign",
  137. "sin",
  138. "size",
  139. "split",
  140. "sqrt",
  141. "startNode",
  142. "stDev",
  143. "stDevP",
  144. "substring",
  145. "sum",
  146. "tail",
  147. "tan",
  148. "timestamp",
  149. "toBoolean",
  150. "toFloat",
  151. "toInteger",
  152. "toLower",
  153. "toString",
  154. "toUpper",
  155. "trim",
  156. "type"
  157. ],
  158. operators: [
  159. "+",
  160. "-",
  161. "*",
  162. "/",
  163. "%",
  164. "^",
  165. "=",
  166. "<>",
  167. "<",
  168. ">",
  169. "<=",
  170. ">=",
  171. "->",
  172. "<-",
  173. "-->",
  174. "<--"
  175. ],
  176. escapes: /\\(?:[tbnrf\\"'`]|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  177. digits: /\d+/,
  178. octaldigits: /[0-7]+/,
  179. hexdigits: /[0-9a-fA-F]+/,
  180. tokenizer: {
  181. root: [[/[{}[\]()]/, "@brackets"], { include: "common" }],
  182. common: [
  183. { include: "@whitespace" },
  184. { include: "@numbers" },
  185. { include: "@strings" },
  186. [/:[a-zA-Z_][\w]*/, "type.identifier"],
  187. [
  188. /[a-zA-Z_][\w]*(?=\()/,
  189. {
  190. cases: {
  191. "@builtinFunctions": "predefined.function"
  192. }
  193. }
  194. ],
  195. [
  196. /[a-zA-Z_$][\w$]*/,
  197. {
  198. cases: {
  199. "@keywords": "keyword",
  200. "@builtinLiterals": "predefined.literal",
  201. "@default": "identifier"
  202. }
  203. }
  204. ],
  205. [/`/, "identifier.escape", "@identifierBacktick"],
  206. [/[;,.:|]/, "delimiter"],
  207. [
  208. /[<>=%+\-*/^]+/,
  209. {
  210. cases: {
  211. "@operators": "delimiter",
  212. "@default": ""
  213. }
  214. }
  215. ]
  216. ],
  217. numbers: [
  218. [/-?(@digits)[eE](-?(@digits))?/, "number.float"],
  219. [/-?(@digits)?\.(@digits)([eE]-?(@digits))?/, "number.float"],
  220. [/-?0x(@hexdigits)/, "number.hex"],
  221. [/-?0(@octaldigits)/, "number.octal"],
  222. [/-?(@digits)/, "number"]
  223. ],
  224. strings: [
  225. [/"([^"\\]|\\.)*$/, "string.invalid"],
  226. [/'([^'\\]|\\.)*$/, "string.invalid"],
  227. [/"/, "string", "@stringDouble"],
  228. [/'/, "string", "@stringSingle"]
  229. ],
  230. whitespace: [
  231. [/[ \t\r\n]+/, "white"],
  232. [/\/\*/, "comment", "@comment"],
  233. [/\/\/.*$/, "comment"]
  234. ],
  235. comment: [
  236. [/\/\/.*/, "comment"],
  237. [/[^/*]+/, "comment"],
  238. [/\*\//, "comment", "@pop"],
  239. [/[/*]/, "comment"]
  240. ],
  241. stringDouble: [
  242. [/[^\\"]+/, "string"],
  243. [/@escapes/, "string"],
  244. [/\\./, "string.invalid"],
  245. [/"/, "string", "@pop"]
  246. ],
  247. stringSingle: [
  248. [/[^\\']+/, "string"],
  249. [/@escapes/, "string"],
  250. [/\\./, "string.invalid"],
  251. [/'/, "string", "@pop"]
  252. ],
  253. identifierBacktick: [
  254. [/[^\\`]+/, "identifier.escape"],
  255. [/@escapes/, "identifier.escape"],
  256. [/\\./, "identifier.escape.invalid"],
  257. [/`/, "identifier.escape", "@pop"]
  258. ]
  259. }
  260. };
  261. export {
  262. conf,
  263. language
  264. };