1 /*! `xquery` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar
= (function () {
7 Author: Dirk Kirsten <dk@basex.org>
8 Contributor: Duncan Paterson
9 Description: Supports XQuery 3.1 including XQuery Update 3, so also XPath (as it is a superset)
10 Refactored to process xml constructor syntax and function-bodies. Added missing data-types, xpath operands, inbuilt functions, and query prologs
11 Website: https://www.w3.org/XML/Query/
16 /** @type LanguageFn */
17 function xquery(_hljs
) {
18 // see https://www.w3.org/TR/xquery/#id-terminal-delimitation
117 // Node Types (sorted by inheritance)
118 // atomic types (sorted by inheritance)
129 "processing-instruction",
154 "xs:normalizedString",
164 "xs:nonPositiveInteger",
165 "xs:negativeInteger",
170 "xs:nonNegativeInteger",
175 "xs:positiveInteger",
176 "xs:yearMonthDuration",
191 "descendant-or-self::",
194 "following-sibling::",
197 "ancestor-or-self::",
199 "preceding-sibling::",
203 // functions (TODO: find regex for op: without breaking build)
205 className: 'built_in',
209 end: /(?:append|filter|flatten|fold-(?:left|right)|for-each(?:-pair)?|get|head|insert-before|join|put|remove|reverse|size|sort|subarray|tail)\b/
213 end: /(?:contains|entry|find|for-each|get|keys|merge|put|remove|size)\b/
217 end: /(?:a(?:cos|sin|tan[2]?)|cos|exp(?:10)?|log(?:10)?|pi|pow|sin|sqrt|tan)\b/
229 // do not highlight inbuilt strings as variable or xml element names
230 { begin: /[^</$:'"-]\b(?:abs|accumulator-(?:after|before)|adjust-(?:date(?:Time)?|time)-to-timezone|analyze-string|apply|available-(?:environment-variables|system-properties)|avg|base-uri|boolean|ceiling|codepoints?-(?:equal|to-string)|collation-key|collection|compare|concat|contains(?:-token)?|copy-of|count|current(?:-)?(?:date(?:Time)?|time|group(?:ing-key)?|output-uri|merge-(?:group|key))?data|dateTime|days?-from-(?:date(?:Time)?|duration)|deep-equal|default-(?:collation|language)|distinct-values|document(?:-uri)?|doc(?:-available)?|element-(?:available|with-id)|empty|encode-for-uri|ends-with|environment-variable|error|escape-html-uri|exactly-one|exists|false|filter|floor|fold-(?:left|right)|for-each(?:-pair)?|format-(?:date(?:Time)?|time|integer|number)|function-(?:arity|available|lookup|name)|generate-id|has-children|head|hours-from-(?:dateTime|duration|time)|id(?:ref)?|implicit-timezone|in-scope-prefixes|index-of|innermost|insert-before|iri-to-uri|json-(?:doc|to-xml)|key|lang|last|load-xquery-module|local-name(?:-from-QName)?|(?:lower|upper)-case|matches|max|minutes-from-(?:dateTime|duration|time)|min|months?-from-(?:date(?:Time)?|duration)|name(?:space-uri-?(?:for-prefix|from-QName)?)?|nilled|node-name|normalize-(?:space|unicode)|not|number|one-or-more|outermost|parse-(?:ietf-date|json)|path|position|(?:prefix-from-)?QName|random-number-generator|regex-group|remove|replace|resolve-(?:QName|uri)|reverse|root|round(?:-half-to-even)?|seconds-from-(?:dateTime|duration|time)|snapshot|sort|starts-with|static-base-uri|stream-available|string-?(?:join|length|to-codepoints)?|subsequence|substring-?(?:after|before)?|sum|system-property|tail|timezone-from-(?:date(?:Time)?|time)|tokenize|trace|trans(?:form|late)|true|type-available|unordered|unparsed-(?:entity|text)?-?(?:public-id|uri|available|lines)?|uri-collection|xml-to-json|years?-from-(?:date(?:Time)?|duration)|zero-or-one)\b/ },
238 end: /(?:zip-file|(?:xml|html|text|binary)-entry| (?:update-)?entries)\b/
241 begin: /\b(?:util|db|functx|app|xdmp|xmldb):/,
250 begin: /\bxquery version "[13]\.[01]"\s?(?:encoding ".+")?/,
255 className: 'variable
',
261 begin: /(\b0[0-7_]+)|(\b0x[0-9a-fA-F_]+)|(\b[1-9][0-9_]*(\.[0-9_]+)?)|[0_]\b/,
297 className: 'comment
',
309 // see https://www.w3.org/TR/xquery/#id-computedConstructors
310 // mocha: computed_inbuilt
311 // see https://www.regexpal.com/?fam=99749
313 beginKeywords: 'element attribute comment document processing
-instruction
',
318 // mocha: direct_method
320 begin: /<([\w._:-]+)(\s+\S*=('|").*('|"))?>/,
321 end: /(\/[\w._:-]+>)/,
327 subLanguage: 'xquery'
352 case_insensitive: false,
353 illegal: /(proc)|(abstract)|(extends)|(until)|(#)/,
355 $pattern: /[a-zA-Z$][a-zA-Z0-9_:-]*/,
368 export default hljsGrammar
;