diff --git a/lib/ace/mode/xquery.js b/lib/ace/mode/xquery.js index e1a7b4f8..dfe81aff 100644 --- a/lib/ace/mode/xquery.js +++ b/lib/ace/mode/xquery.js @@ -125,7 +125,6 @@ oop.inherits(Mode, TextMode); worker.attachToDocument(session.getDocument()); worker.on("start", function(e) { - //console.log("start"); that.$deltas = []; }); @@ -138,51 +137,14 @@ oop.inherits(Mode, TextMode); }); worker.on("highlight", function(tokens) { + if(that.$deltas.length > 0) return; + var firstRow = 0; var lastRow = session.getLength() - 1; var lines = tokens.data.lines; var states = tokens.data.states; - - for(var i=0; i < that.$deltas.length; i++) - { - var delta = that.$deltas[i]; - - if (delta.action === "insertLines") - { - var newLineCount = delta.lines.length; - for (var i = 0; i < newLineCount; i++) { - lines.splice(delta.range.start.row + i, 0, undefined); - states.splice(delta.range.start.row + i, 0, undefined); - } - } - else if (delta.action === "insertText") - { - if (session.getDocument().isNewLine(delta.text)) - { - lines.splice(delta.range.end.row, 0, undefined); - states.splice(delta.range.end.row, 0, undefined); - } else { - lines[delta.range.start.row] = undefined; - states[delta.range.start.row] = undefined; - } - } else if (delta.action === "removeLines") { - var oldLineCount = delta.lines.length; - lines.splice(delta.range.start.row, oldLineCount); - states.splice(delta.range.start.row, oldLineCount); - } else if (delta.action === "removeText") { - if (session.getDocument().isNewLine(delta.text)) - { - lines[delta.range.start.row] = undefined; - lines.splice(delta.range.end.row, 1); - states[delta.range.start.row] = undefined; - states.splice(delta.range.end.row, 1); - } else { - lines[delta.range.start.row] = undefined; - states[delta.range.start.row] = undefined; - } - } - } + session.bgTokenizer.lines = lines; session.bgTokenizer.states = states; session.bgTokenizer.fireUpdateEvent(firstRow, lastRow); diff --git a/lib/ace/mode/xquery/CommentHandler.js b/lib/ace/mode/xquery/CommentHandler.js new file mode 100644 index 00000000..649fedb4 --- /dev/null +++ b/lib/ace/mode/xquery/CommentHandler.js @@ -0,0 +1,129 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Ajax.org B.V. nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module){ + var CommentHandler = exports.CommentHandler = function(code) { + + var ast = null; + var ptr = null; + var remains = code; + var cursor = 0; + var lineCursor = 0; + var line = 0; + var col = 0; + + function createNode(name){ + return { name: name, children: [], getParent: null, pos: { sl: 0, sc: 0, el: 0, ec: 0 } }; + } + + function pushNode(name, begin){ + var node = createNode(name); + if(ast === null) { + ast = node; + ptr = node; + } else { + node.getParent = ptr; + ptr.children.push(node); + ptr = ptr.children[ptr.children.length - 1]; + } + } + + function popNode(name, end){ + + if(ptr.children.length > 0) { + var s = ptr.children[0]; + var e = ptr.children[ptr.children.length - 1]; + ptr.pos.sl = s.pos.sl; + ptr.pos.sc = s.pos.sc; + ptr.pos.el = e.pos.el; + ptr.pos.ec = e.pos.ec; + } + + if(ptr.getParent !== null) { + ptr = ptr.getParent; + for(var i in ptr.children) { + delete ptr.children[i].getParent; + } + } else { + delete ptr.getParent; + } + } + + this.peek = function() { + return ptr; + }; + + this.getParseTree = function() { + return ast; + }; + + this.reset = function(input) {}; + + this.startNonterminal = function(name, begin) { + pushNode(name, begin); + }; + + this.endNonterminal = function(name, end) { + popNode(name, end); + }; + + this.terminal = function(name, begin, end) { + name = (name.substring(0, 1) === "'" && name.substring(name.length - 1) === "'") ? "TOKEN" : name; + pushNode(name, begin); + setValue(ptr, begin, end); + popNode(name, end); + }; + + this.whitespace = function(begin, end) { + var name = "WS"; + pushNode(name, begin); + setValue(ptr, begin, end); + popNode(name, end); + }; + + function setValue(node, begin, end) { + var e = end - cursor; + ptr.value = remains.substring(0, e); + var sl = line; + var sc = line === 0 ? lineCursor : lineCursor - 1; + var el = sl + ptr.value.split("\n").length - 1; + var lastIdx = ptr.value.lastIndexOf("\n"); + var ec = lastIdx === -1 ? sc + ptr.value.length : ptr.value.substring(lastIdx).length; + remains = remains.substring(e); + cursor = end; + lineCursor = lastIdx === -1 ? lineCursor + (ptr.value.length) : ec; + line = el; + ptr.pos.sl = sl; + ptr.pos.sc = sc; + ptr.pos.el = el; + ptr.pos.ec = ec; + } + }; +}); diff --git a/lib/ace/mode/xquery/CommentParser.ebnf b/lib/ace/mode/xquery/CommentParser.ebnf new file mode 100644 index 00000000..310583a3 --- /dev/null +++ b/lib/ace/mode/xquery/CommentParser.ebnf @@ -0,0 +1,55 @@ + + + +Comments ::= (S^WS | Comment)* EOF + +Comment ::= '(:' ( CommentContents | Comment )* ':)' + + +S ::= [#x0009#x000A#x000D#x0020]+ +Char ::= [#x0009#x000A#x000D#x0020-#xD7FF#xE000-#xFFFD#x10000-#x10FFFF] +CommentContents + ::= ( ( Char+ - ( Char* ( '(:' | ':)' ) Char* ) ) - ( Char* '(' ) ) &':' + | ( Char+ - ( Char* ( '(:' | ':)' ) Char* ) ) &'(' + +EOF ::= $ + + + diff --git a/lib/ace/mode/xquery/CommentParser.js b/lib/ace/mode/xquery/CommentParser.js new file mode 100644 index 00000000..9379524c --- /dev/null +++ b/lib/ace/mode/xquery/CommentParser.js @@ -0,0 +1,371 @@ +// This file was generated on Wed Dec 12, 2012 20:06 (UTC+01) by REx v5.20 which is Copyright (c) 1979-2012 by Gunther Rademacher +// REx command line: CommentParser.ebnf -tree -javascript -a xqlint + + // line 2 "CommentParser.ebnf" + /* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Ajax.org B.V. nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ***** END LICENSE BLOCK ***** */ + + define(function(require, exports, module){ + var CommentParser = exports.CommentParser = function CommentParser(string, parsingEventHandler) + { + init(string, parsingEventHandler); + // line 40 "CommentParser.js" + var self = this; + + this.ParseException = function(b, e, s, o, x) + { + var + begin = b, + end = e, + state = s, + offending = o, + expected = x; + + this.getBegin = function() {return begin;}; + this.getEnd = function() {return end;}; + this.getState = function() {return state;}; + this.getExpected = function() {return expected;}; + this.getOffending = function() {return offending;}; + + this.getMessage = function() + { + return offending < 0 ? "lexical analysis failed" : "syntax error"; + }; + }; + + function init(string, parsingEventHandler) + { + eventHandler = parsingEventHandler; + input = string; + size = string.length; + reset(0, 0, 0); + } + + this.getInput = function() + { + return input; + }; + + function reset(l, b, e) + { + b0 = b; e0 = b; + l1 = l; b1 = b; e1 = e; + end = e; + eventHandler.reset(input); + } + + this.getOffendingToken = function(e) + { + var o = e.getOffending(); + return o >= 0 ? CommentParser.TOKEN[o] : null; + }; + + this.getExpectedTokenSet = function(e) + { + var expected; + if (e.getExpected() < 0) + { + expected = getExpectedTokenSet(e.getState()); + } + else + { + expected = [CommentParser.TOKEN[e.getExpected()]]; + } + return expected; + }; + + this.getErrorMessage = function(e) + { + var tokenSet = this.getExpectedTokenSet(e); + var found = this.getOffendingToken(e); + var prefix = input.substring(0, e.getBegin()); + var lines = prefix.split("\n"); + var line = lines.length; + var column = lines[line - 1].length + 1; + var size = e.getEnd() - e.getBegin(); + return e.getMessage() + + (found == null ? "" : ", found " + found) + + "\nwhile expecting " + + (tokenSet.length == 1 ? tokenSet[0] : ("[" + tokenSet.join(", ") + "]")) + + "\n" + + (size == 0 ? "" : "after successfully scanning " + size + " characters beginning ") + + "at line " + line + ", column " + column + ":\n..." + + input.substring(e.getBegin(), Math.min(input.length, e.getBegin() + 64)) + + "..."; + }; + + this.parse_Comments = function() + { + eventHandler.startNonterminal("Comments", e0); + for (;;) + { + lookahead1(0); // S^WS | EOF | '(:' + if (l1 == 3) // EOF + { + break; + } + switch (l1) + { + case 1: // S^WS + shift(1); // S^WS + break; + default: + parse_Comment(); + } + } + shift(3); // EOF + eventHandler.endNonterminal("Comments", e0); + }; + + function parse_Comment() + { + eventHandler.startNonterminal("Comment", e0); + shift(4); // '(:' + for (;;) + { + lookahead1(1); // CommentContents | '(:' | ':)' + if (l1 == 5) // ':)' + { + break; + } + switch (l1) + { + case 2: // CommentContents + shift(2); // CommentContents + break; + default: + parse_Comment(); + } + } + shift(5); // ':)' + eventHandler.endNonterminal("Comment", e0); + } + + var lk, b0, e0; + var l1, b1, e1; + var eventHandler; + + function error(b, e, s, l, t) + { + throw new self.ParseException(b, e, s, l, t); + } + + function shift(t) + { + if (l1 == t) + { + eventHandler.terminal(CommentParser.TOKEN[l1], b1, e1 > size ? size : e1); + b0 = b1; e0 = e1; l1 = 0; + } + else + { + error(b1, e1, 0, l1, t); + } + } + + function lookahead1(set) + { + if (l1 == 0) + { + l1 = match(set); + b1 = begin; + e1 = end; + } + } + + var input; + var size; + var begin; + var end; + var state; + + function match(tokenset) + { + var nonbmp = false; + begin = end; + var current = end; + var result = CommentParser.INITIAL[tokenset]; + + for (var code = result & 15; code != 0; ) + { + var charclass; + var c0 = current < size ? input.charCodeAt(current) : 0; + ++current; + if (c0 < 0x80) + { + charclass = CommentParser.MAP0[c0]; + } + else if (c0 < 0xd800) + { + var c1 = c0 >> 5; + charclass = CommentParser.MAP1[(c0 & 31) + CommentParser.MAP1[(c1 & 31) + CommentParser.MAP1[c1 >> 5]]]; + } + else + { + if (c0 < 0xdc00) + { + var c1 = current < size ? input.charCodeAt(current) : 0; + if (c1 >= 0xdc00 && c1 < 0xe000) + { + ++current; + c0 = ((c0 & 0x3ff) << 10) + (c1 & 0x3ff) + 0x10000; + nonbmp = true; + } + } + var lo = 0, hi = 1; + for (var m = 1; ; m = (hi + lo) >> 1) + { + if (CommentParser.MAP2[m] > c0) hi = m - 1; + else if (CommentParser.MAP2[2 + m] < c0) lo = m + 1; + else {charclass = CommentParser.MAP2[4 + m]; break;} + if (lo > hi) {charclass = 0; break;} + } + } + + state = code; + var i0 = (charclass << 4) + code - 1; + code = CommentParser.TRANSITION[(i0 & 3) + CommentParser.TRANSITION[i0 >> 2]]; + + if (code > 15) + { + result = code; + code &= 15; + end = current; + } + } + + result >>= 4; + if (result == 0) + { + end = current - 1; + var c1 = end < size ? input.charCodeAt(end) : 0; + if (c1 >= 0xdc00 && c1 < 0xe000) --end; + error(begin, end, state, -1, -1); + } + + if (nonbmp) + { + for (var i = result >> 3; i > 0; --i) + { + --end; + var c1 = end < size ? input.charCodeAt(end) : 0; + if (c1 >= 0xdc00 && c1 < 0xe000) --end; + } + } + else + { + end -= result >> 3; + } + + return (result & 7) - 1; + } + + function getExpectedTokenSet(s) + { + var set = []; + if (s > 0) + { + for (var i = 0; i < 6; i += 32) + { + var j = i; + for (var f = ec(i >>> 5, s); f != 0; f >>>= 1, ++j) + { + if ((f & 1) != 0) + { + set[set.length] = CommentParser.TOKEN[j]; + } + } + } + } + return set; + } + + function ec(t, s) + { + var i0 = t * 9 + s - 1; + return CommentParser.EXPECTED[i0]; + } +} + +CommentParser.MAP0 = +[ + /* 0 */ 6, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, + /* 36 */ 2, 2, 2, 2, 3, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + /* 72 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + /* 108 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 +]; + +CommentParser.MAP1 = +[ + /* 0 */ 54, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + /* 27 */ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + /* 54 */ 88, 120, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, + /* 76 */ 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 6, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, + /* 104 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 3, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + /* 140 */ 2, 2, 2, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + /* 176 */ 2, 2, 2 +]; + +CommentParser.MAP2 = +[ + /* 0 */ 57344, 65536, 65533, 1114111, 2, 2 +]; + +CommentParser.INITIAL = +[ + /* 0 */ 1, 2 +]; + +CommentParser.TRANSITION = +[ + /* 0 */ 33, 33, 33, 33, 28, 37, 32, 33, 31, 37, 32, 33, 43, 50, 53, 33, 31, 39, 33, 33, 46, 57, 59, 33, 63, 33, 33, + /* 27 */ 33, 35, 5, 35, 0, 5, 0, 0, 0, 0, 5, 5, 5, 5, 96, 5, 4, 6, 0, 0, 7, 0, 80, 184, 184, 184, 184, 0, 0, 0, 185, + /* 58 */ 80, 185, 0, 0, 0, 64, 0, 0, 0 +]; + +CommentParser.EXPECTED = +[ + /* 0 */ 26, 52, 2, 16, 4, 20, 36, 4, 4 +]; + +CommentParser.TOKEN = +[ + "(0)", + "S", + "CommentContents", + "EOF", + "'(:'", + "':)'" +]; + + // line 54 "CommentParser.ebnf" + }); + // line 371 "CommentParser.js" +// End diff --git a/lib/ace/mode/xquery/JSONParseTreeHandler.js b/lib/ace/mode/xquery/JSONParseTreeHandler.js index 77f493be..ff98ac3c 100644 --- a/lib/ace/mode/xquery/JSONParseTreeHandler.js +++ b/lib/ace/mode/xquery/JSONParseTreeHandler.js @@ -29,18 +29,26 @@ * ***** END LICENSE BLOCK ***** */ define(function(require, exports, module){ - var JSONParseTreeHandler = exports.JSONParseTreeHandler = function() { + + var JSONParseTreeHandler = exports.JSONParseTreeHandler = function(code) { + + //List of nodes that are left untouched in the parse tree size optimization. + var blacklist = ["VarDeclStatement"]; var ast = null; var ptr = null; - + var remains = code; + var cursor = 0; + var lineCursor = 0; + var line = 0; + var col = 0; + function createNode(name){ - return { name: name, children: [], getParent: null }; + return { name: name, children: [], getParent: null, pos: { sl: 0, sc: 0, el: 0, ec: 0 } }; } function pushNode(name, begin){ var node = createNode(name); - node.begin = begin; if(ast === null) { ast = node; ptr = node; @@ -52,17 +60,38 @@ define(function(require, exports, module){ } function popNode(name, end){ - ptr.end = end; + + if(ptr.children.length > 0) { + var s = ptr.children[0]; + var e = ptr.children[ptr.children.length - 1]; + ptr.pos.sl = s.pos.sl; + ptr.pos.sc = s.pos.sc; + ptr.pos.el = e.pos.el; + ptr.pos.ec = e.pos.ec; + } + if(ptr.getParent !== null) { ptr = ptr.getParent; - for(var i in ptr.children) { - delete ptr.children[i].getParent; - } + //for(var i in ptr.children) { + //delete ptr.children[i].getParent; + //} } else { - delete ptr.getParent; + //delete ptr.getParent; } + + //Parse tree size optimization + //if(ptr.children.length > 0) { + // var lastChild = ptr.children[ptr.children.length - 1]; + // if(lastChild.children.length === 1 && blacklist.indexOf(lastChild.name) !== -1) { + // ptr.children[ptr.children.length - 1] = lastChild.children[0]; + // } + //} } + this.peek = function() { + return ptr; + }; + this.getParseTree = function() { return ast; }; @@ -78,15 +107,35 @@ define(function(require, exports, module){ }; this.terminal = function(name, begin, end) { - var name = (name.substring(0, 1) === "'" && name.substring(name.length - 1) === "'") ? "TOKEN" : name; - pushNode(name, begin); + name = (name.substring(0, 1) === "'" && name.substring(name.length - 1) === "'") ? "TOKEN" : name; + pushNode(name, begin); + setValue(ptr, begin, end); popNode(name, end); }; this.whitespace = function(begin, end) { var name = "WS"; pushNode(name, begin); + setValue(ptr, begin, end); popNode(name, end); - }; + }; + + function setValue(node, begin, end) { + var e = end - cursor; + ptr.value = remains.substring(0, e); + var sl = line; + var sc = line === 0 ? lineCursor : lineCursor - 1; + var el = sl + ptr.value.split("\n").length - 1; + var lastIdx = ptr.value.lastIndexOf("\n"); + var ec = lastIdx === -1 ? sc + ptr.value.length : ptr.value.substring(lastIdx).length; + remains = remains.substring(e); + cursor = end; + lineCursor = lastIdx === -1 ? lineCursor + (ptr.value.length) : ec; + line = el; + ptr.pos.sl = sl; + ptr.pos.sc = sc; + ptr.pos.el = el; + ptr.pos.ec = ec; + } }; }); diff --git a/lib/ace/mode/xquery/XQueryParser.ebnf b/lib/ace/mode/xquery/XQueryParser.ebnf new file mode 100644 index 00000000..8c968ad3 --- /dev/null +++ b/lib/ace/mode/xquery/XQueryParser.ebnf @@ -0,0 +1,1175 @@ + + +XQuery ::= Module EOF +Module ::= VersionDecl? ( LibraryModule | MainModule ) +VersionDecl + ::= 'xquery' ( 'encoding' StringLiteral | 'version' StringLiteral ( 'encoding' StringLiteral )? ) Separator +LibraryModule + ::= ModuleDecl Prolog +ModuleDecl + ::= 'module' 'namespace' NCName '=' URILiteral Separator +Prolog ::= ( ( DefaultNamespaceDecl | Setter | NamespaceDecl | Import | FTOptionDecl ) Separator )* ( ( ContextItemDecl | AnnotatedDecl | OptionDecl ) Separator )* +Separator + ::= ';' +Setter ::= BoundarySpaceDecl + | DefaultCollationDecl + | BaseURIDecl + | ConstructionDecl + | OrderingModeDecl + | EmptyOrderDecl + | RevalidationDecl + | CopyNamespacesDecl + | DecimalFormatDecl +BoundarySpaceDecl + ::= 'declare' 'boundary-space' ( 'preserve' | 'strip' ) +DefaultCollationDecl + ::= 'declare' 'default' 'collation' URILiteral +BaseURIDecl + ::= 'declare' 'base-uri' URILiteral +ConstructionDecl + ::= 'declare' 'construction' ( 'strip' | 'preserve' ) +OrderingModeDecl + ::= 'declare' 'ordering' ( 'ordered' | 'unordered' ) +EmptyOrderDecl + ::= 'declare' 'default' 'order' 'empty' ( 'greatest' | 'least' ) +CopyNamespacesDecl + ::= 'declare' 'copy-namespaces' PreserveMode ',' InheritMode +PreserveMode + ::= 'preserve' + | 'no-preserve' +InheritMode + ::= 'inherit' + | 'no-inherit' +DecimalFormatDecl + ::= 'declare' ( 'decimal-format' EQName | 'default' 'decimal-format' ) ( DFPropertyName '=' StringLiteral )* +DFPropertyName + ::= 'decimal-separator' + | 'grouping-separator' + | 'infinity' + | 'minus-sign' + | 'NaN' + | 'percent' + | 'per-mille' + | 'zero-digit' + | 'digit' + | 'pattern-separator' +Import ::= SchemaImport + | ModuleImport +SchemaImport + ::= 'import' 'schema' SchemaPrefix? URILiteral ( 'at' URILiteral ( ',' URILiteral )* )? +SchemaPrefix + ::= 'namespace' NCName '=' + | 'default' 'element' 'namespace' +ModuleImport + ::= 'import' 'module' ( 'namespace' NCName '=' )? URILiteral ( 'at' URILiteral ( ',' URILiteral )* )? +NamespaceDecl + ::= 'declare' 'namespace' NCName '=' URILiteral +DefaultNamespaceDecl + ::= 'declare' 'default' ( 'element' | 'function' ) 'namespace' URILiteral +FTOptionDecl + ::= 'declare' 'ft-option' FTMatchOptions +AnnotatedDecl + ::= 'declare' ( CompatibilityAnnotation | Annotation )* ( VarDecl | FunctionDecl | CollectionDecl | IndexDecl | ICDecl ) +CompatibilityAnnotation + ::= 'updating' +Annotation + ::= '%' EQName ( '(' Literal ( ',' Literal )* ')' )? +VarDecl ::= 'variable' '$' VarName TypeDeclaration? ( ':=' VarValue | 'external' ( ':=' VarDefaultValue )? ) +VarValue ::= ExprSingle +VarDefaultValue + ::= ExprSingle +ContextItemDecl + ::= 'declare' 'context' 'item' ( 'as' ItemType )? ( ':=' VarValue | 'external' ( ':=' VarDefaultValue )? ) +ParamList + ::= Param ( ',' Param )* +Param ::= '$' EQName TypeDeclaration? +FunctionBody + ::= EnclosedExpr +EnclosedExpr + ::= '{' Expr '}' +OptionDecl + ::= 'declare' 'option' EQName StringLiteral +Expr ::= ExprSingle ( ',' ExprSingle )* +FLWORExpr + ::= InitialClause IntermediateClause* ReturnClause +InitialClause + ::= ForClause + | LetClause + | WindowClause +IntermediateClause + ::= InitialClause + | WhereClause + | GroupByClause + | OrderByClause + | CountClause +ForClause + ::= 'for' ForBinding ( ',' ForBinding )* +ForBinding + ::= '$' VarName TypeDeclaration? AllowingEmpty? PositionalVar? FTScoreVar? 'in' ExprSingle +AllowingEmpty + ::= 'allowing' 'empty' +PositionalVar + ::= 'at' '$' VarName +FTScoreVar + ::= 'score' '$' VarName +LetClause + ::= 'let' LetBinding ( ',' LetBinding )* +LetBinding + ::= ( '$' VarName TypeDeclaration? | FTScoreVar ) ':=' ExprSingle +WindowClause + ::= 'for' ( TumblingWindowClause | SlidingWindowClause ) +TumblingWindowClause + ::= 'tumbling' 'window' '$' VarName TypeDeclaration? 'in' ExprSingle WindowStartCondition WindowEndCondition? +SlidingWindowClause + ::= 'sliding' 'window' '$' VarName TypeDeclaration? 'in' ExprSingle WindowStartCondition WindowEndCondition +WindowStartCondition + ::= 'start' WindowVars 'when' ExprSingle +WindowEndCondition + ::= 'only'? 'end' WindowVars 'when' ExprSingle +WindowVars + ::= ( '$' CurrentItem )? PositionalVar? ( 'previous' '$' PreviousItem )? ( 'next' '$' NextItem )? +CurrentItem + ::= EQName +PreviousItem + ::= EQName +NextItem ::= EQName +CountClause + ::= 'count' '$' VarName +WhereClause + ::= 'where' ExprSingle +GroupByClause + ::= 'group' 'by' GroupingSpecList +GroupingSpecList + ::= GroupingSpec ( ',' GroupingSpec )* +GroupingSpec + ::= '$' VarName ( TypeDeclaration? ':=' ExprSingle )? ( 'collation' URILiteral )? +OrderByClause + ::= ( 'order' 'by' | 'stable' 'order' 'by' ) OrderSpecList +OrderSpecList + ::= OrderSpec ( ',' OrderSpec )* +OrderSpec + ::= ExprSingle OrderModifier +OrderModifier + ::= ( 'ascending' | 'descending' )? ( 'empty' ( 'greatest' | 'least' ) )? ( 'collation' URILiteral )? +ReturnClause + ::= 'return' ExprSingle +QuantifiedExpr + ::= ( 'some' | 'every' ) '$' VarName TypeDeclaration? 'in' ExprSingle ( ',' '$' VarName TypeDeclaration? 'in' ExprSingle )* 'satisfies' ExprSingle +SwitchExpr + ::= 'switch' '(' Expr ')' SwitchCaseClause+ 'default' 'return' ExprSingle +SwitchCaseClause + ::= ( 'case' SwitchCaseOperand )+ 'return' ExprSingle +SwitchCaseOperand + ::= ExprSingle +TypeswitchExpr + ::= 'typeswitch' '(' Expr ')' CaseClause+ 'default' ( '$' VarName )? 'return' ExprSingle +CaseClause + ::= 'case' ( '$' VarName 'as' )? SequenceTypeUnion 'return' ExprSingle +SequenceTypeUnion + ::= SequenceType ( '|' SequenceType )* +IfExpr ::= 'if' '(' Expr ')' 'then' ExprSingle 'else' ExprSingle +TryCatchExpr + ::= TryClause CatchClause+ +TryClause + ::= 'try' '{' TryTargetExpr '}' +TryTargetExpr + ::= Expr +CatchClause + ::= 'catch' CatchErrorList '{' Expr '}' +CatchErrorList + ::= NameTest ( '|' NameTest )* +OrExpr ::= AndExpr ( 'or' AndExpr )* +AndExpr ::= ComparisonExpr ( 'and' ComparisonExpr )* +ComparisonExpr + ::= FTContainsExpr ( ( ValueComp | GeneralComp | NodeComp ) FTContainsExpr )? +FTContainsExpr + ::= StringConcatExpr ( 'contains' 'text' FTSelection FTIgnoreOption? )? +StringConcatExpr + ::= RangeExpr ( '||' RangeExpr )* +RangeExpr + ::= AdditiveExpr ( 'to' AdditiveExpr )? +AdditiveExpr + ::= MultiplicativeExpr ( ( '+' | '-' ) MultiplicativeExpr )* +MultiplicativeExpr + ::= UnionExpr ( ( '*' | 'div' | 'idiv' | 'mod' ) UnionExpr )* +UnionExpr + ::= IntersectExceptExpr ( ( 'union' | '|' ) IntersectExceptExpr )* +IntersectExceptExpr + ::= InstanceofExpr ( ( 'intersect' | 'except' ) InstanceofExpr )* +InstanceofExpr + ::= TreatExpr ( 'instance' 'of' SequenceType )? +TreatExpr + ::= CastableExpr ( 'treat' 'as' SequenceType )? +CastableExpr + ::= CastExpr ( 'castable' 'as' SingleType )? +CastExpr ::= UnaryExpr ( 'cast' 'as' SingleType )? +UnaryExpr + ::= ( '-' | '+' )* ValueExpr +ValueExpr + ::= ValidateExpr + | SimpleMapExpr + | ExtensionExpr +SimpleMapExpr + ::= PathExpr ('!' PathExpr)* +GeneralComp + ::= '=' + | '!=' + | '<' + | '<=' + | '>' + | '>=' +ValueComp + ::= 'eq' + | 'ne' + | 'lt' + | 'le' + | 'gt' + | 'ge' +NodeComp ::= 'is' + | '<<' + | '>>' +ValidateExpr + ::= 'validate' ( ValidationMode | 'type' TypeName )? '{' Expr '}' +ValidationMode + ::= 'lax' + | 'strict' +ExtensionExpr + ::= Pragma+ '{' Expr? '}' +Pragma ::= '(#' S? EQName ( S PragmaContents )? '#)' + /* ws: explicit */ +PathExpr ::= '/' ( RelativePathExpr / ) + | '//' RelativePathExpr + | RelativePathExpr +RelativePathExpr + ::= StepExpr ( ( '/' | '//' | '!' ) StepExpr )* +StepExpr ::= PostfixExpr + | AxisStep +AxisStep ::= ( ReverseStep | ForwardStep ) PredicateList +ForwardStep + ::= ForwardAxis NodeTest + | AbbrevForwardStep +ForwardAxis + ::= 'child' '::' + | 'descendant' '::' + | 'attribute' '::' + | 'self' '::' + | 'descendant-or-self' '::' + | 'following-sibling' '::' + | 'following' '::' +AbbrevForwardStep + ::= '@'? NodeTest +ReverseStep + ::= ReverseAxis NodeTest + | AbbrevReverseStep +ReverseAxis + ::= 'parent' '::' + | 'ancestor' '::' + | 'preceding-sibling' '::' + | 'preceding' '::' + | 'ancestor-or-self' '::' +AbbrevReverseStep + ::= '..' +NodeTest ::= KindTest + | NameTest +NameTest ::= EQName + | Wildcard +PostfixExpr + ::= PrimaryExpr ( Predicate | ArgumentList )* +ArgumentList + ::= '(' ( Argument ( ',' Argument )* )? ')' +PredicateList + ::= Predicate* +Predicate + ::= '[' Expr ']' +Literal ::= NumericLiteral + | StringLiteral +NumericLiteral + ::= IntegerLiteral + | DecimalLiteral + | DoubleLiteral +VarRef ::= '$' VarName +VarName ::= EQName +ParenthesizedExpr + ::= '(' Expr? ')' +ContextItemExpr + ::= '.' +OrderedExpr + ::= 'ordered' '{' Expr '}' +UnorderedExpr + ::= 'unordered' '{' Expr '}' +FunctionCall + ::= FunctionName ArgumentList +Argument ::= ExprSingle + | ArgumentPlaceholder +ArgumentPlaceholder + ::= '?' +Constructor + ::= DirectConstructor + | ComputedConstructor +DirectConstructor + ::= DirElemConstructor + | DirCommentConstructor + | DirPIConstructor +DirElemConstructor + ::= '<' QName DirAttributeList ( '/>' | '>' DirElemContent* '' ) + /* ws: explicit */ +DirAttributeList + ::= ( S ( QName S? '=' S? DirAttributeValue )? )* + /* ws: explicit */ +DirAttributeValue + ::= '"' ( EscapeQuot | QuotAttrValueContent )* '"' + | "'" ( EscapeApos | AposAttrValueContent )* "'" + /* ws: explicit */ +QuotAttrValueContent + ::= QuotAttrContentChar + | CommonContent +AposAttrValueContent + ::= AposAttrContentChar + | CommonContent +DirElemContent + ::= DirectConstructor + | CDataSection + | CommonContent + | ElementContentChar +DirCommentConstructor + ::= '' + /* ws: explicit */ +DirPIConstructor + ::= '' + /* ws: explicit */ +ComputedConstructor + ::= CompDocConstructor + | CompElemConstructor + | CompAttrConstructor + | CompNamespaceConstructor + | CompTextConstructor + | CompCommentConstructor + | CompPIConstructor +CompElemConstructor + ::= 'element' ( EQName | '{' Expr '}' ) '{' ContentExpr? '}' +CompNamespaceConstructor + ::= 'namespace' ( Prefix | '{' PrefixExpr '}' ) '{' URIExpr '}' +Prefix ::= NCName +PrefixExpr + ::= Expr +URIExpr ::= Expr +FunctionItemExpr + ::= NamedFunctionRef + | InlineFunctionExpr +NamedFunctionRef + ::= EQName '#' IntegerLiteral +InlineFunctionExpr + ::= Annotation* 'function' '(' ParamList? ')' ( 'as' SequenceType )? FunctionBody +SingleType + ::= SimpleTypeName '?'? +TypeDeclaration + ::= 'as' SequenceType +SequenceType + ::= 'empty-sequence' '(' ')' + | ItemType ( OccurrenceIndicator / ) +OccurrenceIndicator + ::= '?' + | '*'^OccurrenceIndicator + | '+' +ItemType ::= KindTest + | 'item' '(' ')' + | FunctionTest + | AtomicOrUnionType + | ParenthesizedItemType + | JSONTest + | StructuredItemTest +JSONTest ::= + JSONItemTest + | JSONObjectTest + | JSONArrayTest + +StructuredItemTest ::= "structured-item" "(" ")" + +JSONItemTest ::= "json-item" "(" ")" + +JSONObjectTest ::= "object" "(" ")" + +JSONArrayTest ::= "array" "(" ")" + +AtomicOrUnionType + ::= EQName +KindTest ::= DocumentTest + | ElementTest + | AttributeTest + | SchemaElementTest + | SchemaAttributeTest + | PITest + | CommentTest + | TextTest + | NamespaceNodeTest + | JSONTest + | AnyKindTest +AnyKindTest + ::= 'node' '(' ')' +DocumentTest + ::= 'document-node' '(' ( ElementTest | SchemaElementTest )? ')' +TextTest ::= 'text' '(' ')' +CommentTest + ::= 'comment' '(' ')' +NamespaceNodeTest + ::= 'namespace-node' '(' ')' +PITest ::= 'processing-instruction' '(' ( NCName | StringLiteral )? ')' +AttributeTest + ::= 'attribute' '(' ( AttribNameOrWildcard ( ',' TypeName )? )? ')' +AttribNameOrWildcard + ::= AttributeName + | '*' +SchemaAttributeTest + ::= 'schema-attribute' '(' AttributeDeclaration ')' +AttributeDeclaration + ::= AttributeName +ElementTest + ::= 'element' '(' ( ElementNameOrWildcard ( ',' TypeName '?'? )? )? ')' +ElementNameOrWildcard + ::= ElementName + | '*' +SchemaElementTest + ::= 'schema-element' '(' ElementDeclaration ')' +ElementDeclaration + ::= ElementName +AttributeName + ::= EQName +ElementName + ::= EQName +SimpleTypeName + ::= TypeName +TypeName ::= EQName +FunctionTest + ::= Annotation* ( AnyFunctionTest | TypedFunctionTest ) +AnyFunctionTest + ::= 'function' '(' '*' ')' +TypedFunctionTest + ::= 'function' '(' ( SequenceType ( ',' SequenceType )* )? ')' 'as' SequenceType +ParenthesizedItemType + ::= '(' ItemType ')' +RevalidationDecl + ::= 'declare' 'revalidation' ( 'strict' | 'lax' | 'skip' ) +InsertExprTargetChoice + ::= ( 'as' ( 'first' | 'last' ) )? 'into' + | 'after' + | 'before' +InsertExpr + ::= 'insert' ( 'node' | 'nodes' ) SourceExpr InsertExprTargetChoice TargetExpr +DeleteExpr + ::= 'delete' ( 'node' | 'nodes' ) TargetExpr +ReplaceExpr + ::= 'replace' ( 'value' 'of' )? 'node' TargetExpr 'with' ExprSingle +RenameExpr + ::= 'rename' 'node' TargetExpr 'as' NewNameExpr +SourceExpr + ::= ExprSingle +TargetExpr + ::= ExprSingle +NewNameExpr + ::= ExprSingle +TransformExpr + ::= 'copy' '$' VarName ':=' ExprSingle ( ',' '$' VarName ':=' ExprSingle )* 'modify' ExprSingle 'return' ExprSingle +FTSelection + ::= FTOr FTPosFilter* +FTWeight ::= 'weight' '{' Expr '}' +FTOr ::= FTAnd ( 'ftor' FTAnd )* +FTAnd ::= FTMildNot ( 'ftand' FTMildNot )* +FTMildNot + ::= FTUnaryNot ( 'not' 'in' FTUnaryNot )* +FTUnaryNot + ::= 'ftnot'? FTPrimaryWithOptions +FTPrimaryWithOptions + ::= FTPrimary FTMatchOptions? FTWeight? +FTPrimary + ::= FTWords FTTimes? + | '(' FTSelection ')' + | FTExtensionSelection +FTWords ::= FTWordsValue FTAnyallOption? +FTWordsValue + ::= StringLiteral + | '{' Expr '}' +FTExtensionSelection + ::= Pragma+ '{' FTSelection? '}' +FTAnyallOption + ::= 'any' 'word'? + | 'all' 'words'? + | 'phrase' +FTTimes ::= 'occurs' FTRange 'times' +FTRange ::= 'exactly' AdditiveExpr + | 'at' ( 'least' AdditiveExpr | 'most' AdditiveExpr ) + | 'from' AdditiveExpr 'to' AdditiveExpr +FTPosFilter + ::= FTOrder + | FTWindow + | FTDistance + | FTScope + | FTContent +FTOrder ::= 'ordered' +FTWindow ::= 'window' AdditiveExpr FTUnit +FTDistance + ::= 'distance' FTRange FTUnit +FTUnit ::= 'words' + | 'sentences' + | 'paragraphs' +FTScope ::= ( 'same' | 'different' ) FTBigUnit +FTBigUnit + ::= 'sentence' + | 'paragraph' +FTContent + ::= 'at' ( 'start' | 'end' ) + | 'entire' 'content' +FTMatchOptions + ::= ( 'using' FTMatchOption )+ +FTMatchOption + ::= FTLanguageOption + | FTWildCardOption + | FTThesaurusOption + | FTStemOption + | FTCaseOption + | FTDiacriticsOption + | FTStopWordOption + | FTExtensionOption +FTCaseOption + ::= 'case' ( 'insensitive' | 'sensitive' ) + | 'lowercase' + | 'uppercase' +FTDiacriticsOption + ::= 'diacritics' ( 'insensitive' | 'sensitive' ) +FTStemOption + ::= 'stemming' + | 'no' 'stemming' +FTThesaurusOption + ::= 'thesaurus' ( FTThesaurusID | 'default' | '(' ( FTThesaurusID | 'default' ) ( ',' FTThesaurusID )* ')' ) + | 'no' 'thesaurus' +FTThesaurusID + ::= 'at' URILiteral ( 'relationship' StringLiteral )? ( FTLiteralRange 'levels' )? +FTLiteralRange + ::= 'exactly' IntegerLiteral + | 'at' ( 'least' IntegerLiteral | 'most' IntegerLiteral ) + | 'from' IntegerLiteral 'to' IntegerLiteral +FTStopWordOption + ::= 'stop' 'words' ( FTStopWords FTStopWordsInclExcl* | 'default' FTStopWordsInclExcl* ) + | 'no' 'stop' 'words' +FTStopWords + ::= 'at' URILiteral + | '(' StringLiteral ( ',' StringLiteral )* ')' +FTStopWordsInclExcl + ::= ( 'union' | 'except' ) FTStopWords +FTLanguageOption + ::= 'language' StringLiteral +FTWildCardOption + ::= 'wildcards' + | 'no' 'wildcards' +FTExtensionOption + ::= 'option' EQName StringLiteral +FTIgnoreOption + ::= 'without' 'content' UnionExpr +CollectionDecl + ::= 'collection' EQName CollectionTypeDecl? +CollectionTypeDecl + ::= 'as' KindTest OccurrenceIndicator? +IndexName + ::= EQName +IndexDomainExpr + ::= PathExpr +IndexKeySpec + ::= IndexKeyExpr IndexKeyTypeDecl? IndexKeyCollation? +IndexKeyExpr + ::= PathExpr +IndexKeyTypeDecl + ::= 'as' AtomicType OccurrenceIndicator? +AtomicType + ::= EQName +IndexKeyCollation + ::= 'collation' URILiteral +IndexDecl + ::= 'index' IndexName 'on' 'nodes' IndexDomainExpr 'by' IndexKeySpec ( ',' IndexKeySpec )* +ICDecl ::= 'integrity' 'constraint' EQName ( ICCollection | ICForeignKey ) +ICCollection + ::= 'on' 'collection' EQName ( ICCollSequence | ICCollSequenceUnique | ICCollNode ) +ICCollSequence + ::= VarRef 'check' ExprSingle +ICCollSequenceUnique + ::= 'node' VarRef 'check' 'unique' 'key' PathExpr +ICCollNode + ::= 'foreach' 'node' VarRef 'check' ExprSingle +ICForeignKey + ::= 'foreign' 'key' ICForeignKeySource ICForeignKeyTarget +ICForeignKeySource + ::= 'from' ICForeignKeyValues +ICForeignKeyTarget + ::= 'to' ICForeignKeyValues +ICForeignKeyValues + ::= 'collection' EQName 'node' VarRef 'key' PathExpr +Comment ::= '(:' ( CommentContents | Comment )* ':)' + /* ws: explicit */ +Whitespace + ::= S^WS + | Comment + /* ws: definition */ +EQName ::= FunctionName + | 'attribute' + | 'comment' + | 'document-node' + | 'element' + | 'empty-sequence' + | 'function' + | 'if' + | 'item' + | 'namespace-node' + | 'node' + | 'processing-instruction' + | 'schema-attribute' + | 'schema-element' + | 'switch' + | 'text' + | 'typeswitch' +FunctionName + ::= EQName^Token + | 'after' + | 'ancestor' + | 'ancestor-or-self' + | 'and' + | 'as' + | 'ascending' + | 'before' + | 'case' + | 'cast' + | 'castable' + | 'child' + | 'collation' + | 'copy' + | 'count' + | 'declare' + | 'default' + | 'delete' + | 'descendant' + | 'descendant-or-self' + | 'descending' + | 'div' + | 'document' + | 'else' + | 'empty' + | 'end' + | 'eq' + | 'every' + | 'except' + | 'first' + | 'following' + | 'following-sibling' + | 'for' + | 'ge' + | 'group' + | 'gt' + | 'idiv' + | 'import' + | 'insert' + | 'instance' + | 'intersect' + | 'into' + | 'is' + | 'last' + | 'le' + | 'let' + | 'lt' + | 'mod' + | 'modify' + | 'module' + | 'namespace' + | 'ne' + | 'only' + | 'or' + | 'order' + | 'ordered' + | 'parent' + | 'preceding' + | 'preceding-sibling' + | 'rename' + | 'replace' + | 'return' + | 'satisfies' + | 'self' + | 'some' + | 'stable' + | 'start' + | 'to' + | 'treat' + | 'try' + | 'union' + | 'unordered' + | 'validate' + | 'where' + | 'with' + | 'xquery' + | 'allowing' + | 'at' + | 'base-uri' + | 'boundary-space' + | 'break' + | 'catch' + | 'construction' + | 'context' + | 'continue' + | 'copy-namespaces' + | 'decimal-format' + | 'encoding' + | 'exit' + | 'external' + | 'ft-option' + | 'in' + | 'index' + | 'integrity' + | 'lax' + | 'nodes' + | 'option' + | 'ordering' + | 'revalidation' + | 'schema' + | 'score' + | 'sliding' + | 'strict' + | 'tumbling' + | 'type' + | 'updating' + | 'value' + | 'variable' + | 'version' + | 'while' + | 'constraint' + | 'loop' + | 'returning' +NCName ::= NCName^Token + | 'after' + | 'and' + | 'as' + | 'ascending' + | 'before' + | 'case' + | 'cast' + | 'castable' + | 'collation' + | 'count' + | 'default' + | 'descending' + | 'div' + | 'else' + | 'empty' + | 'end' + | 'eq' + | 'except' + | 'for' + | 'ge' + | 'group' + | 'gt' + | 'idiv' + | 'instance' + | 'intersect' + | 'into' + | 'is' + | 'le' + | 'let' + | 'lt' + | 'mod' + | 'modify' + | 'ne' + | 'only' + | 'or' + | 'order' + | 'return' + | 'satisfies' + | 'stable' + | 'start' + | 'to' + | 'treat' + | 'union' + | 'where' + | 'with' + | 'ancestor' + | 'ancestor-or-self' + | 'attribute' + | 'child' + | 'comment' + | 'copy' + | 'declare' + | 'delete' + | 'descendant' + | 'descendant-or-self' + | 'document' + | 'document-node' + | 'element' + | 'empty-sequence' + | 'every' + | 'first' + | 'following' + | 'following-sibling' + | 'function' + | 'if' + | 'import' + | 'insert' + | 'item' + | 'last' + | 'module' + | 'namespace' + | 'namespace-node' + | 'node' + | 'ordered' + | 'parent' + | 'preceding' + | 'preceding-sibling' + | 'processing-instruction' + | 'rename' + | 'replace' + | 'schema-attribute' + | 'schema-element' + | 'self' + | 'some' + | 'switch' + | 'text' + | 'try' + | 'typeswitch' + | 'unordered' + | 'validate' + | 'variable' + | 'xquery' + | 'allowing' + | 'at' + | 'base-uri' + | 'boundary-space' + | 'break' + | 'catch' + | 'construction' + | 'context' + | 'continue' + | 'copy-namespaces' + | 'decimal-format' + | 'encoding' + | 'exit' + | 'external' + | 'ft-option' + | 'in' + | 'index' + | 'integrity' + | 'lax' + | 'nodes' + | 'option' + | 'ordering' + | 'revalidation' + | 'schema' + | 'score' + | 'sliding' + | 'strict' + | 'tumbling' + | 'type' + | 'updating' + | 'value' + | 'version' + | 'while' + | 'constraint' + | 'loop' + | 'returning' +MainModule + ::= Prolog Program +Program ::= StatementsAndOptionalExpr +Statements + ::= Statement* +StatementsAndExpr + ::= Statements Expr +StatementsAndOptionalExpr + ::= Statements Expr? +Statement + ::= ApplyStatement + | AssignStatement + | BlockStatement + | BreakStatement + | ContinueStatement + | ExitStatement + | FLWORStatement + | IfStatement + | SwitchStatement + | TryCatchStatement + | TypeswitchStatement + | VarDeclStatement + | WhileStatement +ApplyStatement + ::= ExprSimple ';' +AssignStatement + ::= '$' VarName ':=' ExprSingle ';' +BlockStatement + ::= '{' Statements '}' +BreakStatement + ::= 'break' 'loop' ';' +ContinueStatement + ::= 'continue' 'loop' ';' +ExitStatement + ::= 'exit' 'returning' ExprSingle ';' +FLWORStatement + ::= InitialClause IntermediateClause* ReturnStatement +ReturnStatement + ::= 'return' Statement +IfStatement + ::= 'if' '(' Expr ')' 'then' Statement 'else' Statement +SwitchStatement + ::= 'switch' '(' Expr ')' SwitchCaseStatement+ 'default' 'return' Statement +SwitchCaseStatement + ::= ( 'case' SwitchCaseOperand )+ 'return' Statement +TryCatchStatement + ::= 'try' BlockStatement ( 'catch' CatchErrorList BlockStatement )+ +TypeswitchStatement + ::= 'typeswitch' '(' Expr ')' CaseStatement+ 'default' ( '$' VarName )? 'return' Statement +CaseStatement + ::= 'case' ( '$' VarName 'as' )? SequenceType 'return' Statement +VarDeclStatement + ::= Annotation* 'variable' '$' VarName TypeDeclaration? ( ':=' ExprSingle )? ( ',' '$' VarName TypeDeclaration? ( ':=' ExprSingle )? )* ';' +WhileStatement + ::= 'while' '(' Expr ')' Statement +ExprSingle + ::= ExprSimple + | FLWORExpr + | IfExpr + | SwitchExpr + | TryCatchExpr + | TypeswitchExpr +ExprSimple + ::= QuantifiedExpr + | OrExpr + | InsertExpr + | DeleteExpr + | RenameExpr + | ReplaceExpr + | TransformExpr + | JSONDeleteExpr + | JSONInsertExpr + | JSONRenameExpr + | JSONReplaceExpr + | JSONAppendExpr + +JSONDeleteExpr ::= "delete" "json" PostfixExpr + +JSONInsertExpr ::= "insert" "json" ExprSingle "into" ExprSingle ("at" "position" ExprSingle)? + +JSONRenameExpr ::= "rename" "json" PostfixExpr "as" ExprSingle + +JSONReplaceExpr ::= "replace" "json" "value" "of" PostfixExpr "with" ExprSingle + +JSONAppendExpr ::= "append" "json" ExprSingle "into" ExprSingle + +CommonContent + ::= PredefinedEntityRef + | CharRef + | '{{' + | '}}' + | BlockExpr +ContentExpr + ::= StatementsAndExpr +CompDocConstructor + ::= 'document' BlockExpr +CompAttrConstructor + ::= 'attribute' ( EQName | '{' Expr '}' ) ( '{' '}' | BlockExpr ) +CompPIConstructor + ::= 'processing-instruction' ( NCName | '{' Expr '}' ) ( '{' '}' | BlockExpr ) +CompCommentConstructor + ::= 'comment' BlockExpr +CompTextConstructor + ::= 'text' BlockExpr +PrimaryExpr + ::= Literal + | VarRef + | ParenthesizedExpr + | ContextItemExpr + | FunctionCall + | OrderedExpr + | UnorderedExpr + | Constructor + | FunctionItemExpr + | BlockExpr + | ObjectConstructor + | ArrayConstructor + | JSONSimpleObjectUnion + +JSONSimpleObjectUnion + ::= '{|' Expr? '|}' + + +ObjectConstructor ::= "{" ( PairConstructor ("," PairConstructor)* )? "}" + +PairConstructor ::= ExprSingle ":" ExprSingle + +ArrayConstructor ::= "[" Expr? "]" + +BlockExpr + ::= '{' StatementsAndOptionalExpr '}' +FunctionDecl + ::= 'function' EQName '(' ParamList? ')' ( 'as' SequenceType )? ( '{' StatementsAndOptionalExpr '}' | 'external' ) + + + +PragmaContents + ::= ( Char* - ( Char* '#)' Char* ) ) &'#' +DirCommentContents + ::= ( ( Char - '-' ) | '-' ( Char - '-' ) )* +DirPIContents + ::= ( Char* - ( Char* '?>' Char* ) ) &'?' +CDataSection + ::= '' +CDataSectionContents + ::= Char* - ( Char* ']]>' Char* ) +Wildcard ::= "*" + | (NCName ":" "*") + | ("*" ":" NCName) + | (BracedURILiteral "*") +EQName ::= QName + | URIQualifiedName +URIQualifiedName + ::= BracedURILiteral NCName +BracedURILiteral + ::= 'Q' '{' (PredefinedEntityRef | CharRef | [^&{}] )* '}' +URILiteral + ::= StringLiteral +IntegerLiteral + ::= Digits +DecimalLiteral + ::= '.' Digits + | Digits '.' [0-9]* + /* ws: explicit */ +DoubleLiteral + ::= ( '.' Digits | Digits ( '.' [0-9]* )? ) [Ee] [+#x002D]? Digits + /* ws: explicit */ +StringLiteral + ::= '"' ( PredefinedEntityRef | CharRef | EscapeQuot | [^"&] )* '"' + | "'" ( PredefinedEntityRef | CharRef | EscapeApos | [^&'] )* "'" + /* ws: explicit */ +PredefinedEntityRef + ::= '&' ( 'lt' | 'gt' | 'amp' | 'quot' | 'apos' ) ';' + /* ws: explicit */ +EscapeQuot + ::= '""' +EscapeApos + ::= "''" +ElementContentChar + ::= Char - [&<{}] +QuotAttrContentChar + ::= Char - ["&<{}] +AposAttrContentChar + ::= Char - [&'<{}] +PITarget ::= NCName - ( ( 'X' | 'x' ) ( 'M' | 'm' ) ( 'L' | 'l' ) ) +Name ::= NameStartChar NameChar* +NameStartChar + ::= [:A-Z_a-z#x00C0-#x00D6#x00D8-#x00F6#x00F8-#x02FF#x0370-#x037D#x037F-#x1FFF#x200C-#x200D#x2070-#x218F#x2C00-#x2FEF#x3001-#xD7FF#xF900-#xFDCF#xFDF0-#xFFFD#x10000-#xEFFFF] +NameChar ::= NameStartChar + | [-.0-9#x00B7#x0300-#x036F#x203F-#x2040] +NCName ::= Name - ( Char* ':' Char* ) +Char ::= [#x0009#x000A#x000D#x0020-#xD7FF#xE000-#xFFFD#x10000-#x10FFFF] +QName ::= PrefixedName + | UnprefixedName +PrefixedName + ::= Prefix ':' LocalPart +UnprefixedName + ::= LocalPart +Prefix ::= NCName +LocalPart + ::= NCName +S ::= [#x0009#x000A#x000D#x0020]+ +CharRef ::= '&#' [0-9]+ ';' + | '&#x' [0-9A-Fa-f]+ ';' +Digits ::= [0-9]+ +CommentContents + ::= ( ( Char+ - ( Char* ( '(:' | ':)' ) Char* ) ) - ( Char* '(' ) ) &':' + | ( Char+ - ( Char* ( '(:' | ':)' ) Char* ) ) &'(' +EOF ::= $ +NonNCNameChar + ::= $ + | ':' + | ( Char - NameChar ) +DelimitingChar + ::= NonNCNameChar + | '-' + | '.' +DelimitingChar + \\ IntegerLiteral DecimalLiteral DoubleLiteral +NonNCNameChar + \\ EQName^Token QName NCName^Token 'NaN' 'after' 'all' + 'allowing' 'ancestor' 'ancestor-or-self' 'and' 'any' + 'append' 'array' 'as' 'ascending' 'at' 'attribute' + 'base-uri' 'before' 'boundary-space' 'break' 'by' 'case' + 'cast' 'castable' 'catch' 'check' 'child' 'collation' + 'collection' 'comment' 'constraint' 'construction' + 'contains' 'content' 'context' 'continue' 'copy' + 'copy-namespaces' 'count' 'decimal-format' + 'decimal-separator' 'declare' 'default' 'delete' + 'descendant' 'descendant-or-self' 'descending' + 'diacritics' 'different' 'digit' 'distance' 'div' + 'document' 'document-node' 'element' 'else' 'empty' + 'empty-sequence' 'encoding' 'end' 'entire' 'eq' 'every' + 'exactly' 'except' 'exit' 'external' 'first' 'following' + 'following-sibling' 'for' 'foreach' 'foreign' 'from' + 'ft-option' 'ftand' 'ftnot' 'ftor' 'function' 'ge' + 'greatest' 'group' 'grouping-separator' 'gt' 'idiv' 'if' + 'import' 'in' 'index' 'infinity' 'inherit' 'insensitive' + 'insert' 'instance' 'integrity' 'intersect' 'into' 'is' + 'item' 'json' 'json-item' 'key' 'language' 'last' 'lax' + 'le' 'least' 'let' 'levels' 'loop' 'lowercase' 'lt' + 'minus-sign' 'mod' 'modify' 'module' 'most' 'namespace' + 'namespace-node' 'ne' 'next' 'no' 'no-inherit' + 'no-preserve' 'node' 'nodes' 'not' 'object' 'occurs' + 'of' 'on' 'only' 'option' 'or' 'order' 'ordered' + 'ordering' 'paragraph' 'paragraphs' 'parent' + 'pattern-separator' 'per-mille' 'percent' 'phrase' + 'position' 'preceding' 'preceding-sibling' 'preserve' + 'previous' 'processing-instruction' 'relationship' + 'rename' 'replace' 'return' 'returning' 'revalidation' + 'same' 'satisfies' 'schema' 'schema-attribute' + 'schema-element' 'score' 'self' 'sensitive' 'sentence' + 'sentences' 'skip' 'sliding' 'some' 'stable' 'start' + 'stemming' 'stop' 'strict' 'strip' 'structured-item' + 'switch' 'text' 'then' 'thesaurus' 'times' 'to' + 'treat' 'try' 'tumbling' 'type' 'typeswitch' 'union' + 'unique' 'unordered' 'updating' 'uppercase' 'using' + 'validate' 'value' 'variable' 'version' 'weight' + 'when' 'where' 'while' 'wildcards' 'window' 'with' + 'without' 'word' 'words' 'xquery' 'zero-digit' +'*' << Wildcard '*'^OccurrenceIndicator +EQName^Token + << 'after' 'ancestor' 'ancestor-or-self' 'and' 'as' 'ascending' 'attribute' 'before' 'case' 'cast' 'castable' 'child' 'collation' 'comment' 'copy' 'count' 'declare' 'default' 'delete' 'descendant' 'descendant-or-self' 'descending' 'div' 'document' 'document-node' 'element' 'else' 'empty' 'empty-sequence' 'end' 'eq' 'every' 'except' 'first' 'following' 'following-sibling' 'for' 'function' 'ge' 'group' 'gt' 'idiv' 'if' 'import' 'insert' 'instance' 'intersect' 'into' 'is' 'item' 'last' 'le' 'let' 'lt' 'mod' 'modify' 'module' 'namespace' 'namespace-node' 'ne' 'node' 'only' 'or' 'order' 'ordered' 'parent' 'preceding' 'preceding-sibling' 'processing-instruction' 'rename' 'replace' 'return' 'satisfies' 'schema-attribute' 'schema-element' 'self' 'some' 'stable' 'start' 'switch' 'text' 'to' 'treat' 'try' 'typeswitch' 'union' 'unordered' 'validate' 'where' 'with' 'xquery' 'contains' 'paragraphs' 'sentences' 'times' 'words' 'by' 'collection' 'allowing' 'at' 'base-uri' 'boundary-space' 'break' 'catch' 'construction' 'context' 'continue' 'copy-namespaces' 'decimal-format' 'encoding' 'exit' 'external' 'ft-option' 'in' 'index' 'integrity' 'lax' 'nodes' 'option' 'ordering' 'revalidation' 'schema' 'score' 'sliding' 'strict' 'tumbling' 'type' 'updating' 'value' 'variable' 'version' 'while' 'constraint' 'loop' 'returning' 'append' 'array' 'json-item' 'object' 'structured-item' +NCName^Token + << 'after' 'and' 'as' 'ascending' 'before' 'case' 'cast' 'castable' 'collation' 'count' 'default' 'descending' 'div' 'else' 'empty' 'end' 'eq' 'except' 'for' 'ge' 'group' 'gt' 'idiv' 'instance' 'intersect' 'into' 'is' 'le' 'let' 'lt' 'mod' 'modify' 'ne' 'only' 'or' 'order' 'return' 'satisfies' 'stable' 'start' 'to' 'treat' 'union' 'where' 'with' 'contains' 'paragraphs' 'sentences' 'times' 'words' 'by' 'ancestor' 'ancestor-or-self' 'attribute' 'child' 'comment' 'copy' 'declare' 'delete' 'descendant' 'descendant-or-self' 'document' 'document-node' 'element' 'empty-sequence' 'every' 'first' 'following' 'following-sibling' 'function' 'if' 'import' 'insert' 'item' 'last' 'module' 'namespace' 'namespace-node' 'node' 'ordered' 'parent' 'preceding' 'preceding-sibling' 'processing-instruction' 'rename' 'replace' 'schema-attribute' 'schema-element' 'self' 'some' 'switch' 'text' 'try' 'typeswitch' 'unordered' 'validate' 'variable' 'xquery' 'allowing' 'at' 'base-uri' 'boundary-space' 'break' 'catch' 'construction' 'context' 'continue' 'copy-namespaces' 'decimal-format' 'encoding' 'exit' 'external' 'ft-option' 'in' 'index' 'integrity' 'lax' 'nodes' 'option' 'ordering' 'revalidation' 'schema' 'score' 'sliding' 'strict' 'tumbling' 'type' 'updating' 'value' 'version' 'while' 'constraint' 'loop' 'returning' + + + + diff --git a/lib/ace/mode/xquery/XQueryParser.js b/lib/ace/mode/xquery/XQueryParser.js index af38b6b9..ea17b428 100644 --- a/lib/ace/mode/xquery/XQueryParser.js +++ b/lib/ace/mode/xquery/XQueryParser.js @@ -1,40 +1,45 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Distributed under the BSD license: - * - * Copyright (c) 2010, Ajax.org B.V. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Ajax.org B.V. nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * ***** END LICENSE BLOCK ***** */ - -define(function(require, exports, module){ +// This file was generated on Wed Dec 12, 2012 12:21 (UTC+01) by REx v5.20 which is Copyright (c) 1979-2012 by Gunther Rademacher +// REx command line: XQueryParser.ebnf -ll 2 -backtrack -tree -javascript -a xqlint -var XQueryParser = exports.XQueryParser = function XQueryParser(string, parsingEventHandler) -{ - init(string, parsingEventHandler); + // line 2 "XQueryParser.ebnf" + /* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Ajax.org B.V. nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ***** END LICENSE BLOCK ***** */ - function ParseException(b, e, s, o, x) + define(function(require, exports, module){ + var XQueryParser = exports.XQueryParser = function XQueryParser(string, parsingEventHandler) + { + init(string, parsingEventHandler); + // line 40 "XQueryParser.js" + var self = this; + + this.ParseException = function(b, e, s, o, x) { var begin = b, @@ -53,7 +58,7 @@ var XQueryParser = exports.XQueryParser = function XQueryParser(string, parsingE { return offending < 0 ? "lexical analysis failed" : "syntax error"; }; - } + }; function init(string, parsingEventHandler) { @@ -75,7 +80,7 @@ var XQueryParser = exports.XQueryParser = function XQueryParser(string, parsingE l2 = 0; end = e; ex = -1; - memo = new Object; + memo = {}; eventHandler.reset(input); } @@ -106,7 +111,7 @@ var XQueryParser = exports.XQueryParser = function XQueryParser(string, parsingE var prefix = input.substring(0, e.getBegin()); var lines = prefix.split("\n"); var line = lines.length; - var column = e.getBegin() - lines[line - 1].length + 1; + var column = lines[line - 1].length + 1; var size = e.getEnd() - e.getBegin(); return e.getMessage() + (found == null ? "" : ", found " + found) @@ -122,23 +127,23 @@ var XQueryParser = exports.XQueryParser = function XQueryParser(string, parsingE this.parse_XQuery = function() { eventHandler.startNonterminal("XQuery", e0); - lookahead1W(267); // Wildcard | EQName^Token | IntegerLiteral | DecimalLiteral | DoubleLiteral | + lookahead1W(272); // Wildcard | EQName^Token | IntegerLiteral | DecimalLiteral | DoubleLiteral | // StringLiteral | S^WS | EOF | '$' | '%' | '(' | '(#' | '(:' | '+' | '-' | '.' | // '..' | '/' | '//' | '<' | '", + next: "start" }, { - token : "comment", - regex : "(?:[^\\]]|\\](?!\\]>))+" - } ], + token: "comment", + regex: ".+" + }], - comment : [ { - token : "comment", - regex : ".*?-->", - next : "start" + "apos-string": [{ + token: "string", + regex: ".*'", + next: "start" }, { - token: "comment", - regex : ".*:\\)", - next : "start" + token: "string", + regex: ".*" + }], + + "quot-string": [{ + token: "string", + regex: '.*"', + next: "start" }, { - token : "comment", - regex : ".+" - } ] + token: "string", + regex: ".*" + }], + + "apos-attr": [{ + token: "string", + regex: ".*'", + next: "tag" + }, { + token: "string", + regex: ".*" + }], + + "quot-attr": [{ + token: "string", + regex: '.*"', + next: "tag" + }, { + token: "string", + regex: ".*" + }] }; }; diff --git a/lib/ace/mode/xquery_worker.js b/lib/ace/mode/xquery_worker.js index 863a06e3..0e61791c 100644 --- a/lib/ace/mode/xquery_worker.js +++ b/lib/ace/mode/xquery_worker.js @@ -35,7 +35,7 @@ var oop = require("../lib/oop"); var Mirror = require("../worker/mirror").Mirror; var JSONParseTreeHandler = require("./xquery/JSONParseTreeHandler").JSONParseTreeHandler; var XQueryParser = require("./xquery/XQueryParser").XQueryParser; -var SyntaxHighlighter = require("../mode/xquery/visitors/SyntaxHighlighter").SyntaxHighlighter; +var SyntaxHighlighter = require("./xquery/visitors/SyntaxHighlighter").SyntaxHighlighter; var XQueryWorker = exports.XQueryWorker = function(sender) { Mirror.call(this, sender); @@ -49,28 +49,32 @@ oop.inherits(XQueryWorker, Mirror); this.onUpdate = function() { this.sender.emit("start"); var value = this.doc.getValue(); - var h = new JSONParseTreeHandler(); + var h = new JSONParseTreeHandler(value); var parser = new XQueryParser(value, h); try { parser.parse_XQuery(); - var ast = h.getParseTree(); this.sender.emit("ok"); - var highlighter = new SyntaxHighlighter(value, ast); + var ast = h.getParseTree(); + var highlighter = new SyntaxHighlighter(ast); var tokens = highlighter.getTokens(); this.sender.emit("highlight", tokens); } catch(e) { - var prefix = value.substring(0, e.getBegin()); - var line = prefix.split("\n").length; - var column = e.getBegin() - prefix.lastIndexOf("\n"); - var message = parser.getErrorMessage(e); - this.sender.emit("error", { - row: line - 1, - column: column, - text: message, - type: "error" - }); + if(e instanceof parser.ParseException) { + var prefix = value.substring(0, e.getBegin()); + var line = prefix.split("\n").length; + var column = e.getBegin() - prefix.lastIndexOf("\n"); + var message = parser.getErrorMessage(e); + this.sender.emit("error", { + row: line - 1, + column: column, + text: message, + type: "error" + }); + } else { + throw e; + } } - }; + }; }).call(XQueryWorker.prototype);