sparql.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*!-----------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Version: 0.31.1(337587859b1c171314b40503171188b6cea6a32a)
  4. * Released under the MIT license
  5. * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
  6. *-----------------------------------------------------------------------------*/
  7. // src/basic-languages/sparql/sparql.ts
  8. var conf = {
  9. comments: {
  10. lineComment: "#"
  11. },
  12. brackets: [
  13. ["{", "}"],
  14. ["[", "]"],
  15. ["(", ")"]
  16. ],
  17. autoClosingPairs: [
  18. { open: "'", close: "'", notIn: ["string"] },
  19. { open: '"', close: '"', notIn: ["string"] },
  20. { open: "{", close: "}" },
  21. { open: "[", close: "]" },
  22. { open: "(", close: ")" }
  23. ]
  24. };
  25. var language = {
  26. defaultToken: "",
  27. tokenPostfix: ".rq",
  28. brackets: [
  29. { token: "delimiter.curly", open: "{", close: "}" },
  30. { token: "delimiter.parenthesis", open: "(", close: ")" },
  31. { token: "delimiter.square", open: "[", close: "]" },
  32. { token: "delimiter.angle", open: "<", close: ">" }
  33. ],
  34. keywords: [
  35. "add",
  36. "as",
  37. "asc",
  38. "ask",
  39. "base",
  40. "by",
  41. "clear",
  42. "construct",
  43. "copy",
  44. "create",
  45. "data",
  46. "delete",
  47. "desc",
  48. "describe",
  49. "distinct",
  50. "drop",
  51. "false",
  52. "filter",
  53. "from",
  54. "graph",
  55. "group",
  56. "having",
  57. "in",
  58. "insert",
  59. "limit",
  60. "load",
  61. "minus",
  62. "move",
  63. "named",
  64. "not",
  65. "offset",
  66. "optional",
  67. "order",
  68. "prefix",
  69. "reduced",
  70. "select",
  71. "service",
  72. "silent",
  73. "to",
  74. "true",
  75. "undef",
  76. "union",
  77. "using",
  78. "values",
  79. "where",
  80. "with"
  81. ],
  82. builtinFunctions: [
  83. "a",
  84. "abs",
  85. "avg",
  86. "bind",
  87. "bnode",
  88. "bound",
  89. "ceil",
  90. "coalesce",
  91. "concat",
  92. "contains",
  93. "count",
  94. "datatype",
  95. "day",
  96. "encode_for_uri",
  97. "exists",
  98. "floor",
  99. "group_concat",
  100. "hours",
  101. "if",
  102. "iri",
  103. "isblank",
  104. "isiri",
  105. "isliteral",
  106. "isnumeric",
  107. "isuri",
  108. "lang",
  109. "langmatches",
  110. "lcase",
  111. "max",
  112. "md5",
  113. "min",
  114. "minutes",
  115. "month",
  116. "now",
  117. "rand",
  118. "regex",
  119. "replace",
  120. "round",
  121. "sameterm",
  122. "sample",
  123. "seconds",
  124. "sha1",
  125. "sha256",
  126. "sha384",
  127. "sha512",
  128. "str",
  129. "strafter",
  130. "strbefore",
  131. "strdt",
  132. "strends",
  133. "strlang",
  134. "strlen",
  135. "strstarts",
  136. "struuid",
  137. "substr",
  138. "sum",
  139. "timezone",
  140. "tz",
  141. "ucase",
  142. "uri",
  143. "uuid",
  144. "year"
  145. ],
  146. ignoreCase: true,
  147. tokenizer: {
  148. root: [
  149. [/<[^\s\u00a0>]*>?/, "tag"],
  150. { include: "@strings" },
  151. [/#.*/, "comment"],
  152. [/[{}()\[\]]/, "@brackets"],
  153. [/[;,.]/, "delimiter"],
  154. [/[_\w\d]+:(\.(?=[\w_\-\\%])|[:\w_-]|\\[-\\_~.!$&'()*+,;=/?#@%]|%[a-f\d][a-f\d])*/, "tag"],
  155. [/:(\.(?=[\w_\-\\%])|[:\w_-]|\\[-\\_~.!$&'()*+,;=/?#@%]|%[a-f\d][a-f\d])+/, "tag"],
  156. [
  157. /[$?]?[_\w\d]+/,
  158. {
  159. cases: {
  160. "@keywords": { token: "keyword" },
  161. "@builtinFunctions": { token: "predefined.sql" },
  162. "@default": "identifier"
  163. }
  164. }
  165. ],
  166. [/\^\^/, "operator.sql"],
  167. [/\^[*+\-<>=&|^\/!?]*/, "operator.sql"],
  168. [/[*+\-<>=&|\/!?]/, "operator.sql"],
  169. [/@[a-z\d\-]*/, "metatag.html"],
  170. [/\s+/, "white"]
  171. ],
  172. strings: [
  173. [/'([^'\\]|\\.)*$/, "string.invalid"],
  174. [/'$/, "string.sql", "@pop"],
  175. [/'/, "string.sql", "@stringBody"],
  176. [/"([^"\\]|\\.)*$/, "string.invalid"],
  177. [/"$/, "string.sql", "@pop"],
  178. [/"/, "string.sql", "@dblStringBody"]
  179. ],
  180. stringBody: [
  181. [/[^\\']+/, "string.sql"],
  182. [/\\./, "string.escape"],
  183. [/'/, "string.sql", "@pop"]
  184. ],
  185. dblStringBody: [
  186. [/[^\\"]+/, "string.sql"],
  187. [/\\./, "string.escape"],
  188. [/"/, "string.sql", "@pop"]
  189. ]
  190. }
  191. };
  192. export {
  193. conf,
  194. language
  195. };