// This file was generated on Sat Feb 16, 2013 21:06 (UTC+01) by REx v5.23 which is Copyright (c) 1979-2013 by Gunther Rademacher // REx command line: XQueryParser.ebnf -ll 2 -backtrack -tree -javascript -a xqlint // 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 ***** */ 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, 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; l2 = 0; end = e; ex = -1; memo = {}; eventHandler.reset(input); } this.getOffendingToken = function(e) { var o = e.getOffending(); return o >= 0 ? XQueryParser.TOKEN[o] : null; }; this.getExpectedTokenSet = function(e) { var expected; if (e.getExpected() < 0) { expected = XQueryParser.getTokenSet(- e.getState()); } else { expected = [XQueryParser.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 || found != null ? "" : "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_XQuery = function() { eventHandler.startNonterminal("XQuery", e0); lookahead1W(268); // Wildcard | EQName^Token | IntegerLiteral | DecimalLiteral | DoubleLiteral | // StringLiteral | S^WS | EOF | '$' | '%' | '(' | '(#' | '(:' | '+' | '-' | '.' | // '..' | '/' | '//' | '<' | '' shift(43); // '-->' eventHandler.endNonterminal("DirCommentConstructor", e0); } function try_DirCommentConstructor() { shiftT(55); // '' shiftT(43); // '-->' } function parse_DirPIConstructor() { eventHandler.startNonterminal("DirPIConstructor", e0); shift(59); // '' if (l1 == 21) // S { shift(21); // S lookahead1(2); // DirPIContents shift(3); // DirPIContents } lookahead1(9); // '?>' shift(65); // '?>' eventHandler.endNonterminal("DirPIConstructor", e0); } function try_DirPIConstructor() { shiftT(59); // '' if (l1 == 21) // S { shiftT(21); // S lookahead1(2); // DirPIContents shiftT(3); // DirPIContents } lookahead1(9); // '?>' shiftT(65); // '?>' } function parse_ComputedConstructor() { eventHandler.startNonterminal("ComputedConstructor", e0); switch (l1) { case 119: // 'document' parse_CompDocConstructor(); break; case 121: // 'element' parse_CompElemConstructor(); break; case 82: // 'attribute' parse_CompAttrConstructor(); break; case 184: // 'namespace' parse_CompNamespaceConstructor(); break; case 244: // 'text' parse_CompTextConstructor(); break; case 96: // 'comment' parse_CompCommentConstructor(); break; default: parse_CompPIConstructor(); } eventHandler.endNonterminal("ComputedConstructor", e0); } function try_ComputedConstructor() { switch (l1) { case 119: // 'document' try_CompDocConstructor(); break; case 121: // 'element' try_CompElemConstructor(); break; case 82: // 'attribute' try_CompAttrConstructor(); break; case 184: // 'namespace' try_CompNamespaceConstructor(); break; case 244: // 'text' try_CompTextConstructor(); break; case 96: // 'comment' try_CompCommentConstructor(); break; default: try_CompPIConstructor(); } } function parse_CompElemConstructor() { eventHandler.startNonterminal("CompElemConstructor", e0); shift(121); // 'element' lookahead1W(256); // EQName^Token | S^WS | '(:' | 'after' | 'allowing' | 'ancestor' | // 'ancestor-or-self' | 'and' | 'array' | 'as' | 'ascending' | 'at' | 'attribute' | // 'base-uri' | 'before' | 'boundary-space' | 'break' | 'case' | 'cast' | // 'castable' | 'catch' | 'child' | 'collation' | 'comment' | 'constraint' | // 'construction' | 'context' | 'continue' | 'copy' | 'copy-namespaces' | 'count' | // 'decimal-format' | 'declare' | 'default' | 'delete' | 'descendant' | // 'descendant-or-self' | 'descending' | 'div' | 'document' | 'document-node' | // 'element' | 'else' | 'empty' | 'empty-sequence' | 'encoding' | 'end' | 'eq' | // 'every' | 'except' | 'exit' | 'external' | 'first' | 'following' | // 'following-sibling' | 'for' | 'ft-option' | 'function' | 'ge' | 'group' | 'gt' | // 'idiv' | 'if' | 'import' | 'in' | 'index' | 'insert' | 'instance' | 'integrity' | // 'intersect' | 'into' | 'is' | 'item' | 'json-item' | 'last' | 'lax' | 'le' | // 'let' | 'loop' | 'lt' | 'mod' | 'modify' | 'module' | 'namespace' | // 'namespace-node' | 'ne' | 'node' | 'nodes' | 'object' | 'only' | 'option' | // 'or' | 'order' | 'ordered' | 'ordering' | 'parent' | 'preceding' | // 'preceding-sibling' | 'processing-instruction' | 'rename' | 'replace' | // 'return' | 'returning' | 'revalidation' | 'satisfies' | 'schema' | // 'schema-attribute' | 'schema-element' | 'score' | 'self' | 'sliding' | 'some' | // 'stable' | 'start' | 'strict' | 'switch' | 'text' | 'to' | 'treat' | 'try' | // 'tumbling' | 'type' | 'typeswitch' | 'union' | 'unordered' | 'updating' | // 'validate' | 'value' | 'variable' | 'version' | 'where' | 'while' | 'with' | // 'xquery' | '{' switch (l1) { case 276: // '{' shift(276); // '{' lookahead1W(267); // Wildcard | EQName^Token | IntegerLiteral | DecimalLiteral | DoubleLiteral | // StringLiteral | S^WS | '$' | '%' | '(' | '(#' | '(:' | '+' | '-' | '.' | '..' | // '/' | '//' | '<' | ''", "'.'", "'..'", "'/'", "'//'", "'/>'", "':'", "':)'", "'::'", "':='", "';'", "'<'", "'