sparql.js 6.0 KB

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