1 /*! `xquery` grammar compiled for Highlight.js 11.11.1 */
3 var hljsGrammar
= (function () {
8 Author: Dirk Kirsten <dk@basex.org>
9 Contributor: Duncan Paterson
10 Description: Supports XQuery 3.1 including XQuery Update 3, so also XPath (as it is a superset)
11 Refactored to process xml constructor syntax and function-bodies. Added missing data-types, xpath operands, inbuilt functions, and query prologs
12 Website: https://www.w3.org/XML/Query/
17 /** @type LanguageFn */
18 function xquery(_hljs
) {
19 // see https://www.w3.org/TR/xquery/#id-terminal-delimitation
118 // Node Types (sorted by inheritance)
119 // atomic types (sorted by inheritance)
130 "processing-instruction",
155 "xs:normalizedString",
165 "xs:nonPositiveInteger",
166 "xs:negativeInteger",
171 "xs:nonNegativeInteger",
176 "xs:positiveInteger",
177 "xs:yearMonthDuration",
192 "descendant-or-self::",
195 "following-sibling::",
198 "ancestor-or-self::",
200 "preceding-sibling::",
204 // functions (TODO: find regex for op: without breaking build)
206 className: 'built_in',
210 end: /(?:append|filter|flatten|fold-(?:left|right)|for-each(?:-pair)?|get|head|insert-before|join|put|remove|reverse|size|sort|subarray|tail)\b/
214 end: /(?:contains|entry|find|for-each|get|keys|merge|put|remove|size)\b/
218 end: /(?:a(?:cos|sin|tan[2]?)|cos|exp(?:10)?|log(?:10)?|pi|pow|sin|sqrt|tan)\b/
230 // do not highlight inbuilt strings as variable or xml element names
231 { 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/ },
239 end: /(?:zip-file|(?:xml|html|text|binary)-entry| (?:update-)?entries)\b/
242 begin: /\b(?:util|db|functx|app|xdmp|xmldb):/,
251 begin: /\bxquery version "[13]\.[01]"\s?(?:encoding ".+")?/,
256 className: 'variable
',
262 begin: /(\b0[0-7_]+)|(\b0x[0-9a-fA-F_]+)|(\b[1-9][0-9_]*(\.[0-9_]+)?)|[0_]\b/,
298 className: 'comment
',
310 // see https://www.w3.org/TR/xquery/#id-computedConstructors
311 // mocha: computed_inbuilt
312 // see https://www.regexpal.com/?fam=99749
314 beginKeywords: 'element attribute comment document processing
-instruction
',
319 // mocha: direct_method
321 begin: /<([\w._:-]+)(\s+\S*=('|").*('|"))?>/,
322 end: /(\/[\w._:-]+>)/,
328 subLanguage: 'xquery'
353 case_insensitive: false,
354 illegal: /(proc)|(abstract)|(extends)|(until)|(#)/,
356 $pattern: /[a-zA-Z$][a-zA-Z0-9_:-]*/,
369 hljs
.registerLanguage('xquery', hljsGrammar
);