From ea532e41bf8e310767bf8ad2d2c02eed675628fb Mon Sep 17 00:00:00 2001 From: William Candillon Date: Sat, 29 Mar 2014 22:25:42 +0100 Subject: [PATCH] Update xqlint with code completion --- lib/ace/mode/xquery.js | 2 +- lib/ace/mode/xquery/xqlint.js | 154462 ++++++++++++++-------------- lib/ace/mode/xquery_worker.js | 19 +- lib/ace/snippets/jsoniq.snippets | 26 +- lib/ace/snippets/xquery.snippets | 26 +- 5 files changed, 77415 insertions(+), 77120 deletions(-) diff --git a/lib/ace/mode/xquery.js b/lib/ace/mode/xquery.js index eccffc37..b93d61d2 100644 --- a/lib/ace/mode/xquery.js +++ b/lib/ace/mode/xquery.js @@ -72,7 +72,7 @@ oop.inherits(Mode, TextMode); if (! /^\s+$/.test(line)) return false; - return /^\s*[\}\)]/.test(input); + return (/^\s*[\}\)]/).test(input); }; this.autoOutdent = function(state, doc, row) { diff --git a/lib/ace/mode/xquery/xqlint.js b/lib/ace/mode/xquery/xqlint.js index 86b10d87..78134267 100644 --- a/lib/ace/mode/xquery/xqlint.js +++ b/lib/ace/mode/xquery/xqlint.js @@ -188,7 +188,7 @@ exports.VarRefHandler = function(translator, sctx, node){ } }; }; -},{"../tree_ops":9,"./errors":1}],3:[function(_dereq_,module,exports){ +},{"../tree_ops":10,"./errors":1}],3:[function(_dereq_,module,exports){ exports.StaticContext = function (parent, pos) { 'use strict'; @@ -265,6 +265,7 @@ exports.StaticContext = function (parent, pos) { var s = { parent: parent, + children: [], pos: pos, setModuleResolver: function(resolver){ this.root.moduleResolver = resolver; @@ -274,6 +275,7 @@ exports.StaticContext = function (parent, pos) { defaultFunctionNamespace: '', defaultElementNamespace: '', namespaces: namespaces, + availableModuleNamespaces: [], importModule: function(uri, prefix, pos) { this.root.addNamespace(uri, prefix, pos, 'module'); if(this.root.moduleResolver) { @@ -287,6 +289,12 @@ exports.StaticContext = function (parent, pos) { } return this; }, + getAvailableModuleNamespaces: function(){ + return this.root.availableModuleNamespaces; + }, + getPrefixByNamespace: function(uri){ + return this.root.namespaces[uri].prefix; + }, addNamespace: function (uri, prefix, pos, type) { if(prefix === '' && type === 'module') { throw new StaticWarning('W01', 'Avoid this type of import. Use import module namespace instead'); @@ -320,6 +328,11 @@ exports.StaticContext = function (parent, pos) { } }, + + getNamespaces: function(){ + return this.root.namespaces; + }, + getNamespace: function (uri) { var that = this; while (that) { @@ -382,7 +395,10 @@ exports.StaticContext = function (parent, pos) { varRefs: {}, addVariable: function(qname, type, pos){ - if(type === 'VarDecl' && qname.uri !== this.moduleNamespace && this.moduleNamespace !== '') { + if( + type === 'VarDecl' && this.moduleNamespace !== '' && + !(this.moduleNamespace === qname.uri || (qname.uri === '' && this.defaultFunctionNamespace === this.moduleNamespace)) + ) { throw new StaticError('XQST0048', '"' + qname.prefix + ':' + qname.name + '": Qname not library namespace', pos); } var key = getVarKey(qname); @@ -397,6 +413,21 @@ exports.StaticContext = function (parent, pos) { return this; }, + getVariables: function(){ + var variables = {}; + var that = this; + var handler = function(key){ + if(!variables[key]){ + variables[key] = that.variables[key]; + } + }; + while(that){ + Object.keys(that.variables).forEach(handler); + that = that.parent; + } + return variables; + }, + getVariable: function(qname) { var key = getVarKey(qname); var that = this; @@ -420,6 +451,10 @@ exports.StaticContext = function (parent, pos) { functions: {}, + getFunctions: function(){ + return this.root.functions; + }, + getFunction: function(qname, arity){ var key = getFnKey(qname, arity); var that = this; @@ -431,8 +466,12 @@ exports.StaticContext = function (parent, pos) { } }, - addFunction: function(qname, arity, pos) { - if(qname.uri !== this.moduleNamespace && this.moduleNamespace !== '') { + addFunction: function(qname, pos, params) { + var arity = params.length; + if( + this.moduleNamespace !== '' && + !(this.moduleNamespace === qname.uri || (qname.uri === '' && this.defaultFunctionNamespace === this.moduleNamespace)) + ) { throw new StaticError('XQST0048', '"' + qname.prefix + ':' + qname.name + '": Qname not library namespace', pos); } var key = getFnKey(qname, arity); @@ -440,7 +479,8 @@ exports.StaticContext = function (parent, pos) { throw new StaticError('XQST0034', '"' + qname.name + '": duplicate function declaration', pos); } this.functions[key] = { - pos: pos + pos: pos, + params: params }; return this; } @@ -449,7 +489,7 @@ exports.StaticContext = function (parent, pos) { s.root = parent ? parent.root : s; return s; }; -},{"../tree_ops":9,"./errors":1}],4:[function(_dereq_,module,exports){ +},{"../tree_ops":10,"./errors":1}],4:[function(_dereq_,module,exports){ exports.Translator = function(rootStcx, ast){ 'use strict'; @@ -461,20 +501,6 @@ exports.Translator = function(rootStcx, ast){ var StaticContext = _dereq_('./static_context').StaticContext; var Handlers = _dereq_('./handlers'); - var astAsXML = function(node, indent){ - var result = ''; - indent = indent ? indent : ''; - if(node.value) { - result += (indent + '<' + node.name + '>' + node.value + '\n'); - } - result += indent + '<' + node.name + '>\n'; - node.children.forEach(function(child){ - result += astAsXML(child, indent + ' '); - }); - result += indent + '\n'; - return result; - }; - var get = function(node, path){ var result; if(path.length === 0){ @@ -527,12 +553,11 @@ exports.Translator = function(rootStcx, ast){ var translator = this; - rootStcx = rootStcx ? rootStcx : new StaticContext(); rootStcx.pos = ast.pos; var sctx = rootStcx; - var pushSctx = function(pos){ sctx = new StaticContext(sctx, pos); + sctx.parent.children.push(sctx); }; var popSctx = function(pos){ @@ -540,6 +565,7 @@ exports.Translator = function(rootStcx, ast){ sctx.pos.el = pos.el; sctx.pos.ec = pos.ec; } + Object.keys(sctx.varRefs).forEach(function(key){ if(!sctx.variables[key]) { sctx.parent.varRefs[key] = true; @@ -593,7 +619,7 @@ exports.Translator = function(rootStcx, ast){ } }); } else if(node.name === 'FunctionDecl') { - var qname, arity = 0, pos; + var qname, pos, params = []; node.children.forEach(function(child){ if(child.name === 'EQName') { qname = child; @@ -601,7 +627,7 @@ exports.Translator = function(rootStcx, ast){ } else if(child.name === 'ParamList'){ child.children.forEach(function(c){ if(c.name === 'Param') { - arity++; + params.push(TreeOps.flatten(c)); } }); } @@ -609,7 +635,7 @@ exports.Translator = function(rootStcx, ast){ translator.apply(function(){ qname = TreeOps.flatten(qname); qname = rootStcx.resolveQName(qname, pos); - rootStcx.addFunction(qname, arity, pos); + rootStcx.addFunction(qname, pos, params); }); } }); @@ -954,7 +980,212 @@ exports.Translator = function(rootStcx, ast){ }); }; -},{"../tree_ops":9,"./errors":1,"./handlers":2,"./static_context":3}],5:[function(_dereq_,module,exports){ +},{"../tree_ops":10,"./errors":1,"./handlers":2,"./static_context":3}],5:[function(_dereq_,module,exports){ +'use strict'; + +var TreeOps = _dereq_('../tree_ops').TreeOps; + +var ID_REGEX = /[a-zA-Z_0-9\$]/; + +function retrievePrecedingIdentifier(text, pos, regex) { + console.log(text); + console.log(pos); + regex = regex || ID_REGEX; + var buf = []; + for (var i = pos-1; i >= 0; i--) { + if (regex.test(text[i])) { + buf.push(text[i]); + } else { + break; + } + } + return buf.reverse().join(''); +} +/* +function retrieveFollowingIdentifier(text, pos, regex) { + regex = regex || ID_REGEX; + var buf = []; + for (var i = pos; i < text.length; i++) { + if (regex.test(text[i])) { + buf.push(text[i]); + } else { + break; + } + } + return buf; +} +*/ +function prefixBinarySearch(items, prefix) { + var startIndex = 0; + var stopIndex = items.length - 1; + var middle = Math.floor((stopIndex + startIndex) / 2); + + while (stopIndex > startIndex && middle >= 0 && items[middle].indexOf(prefix) !== 0) { + if (prefix < items[middle]) { + stopIndex = middle - 1; + } else if (prefix > items[middle]) { + startIndex = middle + 1; + } + middle = Math.floor((stopIndex + stopIndex) / 2); + } + while (middle > 0 && items[middle-1].indexOf(prefix) === 0) { + middle--; + } + return middle >= 0 ? middle : 0; // ensure we're not returning a negative index +} + +var uriRegex = /[a-zA-Z_0-9\/\.:\-#]/; +var char = '-._A-Za-z0-9:\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02ff\u0300-\u037D\u037F-\u1FFF\u200C\u200D\u203f\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD'; +var nameChar = '[' + char + ']'; +//var varChar = '[' + char + '\\$]'; +var nameCharRegExp = new RegExp(nameChar); +//var varCharRegExp = new RegExp(varChar); + +var findCompletions = function(prefix, allIdentifiers) { + allIdentifiers.sort(); + var startIdx = prefixBinarySearch(allIdentifiers, prefix); + var matches = []; + for (var i = startIdx; i < allIdentifiers.length && allIdentifiers[i].indexOf(prefix) === 0; i++) { + matches.push(allIdentifiers[i]); + } + return matches; +}; + + +var completePrefix = function(identifier, pos, sctx){ + var idx = identifier.indexOf(':'); + if(idx === -1) { + var prefixes = []; + var namespaces = sctx.getNamespaces(); + Object.keys(namespaces).forEach(function(key){ + if(namespaces[key].type === 'module') { + prefixes.push(namespaces[key].prefix); + } + }); + var matches = findCompletions(identifier, prefixes); + var match = function(name) { + return { + name: name + ':', + score: 8, + value: name + ':' + }; + }; + return matches.map(match); + } else { + return []; + } +}; + +var completeFunction = function(identifier, pos, sctx){ + var names = []; + var functions = sctx.getFunctions(); + var uri = ''; + var prefix = ''; + var name = identifier; + var idx = identifier.indexOf(':'); + if(idx !== -1){ + prefix = identifier.substring(0, idx); + name = identifier.substring(idx + 1); + uri = sctx.getNamespaceByPrefix(prefix).uri; + } + Object.keys(functions).forEach(function(key){ + var fn = functions[key]; + var ns = key.substring(0, key.indexOf('#')); + var name = key.substring(key.indexOf('#') + 1); + name = name.substring(0, name.indexOf('#')); + if(ns !== ''){ + name = sctx.getNamespaces()[ns].prefix + ':' + name; + } + name += '('; + name += fn.params.join(', '); + name += ')'; + names.push(name); + }); + var matches = findCompletions(identifier, names); + var match = function(name) { + return { + name: name, + score: 4, + value: name + }; + }; + return matches.map(match); +}; + +var completeVariable = function(identifier, pos, sctx){ + var uri = ''; + var prefix = ''; + var idx = identifier.indexOf(':'); + //Does the identifier has a prefix? + if(idx !== -1){ + prefix = identifier.substring(0, idx); + uri = sctx.getNamespaceByPrefix(prefix).uri; + } + var decls = sctx.getVariables(); + var names = []; + Object.keys(decls).forEach(function(key){ + var i = key.indexOf('#'); + var ns = key.substring(0, i); + var name = key.substring(i+1); + if(ns !== ''){ + names.push(sctx.getPrefixByNamespace(ns) + ':' + name); + } else { + names.push(name); + } + }); + + var matches = findCompletions(identifier, names); + var match = function(name) { + return { + name: '$' + name, + score: 4, + value: '$' + name + }; + }; + return matches.map(match); +}; + +var completeExpr = function(line, pos, sctx){ + console.log('line'); + console.log(line); + console.log('='); + var identifier = retrievePrecedingIdentifier(line, pos.col, nameCharRegExp); + var before = line.substring(0, pos.col - (identifier.length === 0 ? 0 : identifier.length)); + var isVar = before[before.length - 1] === '$'; + if(isVar) { + return completeVariable(identifier, pos, sctx); + } else if(identifier !== '') { + return completeFunction(identifier, pos, sctx).concat(completePrefix(identifier, pos, sctx)); + } else { + return completeVariable(identifier, pos, sctx).concat(completeFunction(identifier, pos, sctx)).concat(completePrefix(identifier, pos, sctx)); + } +}; + +var completeModuleUri = function(line, pos, sctx){ + var identifier = retrievePrecedingIdentifier(line, pos.col, uriRegex); + var matches = findCompletions(identifier, sctx.getAvailableModuleNamespaces()); + var match = function(name) { + return { + name: name, + score: 4, + value: name + }; + }; + return matches.map(match); +}; + +exports.complete = function(source, ast, rootSctx, pos){ + var line = source.split('\n')[pos.line]; + var node = TreeOps.findNode(ast, pos); + var sctx = TreeOps.findNode(rootSctx, pos); + sctx = sctx ? sctx : rootSctx; + if(node && node.name === 'URILiteral' && node.getParent && node.getParent.name === 'ModuleImport'){ + return completeModuleUri(line, pos, sctx); + } else { + return completeExpr(line, pos, sctx); + } +}; +},{"../tree_ops":10}],6:[function(_dereq_,module,exports){ exports.StyleChecker = function (ast, source) { 'use strict'; @@ -1081,7 +1312,7 @@ exports.StyleChecker = function (ast, source) { }); this.visit(ast); }; -},{}],6:[function(_dereq_,module,exports){ +},{}],7:[function(_dereq_,module,exports){ //TODO: don't copy string exports.JSONParseTreeHandler = function (code) { 'use strict'; @@ -1246,77058 +1477,77058 @@ exports.JSONParseTreeHandler = function (code) { ptr.pos.ec = ec; } }; -},{}],7:[function(_dereq_,module,exports){ -// This file was generated on Mon Mar 24, 2014 11:18 (UTC+01) by REx v5.30 which is Copyright (c) 1979-2014 by Gunther Rademacher -// REx command line: JSONiqParser.ebnf -ll 2 -backtrack -tree -javascript -a xqlint - - // line 2 "JSONiqParser.ebnf" - var JSONiqParser = exports.JSONiqParser = function JSONiqParser(string, parsingEventHandler) - { - init(string, parsingEventHandler); - // line 9 "JSONiqParser.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 ? JSONiqParser.TOKEN[o] : null; - }; - - this.getExpectedTokenSet = function(e) - { - var expected; - if (e.getExpected() < 0) - { - expected = JSONiqParser.getTokenSet(- e.getState()); - } - else - { - expected = [JSONiqParser.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(279); // EQName^Token | IntegerLiteral | DecimalLiteral | DoubleLiteral | StringLiteral | - // S^WS | EOF | '$' | '$$' | '%' | '(' | '(#' | '(:' | '+' | '-' | '/' | '//' | - // ';' | '<' | '' - shift(44); // '-->' - eventHandler.endNonterminal("DirCommentConstructor", e0); - } - - function try_DirCommentConstructor() - { - shiftT(56); // '' - shiftT(44); // '-->' - } - - function parse_DirPIConstructor() - { - eventHandler.startNonterminal("DirPIConstructor", e0); - shift(60); // '' - if (l1 == 21) // S - { - shift(21); // S - lookahead1(2); // DirPIContents - shift(3); // DirPIContents - } - lookahead1(9); // '?>' - shift(66); // '?>' - eventHandler.endNonterminal("DirPIConstructor", e0); - } - - function try_DirPIConstructor() - { - shiftT(60); // '' - if (l1 == 21) // S - { - shiftT(21); // S - lookahead1(2); // DirPIContents - shiftT(3); // DirPIContents - } - lookahead1(9); // '?>' - shiftT(66); // '?>' - } - - function parse_ComputedConstructor() - { - eventHandler.startNonterminal("ComputedConstructor", e0); - switch (l1) - { - case 120: // 'document' - parse_CompDocConstructor(); - break; - case 122: // 'element' - parse_CompElemConstructor(); - break; - case 83: // 'attribute' - parse_CompAttrConstructor(); - break; - case 187: // 'namespace' - parse_CompNamespaceConstructor(); - break; - case 249: // 'text' - parse_CompTextConstructor(); - break; - case 97: // 'comment' - parse_CompCommentConstructor(); - break; - default: - parse_CompPIConstructor(); - } - eventHandler.endNonterminal("ComputedConstructor", e0); - } - - function try_ComputedConstructor() - { - switch (l1) - { - case 120: // 'document' - try_CompDocConstructor(); - break; - case 122: // 'element' - try_CompElemConstructor(); - break; - case 83: // 'attribute' - try_CompAttrConstructor(); - break; - case 187: // 'namespace' - try_CompNamespaceConstructor(); - break; - case 249: // 'text' - try_CompTextConstructor(); - break; - case 97: // 'comment' - try_CompCommentConstructor(); - break; - default: - try_CompPIConstructor(); - } - } - - function parse_CompElemConstructor() - { - eventHandler.startNonterminal("CompElemConstructor", e0); - shift(122); // 'element' - lookahead1W(251); // EQName^Token | S^WS | '(:' | 'after' | 'allowing' | 'ancestor' | - // 'ancestor-or-self' | 'and' | 'append' | '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' | 'false' | - // 'first' | 'following' | 'following-sibling' | 'for' | 'from' | 'ft-option' | - // 'function' | 'ge' | 'group' | 'gt' | 'idiv' | 'if' | 'import' | 'in' | 'index' | - // 'insert' | 'instance' | 'integrity' | 'intersect' | 'into' | 'is' | 'item' | - // 'json' | 'json-item' | 'jsoniq' | 'last' | 'lax' | 'le' | 'let' | 'loop' | 'lt' | - // 'mod' | 'modify' | 'module' | 'namespace' | 'namespace-node' | 'ne' | 'node' | - // 'nodes' | 'null' | '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' | 'select' | 'self' | 'sliding' | 'some' | 'stable' | 'start' | - // 'strict' | 'structured-item' | 'switch' | 'text' | 'to' | 'treat' | 'true' | - // 'try' | 'tumbling' | 'type' | 'typeswitch' | 'union' | 'unordered' | 'updating' | - // 'validate' | 'value' | 'variable' | 'version' | 'where' | 'while' | 'with' | '{' - switch (l1) - { - case 281: // '{' - shift(281); // '{' - lookahead1W(268); // EQName^Token | IntegerLiteral | DecimalLiteral | DoubleLiteral | StringLiteral | - // S^WS | '$' | '$$' | '%' | '(' | '(#' | '(:' | '+' | '-' | '/' | '//' | '<' | - // ''", - "'.'", - "'..'", - "'/'", - "'//'", - "'/>'", - "':'", - "':)'", - "'::'", - "':='", - "';'", - "'<'", - "'' - 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(258); // EQName^Token | S^WS | '(:' | 'after' | 'allowing' | 'ancestor' | - // 'ancestor-or-self' | 'and' | 'append' | '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' | - // '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' | 'structured-item' | '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 | '$' | '%' | '(' | '(#' | '(:' | '+' | '-' | '.' | '..' | - // '/' | '//' | '<' | ''", - "'.'", - "'..'", - "'/'", - "'//'", - "'/>'", - "':'", - "':)'", - "'::'", - "':='", - "';'", - "'<'", - "'' + shift(44); // '-->' + eventHandler.endNonterminal("DirCommentConstructor", e0); + } + + function try_DirCommentConstructor() + { + shiftT(56); // '' + shiftT(44); // '-->' + } + + function parse_DirPIConstructor() + { + eventHandler.startNonterminal("DirPIConstructor", e0); + shift(60); // '' + if (l1 == 21) // S + { + shift(21); // S + lookahead1(2); // DirPIContents + shift(3); // DirPIContents + } + lookahead1(9); // '?>' + shift(66); // '?>' + eventHandler.endNonterminal("DirPIConstructor", e0); + } + + function try_DirPIConstructor() + { + shiftT(60); // '' + if (l1 == 21) // S + { + shiftT(21); // S + lookahead1(2); // DirPIContents + shiftT(3); // DirPIContents + } + lookahead1(9); // '?>' + shiftT(66); // '?>' + } + + function parse_ComputedConstructor() + { + eventHandler.startNonterminal("ComputedConstructor", e0); + switch (l1) + { + case 120: // 'document' + parse_CompDocConstructor(); + break; + case 122: // 'element' + parse_CompElemConstructor(); + break; + case 83: // 'attribute' + parse_CompAttrConstructor(); + break; + case 187: // 'namespace' + parse_CompNamespaceConstructor(); + break; + case 249: // 'text' + parse_CompTextConstructor(); + break; + case 97: // 'comment' + parse_CompCommentConstructor(); + break; + default: + parse_CompPIConstructor(); + } + eventHandler.endNonterminal("ComputedConstructor", e0); + } + + function try_ComputedConstructor() + { + switch (l1) + { + case 120: // 'document' + try_CompDocConstructor(); + break; + case 122: // 'element' + try_CompElemConstructor(); + break; + case 83: // 'attribute' + try_CompAttrConstructor(); + break; + case 187: // 'namespace' + try_CompNamespaceConstructor(); + break; + case 249: // 'text' + try_CompTextConstructor(); + break; + case 97: // 'comment' + try_CompCommentConstructor(); + break; + default: + try_CompPIConstructor(); + } + } + + function parse_CompElemConstructor() + { + eventHandler.startNonterminal("CompElemConstructor", e0); + shift(122); // 'element' + lookahead1W(251); // EQName^Token | S^WS | '(:' | 'after' | 'allowing' | 'ancestor' | + // 'ancestor-or-self' | 'and' | 'append' | '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' | 'false' | + // 'first' | 'following' | 'following-sibling' | 'for' | 'from' | 'ft-option' | + // 'function' | 'ge' | 'group' | 'gt' | 'idiv' | 'if' | 'import' | 'in' | 'index' | + // 'insert' | 'instance' | 'integrity' | 'intersect' | 'into' | 'is' | 'item' | + // 'json' | 'json-item' | 'jsoniq' | 'last' | 'lax' | 'le' | 'let' | 'loop' | 'lt' | + // 'mod' | 'modify' | 'module' | 'namespace' | 'namespace-node' | 'ne' | 'node' | + // 'nodes' | 'null' | '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' | 'select' | 'self' | 'sliding' | 'some' | 'stable' | 'start' | + // 'strict' | 'structured-item' | 'switch' | 'text' | 'to' | 'treat' | 'true' | + // 'try' | 'tumbling' | 'type' | 'typeswitch' | 'union' | 'unordered' | 'updating' | + // 'validate' | 'value' | 'variable' | 'version' | 'where' | 'while' | 'with' | '{' + switch (l1) + { + case 281: // '{' + shift(281); // '{' + lookahead1W(268); // EQName^Token | IntegerLiteral | DecimalLiteral | DoubleLiteral | StringLiteral | + // S^WS | '$' | '$$' | '%' | '(' | '(#' | '(:' | '+' | '-' | '/' | '//' | '<' | + // ''", + "'.'", + "'..'", + "'/'", + "'//'", + "'/>'", + "':'", + "':)'", + "'::'", + "':='", + "';'", + "'<'", + "'' + 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(258); // EQName^Token | S^WS | '(:' | 'after' | 'allowing' | 'ancestor' | + // 'ancestor-or-self' | 'and' | 'append' | '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' | + // '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' | 'structured-item' | '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 | '$' | '%' | '(' | '(#' | '(:' | '+' | '-' | '.' | '..' | + // '/' | '//' | '<' | ''", + "'.'", + "'..'", + "'/'", + "'//'", + "'/>'", + "':'", + "':)'", + "'::'", + "':='", + "';'", + "'<'", + "'