Update XQLint version

This commit is contained in:
William Candillon 2014-03-25 19:54:42 +01:00 committed by nightwing
commit 8645e67f42
16 changed files with 87496 additions and 45056 deletions

View file

@ -32,7 +32,7 @@ define(function(require, exports, module) {
var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
var JSONiqLexer = require("./xquery/JSONiqLexer").JSONiqLexer;
var JSONiqLexer = require("./xquery/jsoniq_lexer").JSONiqLexer;
var Range = require("../range").Range;
var XQueryBehaviour = require("./behaviour/xquery").XQueryBehaviour;
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
@ -100,6 +100,101 @@ oop.inherits(Mode, TextMode);
doc.replace(range, outdent ? line.match(re)[1] : "(:" + line + ":)");
}
};
this.createWorker = function(session) {
var worker = new WorkerClient(["ace"], "ace/mode/xquery_worker", "XQueryWorker");
var that = this;
worker.attachToDocument(session.getDocument());
worker.on("ok", function(e) {
session.clearAnnotations();
});
worker.on("markers", function(e) {
session.clearAnnotations();
that.addMarkers(e.data, session);
});
worker.on("highlight", function(tokens) {
that.$tokenizer.tokens = tokens.data.tokens;
that.$tokenizer.lines = session.getDocument().getAllLines();
var rows = Object.keys(that.$tokenizer.tokens);
for(var i=0; i < rows.length; i++) {
var row = parseInt(rows[i]);
delete session.bgTokenizer.lines[row];
delete session.bgTokenizer.states[row];
session.bgTokenizer.fireUpdateEvent(row, row);
}
});
return worker;
};
this.removeMarkers = function(session) {
var markers = session.getMarkers(false);
for (var id in markers) {
// All language analysis' markers are prefixed with language_highlight
if (markers[id].clazz.indexOf('language_highlight_') === 0) {
session.removeMarker(id);
}
}
for (var i = 0; i < session.markerAnchors.length; i++) {
session.markerAnchors[i].detach();
}
session.markerAnchors = [];
};
this.addMarkers = function(annos, mySession) {
var _self = this;
if (!mySession.markerAnchors) mySession.markerAnchors = [];
this.removeMarkers(mySession);
mySession.languageAnnos = [];
annos.forEach(function(anno) {
// Certain annotations can temporarily be disabled
//if (_self.disabledMarkerTypes[anno.type])
// return;
// Multi-line markers are not supported, and typically are a result from a bad error recover, ignore
//if(anno.pos.el && anno.pos.sl !== anno.pos.el)
// return;
// Using anchors here, to automaticaly move markers as text around the marker is updated
var anchor = new Anchor(mySession.getDocument(), anno.pos.sl, anno.pos.sc || 0);
mySession.markerAnchors.push(anchor);
var markerId;
var colDiff = anno.pos.ec - anno.pos.sc;
var rowDiff = anno.pos.el - anno.pos.sl;
var gutterAnno = {
guttertext: anno.message,
type: anno.level || "warning",
text: anno.message
// row will be filled in updateFloat()
};
function updateFloat(single) {
if (markerId)
mySession.removeMarker(markerId);
gutterAnno.row = anchor.row;
if (anno.pos.sc !== undefined && anno.pos.ec !== undefined) {
var range = new Range(anno.pos.sl, anno.pos.sc, anno.pos.el, anno.pos.ec);
//var range = Range.fromPoints(anchor.getPosition(), {
// row: anchor.row + rowDiff,
// column: anchor.column + colDiff
//});
markerId = mySession.addMarker(range, "language_highlight_" + (anno.type ? anno.type : "default"));
}
if (single) mySession.setAnnotations(mySession.languageAnnos);
}
updateFloat();
anchor.on("change", function() {
updateFloat(true);
});
if (anno.message) mySession.languageAnnos.push(gutterAnno);
});
mySession.setAnnotations(mySession.languageAnnos);
};
this.$id = "ace/mode/jsoniq";
}).call(Mode.prototype);

View file

@ -33,11 +33,11 @@ define(function(require, exports, module) {
var WorkerClient = require("../worker/worker_client").WorkerClient;
var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
var XQueryLexer = require("./xquery/XQueryLexer").XQueryLexer;
var XQueryLexer = require("./xquery/xquery_lexer").XQueryLexer;
var Range = require("../range").Range;
var XQueryBehaviour = require("./behaviour/xquery").XQueryBehaviour;
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
var Anchor = require("../anchor").Anchor;
var Mode = function() {
this.$tokenizer = new XQueryLexer();
@ -109,14 +109,15 @@ oop.inherits(Mode, TextMode);
worker.attachToDocument(session.getDocument());
worker.on("error", function(e) {
session.setAnnotations([e.data]);
});
worker.on("ok", function(e) {
session.clearAnnotations();
});
worker.on("markers", function(e) {
session.clearAnnotations();
that.addMarkers(e.data, session);
});
worker.on("highlight", function(tokens) {
that.$tokenizer.tokens = tokens.data.tokens;
that.$tokenizer.lines = session.getDocument().getAllLines();
@ -132,7 +133,70 @@ oop.inherits(Mode, TextMode);
return worker;
};
this.removeMarkers = function(session) {
var markers = session.getMarkers(false);
for (var id in markers) {
// All language analysis' markers are prefixed with language_highlight
if (markers[id].clazz.indexOf('language_highlight_') === 0) {
session.removeMarker(id);
}
}
for (var i = 0; i < session.markerAnchors.length; i++) {
session.markerAnchors[i].detach();
}
session.markerAnchors = [];
};
this.addMarkers = function(annos, mySession) {
var _self = this;
if (!mySession.markerAnchors) mySession.markerAnchors = [];
this.removeMarkers(mySession);
mySession.languageAnnos = [];
annos.forEach(function(anno) {
// Certain annotations can temporarily be disabled
//if (_self.disabledMarkerTypes[anno.type])
// return;
// Multi-line markers are not supported, and typically are a result from a bad error recover, ignore
//if(anno.pos.el && anno.pos.sl !== anno.pos.el)
// return;
// Using anchors here, to automaticaly move markers as text around the marker is updated
var anchor = new Anchor(mySession.getDocument(), anno.pos.sl, anno.pos.sc || 0);
mySession.markerAnchors.push(anchor);
var markerId;
var colDiff = anno.pos.ec - anno.pos.sc;
var rowDiff = anno.pos.el - anno.pos.sl;
var gutterAnno = {
guttertext: anno.message,
type: anno.level || "warning",
text: anno.message
// row will be filled in updateFloat()
};
function updateFloat(single) {
if (markerId)
mySession.removeMarker(markerId);
gutterAnno.row = anchor.row;
if (anno.pos.sc !== undefined && anno.pos.ec !== undefined) {
var range = new Range(anno.pos.sl, anno.pos.sc, anno.pos.el, anno.pos.ec);
//var range = Range.fromPoints(anchor.getPosition(), {
// row: anchor.row + rowDiff,
// column: anchor.column + colDiff
//});
markerId = mySession.addMarker(range, "language_highlight_" + (anno.type ? anno.type : "default"));
}
if (single) mySession.setAnnotations(mySession.languageAnnos);
}
updateFloat();
anchor.on("change", function() {
updateFloat(true);
});
if (anno.message) mySession.languageAnnos.push(gutterAnno);
});
mySession.setAnnotations(mySession.languageAnnos);
};
this.$id = "ace/mode/xquery";
}).call(Mode.prototype);

View file

@ -1,178 +0,0 @@
/* ***** 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 JSONParseTreeHandler = exports.JSONParseTreeHandler = function(code) {
//List of nodes that are not targeted by the parse tree size optimization.
var list = [
"OrExpr", "AndExpr", "ComparisonExpr", "StringConcatExpr", "RangeExpr"
//, "AdditiveExpr", "MultiplicativeExpr"
, "UnionExpr", "IntersectExceptExpr", "InstanceofExpr", "TreatExpr", "CastableExpr"
, "CastExpr", "UnaryExpr", "ValueExpr", "FTContainsExpr", "SimpleMapExpr", "PathExpr", "RelativePathExpr"
, "PostfixExpr", "StepExpr"
];
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(){
if(ptr.children.length > 0) {
var s = ptr.children[0];
var e = null;
//We want to skip empty non terminals. For instance PredicateList:
// [108] AxisStep ::= (ReverseStep | ForwardStep) PredicateList
// [120] PredicateList ::= Predicate*
for(var i= ptr.children.length - 1; i >= 0;i--) {
e = ptr.children[i];
if(e.pos.el !== 0 || e.pos.ec !== 0) {
break;
}
}
ptr.pos.sl = s.pos.sl;
ptr.pos.sc = s.pos.sc;
ptr.pos.el = e.pos.el;
ptr.pos.ec = e.pos.ec;
}
//Normalize EQName && FunctionName
if(ptr.name === "FunctionName") {
ptr.name = "EQName";
}
if(ptr.name === "EQName" && ptr.value === undefined) {
ptr.value = ptr.children[0].value;
ptr.children.pop();
}
if(ptr.getParent !== null) {
ptr = ptr.getParent;
//for(var i in ptr.children) {
//delete ptr.children[i].getParent;
//}
} else {
//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 && list.indexOf(lastChild.name) !== -1) {
ptr.children[ptr.children.length - 1] = lastChild.children[0];
}
}
}
this.closeParseTree = function() {
while(ptr.getParent !== null) {
popNode();
}
popNode();
};
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();
};
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();
};
this.whitespace = function(begin, end) {
var name = "WS";
pushNode(name, begin);
setValue(ptr, begin, end);
popNode();
};
function setValue(node, begin, end) {
var e = end - cursor;
ptr.value = remains.substring(0, e);
remains = remains.substring(e);
cursor = end;
var sl = line;
var sc = lineCursor;
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 + 1).length;
// ec = ec === 0 ? 0 : ec - 1;
line = el;
//lineCursor = ec === 0 ? 0 : ec;
lineCursor = ec;
ptr.pos.sl = sl;
ptr.pos.sc = sc;
ptr.pos.el = el;
ptr.pos.ec = ec;
}
};
});

View file

@ -1,302 +0,0 @@
/* ***** 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 JSONiqTokenizer = require("./JSONiqTokenizer").JSONiqTokenizer;
var TokenHandler = function(code) {
var input = code;
this.tokens = [];
this.reset = function(code) {
input = input;
this.tokens = [];
};
this.startNonterminal = function(name, begin) {};
this.endNonterminal = function(name, end) {};
this.terminal = function(name, begin, end) {
this.tokens.push({
name: name,
value: input.substring(begin, end)
});
};
this.whitespace = function(begin, end) {
this.tokens.push({
name: "WS",
value: input.substring(begin, end)
});
};
};
var keys = "NaN|after|allowing|ancestor|ancestor-or-self|and|append|array|as|ascending|at|attribute|base-uri|before|boundary-space|break|by|case|cast|castable|catch|child|collation|comment|constraint|construction|contains|context|continue|copy|copy-namespaces|count|decimal-format|decimal-separator|declare|default|delete|descendant|descendant-or-self|descending|digit|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|greatest|group|grouping-separator|gt|idiv|if|import|in|index|infinity|insert|instance|integrity|intersect|into|is|item|json|json-item|jsoniq|last|lax|le|least|let|loop|lt|minus-sign|mod|modify|module|namespace|namespace-node|ne|next|node|nodes|not|null|object|of|only|option|or|order|ordered|ordering|paragraphs|parent|pattern-separator|per-mille|percent|preceding|preceding-sibling|previous|processing-instruction|rename|replace|return|returning|revalidation|satisfies|schema|schema-attribute|schema-element|score|select|self|sentences|sliding|some|stable|start|strict|switch|text|then|times|to|treat|true|try|tumbling|type|typeswitch|union|unordered|updating|validate|value|variable|version|when|where|while|window|with|words|xquery|zero-digit".split("|");
var keywords = keys.map(
function(val) { return { name: "'" + val + "'", token: "keyword" }; }
);
var ncnames = keys.map(
function(val) { return { name: "'" + val + "'", token: "text", next: function(stack){ stack.pop(); } }; }
);
var cdata = "constant.language";
var number = "constant";
var xmlcomment = "comment";
var pi = "xml-pe";
var pragma = "constant.buildin";
var Rules = {
start: [
{ name: "'(#'", token: pragma, next: function(stack){ stack.push("Pragma"); } },
{ name: "'(:'", token: "comment", next: function(stack){ stack.push("Comment"); } },
{ name: "'(:~'", token: "comment.doc", next: function(stack){ stack.push("CommentDoc"); } },
{ name: "'<!--'", token: xmlcomment, next: function(stack){ stack.push("XMLComment"); } },
{ name: "'<?'", token: pi, next: function(stack) { stack.push("PI"); } },
{ name: "''''", token: "string", next: function(stack){ stack.push("AposString"); } },
{ name: "'\"'", token: "string", next: function(stack){ stack.push("QuotString"); } },
{ name: "Annotation", token: "support.function" },
{ name: "ModuleDecl", token: "keyword", next: function(stack){ stack.push("Prefix"); } },
{ name: "OptionDecl", token: "keyword", next: function(stack){ stack.push("_EQName"); } },
{ name: "AttrTest", token: "support.type" },
{ name: "Variable", token: "variable" },
{ name: "'<![CDATA['", token: cdata, next: function(stack){ stack.push("CData"); } },
{ name: "IntegerLiteral", token: number },
{ name: "DecimalLiteral", token: number },
{ name: "DoubleLiteral", token: number },
{ name: "Operator", token: "keyword.operator" },
{ name: "EQName", token: function(val) { return keys.indexOf(val) !== -1 ? "keyword" : "support.function"; } },
{ name: "'('", token:"lparen" },
{ name: "')'", token:"rparen" },
{ name: "Tag", token: "meta.tag", next: function(stack){ stack.push("StartTag"); } },
{ name: "'}'", token: "text", next: function(stack){ if(stack.length > 1) stack.pop(); } },
{ name: "'{'", token: "text", next: function(stack){ stack.push("start"); } } //, next: function(stack){ if(stack.length > 1) { stack.pop(); } } }
].concat(keywords),
_EQName: [
{ name: "EQName", token: "text", next: function(stack) { stack.pop(); } }
].concat(ncnames),
Prefix: [
{ name: "NCName", token: "text", next: function(stack) { stack.pop(); } }
].concat(ncnames),
StartTag: [
{ name: "'>'", token: "meta.tag", next: function(stack){ stack.push("TagContent"); } },
{ name: "QName", token: "entity.other.attribute-name" },
{ name: "'='", token: "text" },
{ name: "''''", token: "string", next: function(stack){ stack.push("AposAttr"); } },
{ name: "'\"'", token: "string", next: function(stack){ stack.push("QuotAttr"); } },
{ name: "'/>'", token: "meta.tag.r", next: function(stack){ stack.pop(); } }
],
TagContent: [
{ name: "ElementContentChar", token: "text" },
{ name: "'<![CDATA['", token: cdata, next: function(stack){ stack.push("CData"); } },
{ name: "'<!--'", token: xmlcomment, next: function(stack){ stack.push("XMLComment"); } },
{ name: "Tag", token: "meta.tag", next: function(stack){ stack.push("StartTag"); } },
{ name: "PredefinedEntityRef", token: "constant.language.escape" },
{ name: "CharRef", token: "constant.language.escape" },
{ name: "'{{'", token: "text" },
{ name: "'}}'", token: "text" },
{ name: "'{'", token: "text", next: function(stack){ stack.push("start"); } },
{ name: "EndTag", token: "meta.tag", next: function(stack){ stack.pop(); stack.pop(); } }
],
AposAttr: [
{ name: "''''", token: "string", next: function(stack){ stack.pop(); } },
{ name: "EscapeApos", token: "constant.language.escape" },
{ name: "AposAttrContentChar", token: "string" },
{ name: "PredefinedEntityRef", token: "constant.language.escape" },
{ name: "CharRef", token: "constant.language.escape" },
{ name: "'{{'", token: "string" },
{ name: "'}}'", token: "string" },
{ name: "'{'", token: "text", next: function(stack){ stack.push("start"); } }
],
QuotAttr: [
{ name: "'\"'", token: "string", next: function(stack){ stack.pop(); } },
{ name: "EscapeQuot", token: "constant.language.escape" },
{ name: "QuotAttrContentChar", token: "string" },
{ name: "PredefinedEntityRef", token: "constant.language.escape" },
{ name: "CharRef", token: "constant.language.escape" },
{ name: "'{{'", token: "string" },
{ name: "'}}'", token: "string" },
{ name: "'{'", token: "text", next: function(stack){ stack.push("start"); } }
],
Pragma: [
{ name: "PragmaContents", token: pragma },
{ name: "'#'", token: pragma },
{ name: "'#)'", token: pragma, next: function(stack){ stack.pop(); } }
],
Comment: [
{ name: "CommentContents", token: "comment" },
{ name: "'(:'", token: "comment", next: function(stack){ stack.push("Comment"); } },
{ name: "':)'", token: "comment", next: function(stack){ stack.pop(); } }
],
CommentDoc: [
{ name: "DocCommentContents", token: "comment.doc" },
{ name: "DocTag", token: "comment.doc.tag" },
{ name: "'(:'", token: "comment.doc", next: function(stack){ stack.push("CommentDoc"); } },
{ name: "':)'", token: "comment.doc", next: function(stack){ stack.pop(); } }
],
XMLComment: [
{ name: "DirCommentContents", token: xmlcomment },
{ name: "'-->'", token: xmlcomment, next: function(stack){ stack.pop(); } }
],
CData: [
{ name: "CDataSectionContents", token: cdata },
{ name: "']]>'", token: cdata, next: function(stack){ stack.pop(); } }
],
PI: [
{ name: "DirPIContents", token: pi },
{ name: "'?'", token: pi },
{ name: "'?>'", token: pi, next: function(stack){ stack.pop(); } }
],
AposString: [
{ name: "''''", token: "string", next: function(stack){ stack.pop(); } },
{ name: "PredefinedEntityRef", token: "constant.language.escape" },
{ name: "CharRef", token: "constant.language.escape" },
{ name: "EscapeApos", token: "constant.language.escape" },
{ name: "AposChar", token: "string" }
],
QuotString: [
{ name: "'\"'", token: "string", next: function(stack){ stack.pop(); } },
{ name: "PredefinedEntityRef", token: "constant.language.escape" },
{ name: "CharRef", token: "constant.language.escape" },
{ name: "EscapeQuot", token: "constant.language.escape" },
{ name: "QuotChar", token: "string" }
]
};
exports.JSONiqLexer = function() {
this.tokens = [];
this.getLineTokens = function(line, state, row) {
state = (state === "start" || !state) ? '["start"]' : state;
var stack = JSON.parse(state);
var h = new TokenHandler(line);
var tokenizer = new JSONiqTokenizer(line, h);
var tokens = [];
while(true) {
var currentState = stack[stack.length - 1];
try {
h.tokens = [];
tokenizer["parse_" + currentState]();
var info = null;
if(h.tokens.length > 1 && h.tokens[0].name === "WS") {
tokens.push({
type: "text",
value: h.tokens[0].value
});
h.tokens.splice(0, 1);
}
var token = h.tokens[0];
var rules = Rules[currentState];
for(var k = 0; k < rules.length; k++) {
var rule = Rules[currentState][k];
if((typeof(rule.name) === "function" && rule.name(token)) || rule.name === token.name) {
info = rule;
break;
}
}
if(token.name === "EOF") { break; }
if(token.value === "") { throw "Encountered empty string lexical rule."; }
tokens.push({
type: info === null ? "text" : (typeof(info.token) === "function" ? info.token(token.value) : info.token),
value: token.value
});
if(info && info.next) {
info.next(stack);
}
} catch(e) {
if(e instanceof tokenizer.ParseException) {
var index = 0;
for(var i=0; i < tokens.length; i++) {
index += tokens[i].value.length;
}
tokens.push({ type: "text", value: line.substring(index) });
return {
tokens: tokens,
state: JSON.stringify(["start"])
};
} else {
throw e;
}
}
}
if(this.tokens[row] !== undefined) {
var cachedLine = this.lines[row];
var begin = sharedStart([line, cachedLine]);
var diff = cachedLine.length - line.length;
var idx = 0;
var col = 0;
for(var i = 0; i < tokens.length; i++) {
var token = tokens[i];
for(var j = 0; j < this.tokens[row].length; j++) {
var semanticToken = this.tokens[row][j];
if(
((col + token.value.length) <= begin.length && semanticToken.sc === col && semanticToken.ec === (col + token.value.length)) ||
(semanticToken.sc === (col + diff) && semanticToken.ec === (col + token.value.length + diff))
) {
idx = i;
tokens[i].type = semanticToken.type;
}
}
col += token.value.length;
}
}
return {
tokens: tokens,
state: JSON.stringify(stack)
};
};
function sharedStart(A) {
var tem1, tem2, s, A = A.slice(0).sort();
tem1 = A[0];
s = tem1.length;
tem2 = A.pop();
while(s && tem2.indexOf(tem1) == -1) {
tem1 = tem1.substring(0, --s);
}
return tem1;
}
};
});

View file

@ -1,544 +0,0 @@
<?xqlint
/* ***** 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 JSONiqTokenizer = exports.JSONiqTokenizer = function JSONiqTokenizer(string, parsingEventHandler)
{
init(string, parsingEventHandler);
?>
start ::= '<![CDATA['
| '<!--'
| '<?'
| '(#'
| '(:~'
| '(:'
| '"'
| "'"
| "}"
| "{"
| "("
| ")"
| "/"
| "["
| "]"
| ","
| "."
| ";"
| ":"
| "!"
| "|"
| Annotation
| ModuleDecl
| OptionDecl
| AttrTest
| Wildcard
| IntegerLiteral
| DecimalLiteral
| DoubleLiteral
| Variable
| EQName
| Tag
| Operator
| EOF
StartTag ::= '>' | '/>' | QName | "=" | '"' | "'" | EOF
TagContent
::= ElementContentChar | Tag | EndTag | '<![CDATA[' | '<!--' | PredefinedEntityRef | CharRef | '{{' | '}}' | '{' | EOF
/* ws: explicit */
AposAttr
::= EscapeApos | AposAttrContentChar | PredefinedEntityRef | CharRef | '{{' | '}}' | '{' | "'" | EOF
/* ws: explicit */
QuotAttr
::= EscapeQuot | QuotAttrContentChar | PredefinedEntityRef | CharRef | '{{' | '}}' | '{' | '"' | EOF
/* ws: explicit */
CData ::= CDataSectionContents | ']]>' | EOF
/* ws: explicit */
XMLComment
::= DirCommentContents | '-->' | EOF
/* ws: explicit */
PI ::= DirPIContents | '?' | '?>' | EOF
/* ws: explicit */
Pragma ::= PragmaContents | '#' | '#)' | EOF
/* ws: explicit */
Comment ::= ':)' | '(:' | CommentContents | EOF
/* ws: explicit */
CommentDoc
::= DocTag | DocCommentContents | ':)' | '(:' | EOF
/* ws: explicit */
QuotString
::= PredefinedEntityRef | CharRef | EscapeQuot | QuotChar | '"' | EOF
/* ws: explicit */
AposString
::= PredefinedEntityRef | CharRef | EscapeApos | AposChar | "'" | EOF
/* ws: explicit */
Prefix ::= NCName
_EQName ::= EQName
Whitespace
::= S^WS
/* 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'
<?TOKENS?>
ModuleDecl
::= ('import' S)? ('module' | 'schema') S 'namespace'
Annotation
::= '%' EQName ?
OptionDecl
::= 'declare' S ( ( 'decimal-format' | 'option' )
| ('default' S 'decimal-format') )
Operator ::= '!=' | ':=' | '>=' | '<=' | '=' | '<' | '>' | '-' | '+' | 'div' | '||' | '?'
Variable ::= '$' EQName
Tag ::= '<' QName
EndTag ::= '</' QName S? '>'
PragmaContents
::= ( Char* - ( Char* '#' Char* ) )+
DirCommentContents
::= ( ( Char - '-' ) | '-' ( Char - '-' ) )+
DirPIContents
::= ( Char* - ( Char* '?' Char* ) )+
CDataSectionContents
::= ( Char+ - ( Char* ']]>' Char* ) ) & ']]'
| ( Char+ - ( Char* ']]>' Char* ) ) & $
AttrTest ::= "@" ( Wildcard | QName )
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 */
PredefinedEntityRef
::= '&' ( 'lt' | 'gt' | 'amp' | 'quot' | 'apos' ) ';'
/* ws: explicit */
EscapeQuot
::= '""'
EscapeApos
::= "''"
QuotChar ::= (Char - ["&])+
AposChar ::= (Char - [&'])+
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+ - ( Char* ( '(:' | ':)' ) Char* ) ) - ( Char* '(' ) ) & ':'
DocTag ::= ' @' NCName?
DocCommentContents
::= ( ( Char+ - ( Char* ( '(:' | ':)' | ' @' ) Char* ) ) - ( Char* '(' ) ) & ':'
| ( Char+ - ( Char* ( '(:' | ':)' | ' @' ) 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'
<?ENCORE?>
<?xqlint
});
?>

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1 @@
WARNING!
============================
Files in this folder are generated automatically from the xquery.js project (https://github.com/wcandillon/xquery.js).
Instructions on how to generate the XQuery parser are available at https://github.com/wcandillon/xquery.js
This files are build from [xqlint](https://github.com/wcandillon/xqlint) (using the `grunt ace_build`)

View file

@ -1,303 +0,0 @@
/* ***** 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 XQueryTokenizer = require("./XQueryTokenizer").XQueryTokenizer;
var TokenHandler = function(code) {
var input = code;
this.tokens = [];
this.reset = function(code) {
input = input;
this.tokens = [];
};
this.startNonterminal = function(name, begin) {};
this.endNonterminal = function(name, end) {};
this.terminal = function(name, begin, end) {
this.tokens.push({
name: name,
value: input.substring(begin, end)
});
};
this.whitespace = function(begin, end) {
this.tokens.push({
name: "WS",
value: input.substring(begin, end)
});
};
};
var keys = "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|collectionreturn|variable|version|option|when|encoding|toswitch|catch|tumbling|sliding|window|at|using|stemming|collection|schema|while|on|nodes|index|external|then|in|updating|value|of|containsbreak|loop|continue|exit|returning|append|json|position|strict".split("|");
var keywords = keys.map(
function(val) { return { name: "'" + val + "'", token: "keyword" }; }
);
var ncnames = keys.map(
function(val) { return { name: "'" + val + "'", token: "text", next: function(stack){ stack.pop(); } }; }
);
var cdata = "constant.language";
var number = "constant";
var xmlcomment = "comment";
var pi = "xml-pe";
var pragma = "constant.buildin";
var Rules = {
start: [
{ name: "'(#'", token: pragma, next: function(stack){ stack.push("Pragma"); } },
{ name: "'(:'", token: "comment", next: function(stack){ stack.push("Comment"); } },
{ name: "'(:~'", token: "comment.doc", next: function(stack){ stack.push("CommentDoc"); } },
{ name: "'<!--'", token: xmlcomment, next: function(stack){ stack.push("XMLComment"); } },
{ name: "'<?'", token: pi, next: function(stack) { stack.push("PI"); } },
{ name: "''''", token: "string", next: function(stack){ stack.push("AposString"); } },
{ name: "'\"'", token: "string", next: function(stack){ stack.push("QuotString"); } },
{ name: "Annotation", token: "support.function" },
{ name: "ModuleDecl", token: "keyword", next: function(stack){ stack.push("Prefix"); } },
{ name: "OptionDecl", token: "keyword", next: function(stack){ stack.push("_EQName"); } },
{ name: "AttrTest", token: "support.type" },
{ name: "Variable", token: "variable" },
{ name: "'<![CDATA['", token: cdata, next: function(stack){ stack.push("CData"); } },
{ name: "IntegerLiteral", token: number },
{ name: "DecimalLiteral", token: number },
{ name: "DoubleLiteral", token: number },
{ name: "Operator", token: "keyword.operator" },
{ name: "EQName", token: function(val) { return keys.indexOf(val) !== -1 ? "keyword" : "support.function"; } },
{ name: "'('", token:"lparen" },
{ name: "')'", token:"rparen" },
{ name: "Tag", token: "meta.tag", next: function(stack){ stack.push("StartTag"); } },
{ name: "'}'", token: "text", next: function(stack){ if(stack.length > 1) stack.pop(); } },
{ name: "'{'", token: "text", next: function(stack){ stack.push("start"); } } //, next: function(stack){ if(stack.length > 1) { stack.pop(); } } }
].concat(keywords),
_EQName: [
{ name: "EQName", token: "text", next: function(stack) { stack.pop(); } }
].concat(ncnames),
Prefix: [
{ name: "NCName", token: "text", next: function(stack) { stack.pop(); } }
].concat(ncnames),
StartTag: [
{ name: "'>'", token: "meta.tag", next: function(stack){ stack.push("TagContent"); } },
{ name: "QName", token: "entity.other.attribute-name" },
{ name: "'='", token: "text" },
{ name: "''''", token: "string", next: function(stack){ stack.push("AposAttr"); } },
{ name: "'\"'", token: "string", next: function(stack){ stack.push("QuotAttr"); } },
{ name: "'/>'", token: "meta.tag.r", next: function(stack){ stack.pop(); } }
],
TagContent: [
{ name: "ElementContentChar", token: "text" },
{ name: "'<![CDATA['", token: cdata, next: function(stack){ stack.push("CData"); } },
{ name: "'<!--'", token: xmlcomment, next: function(stack){ stack.push("XMLComment"); } },
{ name: "Tag", token: "meta.tag", next: function(stack){ stack.push("StartTag"); } },
{ name: "PredefinedEntityRef", token: "constant.language.escape" },
{ name: "CharRef", token: "constant.language.escape" },
{ name: "'{{'", token: "text" },
{ name: "'}}'", token: "text" },
{ name: "'{'", token: "text", next: function(stack){ stack.push("start"); } },
{ name: "EndTag", token: "meta.tag", next: function(stack){ stack.pop(); stack.pop(); } }
],
AposAttr: [
{ name: "''''", token: "string", next: function(stack){ stack.pop(); } },
{ name: "EscapeApos", token: "constant.language.escape" },
{ name: "AposAttrContentChar", token: "string" },
{ name: "PredefinedEntityRef", token: "constant.language.escape" },
{ name: "CharRef", token: "constant.language.escape" },
{ name: "'{{'", token: "string" },
{ name: "'}}'", token: "string" },
{ name: "'{'", token: "text", next: function(stack){ stack.push("start"); } }
],
QuotAttr: [
{ name: "'\"'", token: "string", next: function(stack){ stack.pop(); } },
{ name: "EscapeQuot", token: "constant.language.escape" },
{ name: "QuotAttrContentChar", token: "string" },
{ name: "PredefinedEntityRef", token: "constant.language.escape" },
{ name: "CharRef", token: "constant.language.escape" },
{ name: "'{{'", token: "string" },
{ name: "'}}'", token: "string" },
{ name: "'{'", token: "text", next: function(stack){ stack.push("start"); } }
],
Pragma: [
{ name: "PragmaContents", token: pragma },
{ name: "'#'", token: pragma },
{ name: "'#)'", token: pragma, next: function(stack){ stack.pop(); } }
],
Comment: [
{ name: "CommentContents", token: "comment" },
{ name: "'(:'", token: "comment", next: function(stack){ stack.push("Comment"); } },
{ name: "':)'", token: "comment", next: function(stack){ stack.pop(); } }
],
CommentDoc: [
{ name: "DocCommentContents", token: "comment.doc" },
{ name: "DocTag", token: "comment.doc.tag" },
{ name: "'(:'", token: "comment.doc", next: function(stack){ stack.push("CommentDoc"); } },
{ name: "':)'", token: "comment.doc", next: function(stack){ stack.pop(); } }
],
XMLComment: [
{ name: "DirCommentContents", token: xmlcomment },
{ name: "'-->'", token: xmlcomment, next: function(stack){ stack.pop(); } }
],
CData: [
{ name: "CDataSectionContents", token: cdata },
{ name: "']]>'", token: cdata, next: function(stack){ stack.pop(); } }
],
PI: [
{ name: "DirPIContents", token: pi },
{ name: "'?'", token: pi },
{ name: "'?>'", token: pi, next: function(stack){ stack.pop(); } }
],
AposString: [
{ name: "''''", token: "string", next: function(stack){ stack.pop(); } },
{ name: "PredefinedEntityRef", token: "constant.language.escape" },
{ name: "CharRef", token: "constant.language.escape" },
{ name: "EscapeApos", token: "constant.language.escape" },
{ name: "AposChar", token: "string" }
],
QuotString: [
{ name: "'\"'", token: "string", next: function(stack){ stack.pop(); } },
{ name: "PredefinedEntityRef", token: "constant.language.escape" },
{ name: "CharRef", token: "constant.language.escape" },
{ name: "EscapeQuot", token: "constant.language.escape" },
{ name: "QuotChar", token: "string" }
]
};
exports.XQueryLexer = function() {
this.tokens = [];
this.getLineTokens = function(line, state, row) {
state = (state === "start" || !state) ? '["start"]' : state;
var stack = JSON.parse(state);
var h = new TokenHandler(line);
var tokenizer = new XQueryTokenizer(line, h);
var tokens = [];
while(true) {
var currentState = stack[stack.length - 1];
try {
h.tokens = [];
tokenizer["parse_" + currentState]();
var info = null;
if(h.tokens.length > 1 && h.tokens[0].name === "WS") {
tokens.push({
type: "text",
value: h.tokens[0].value
});
h.tokens.splice(0, 1);
}
var token = h.tokens[0];
var rules = Rules[currentState];
for(var k = 0; k < rules.length; k++) {
var rule = Rules[currentState][k];
if((typeof(rule.name) === "function" && rule.name(token)) || rule.name === token.name) {
info = rule;
break;
}
}
if(token.name === "EOF") { break; }
if(token.value === "") { throw "Encountered empty string lexical rule."; }
tokens.push({
type: info === null ? "text" : (typeof(info.token) === "function" ? info.token(token.value) : info.token),
value: token.value
});
if(info && info.next) {
info.next(stack);
}
} catch(e) {
if(e instanceof tokenizer.ParseException) {
var index = 0;
for(var i=0; i < tokens.length; i++) {
index += tokens[i].value.length;
}
tokens.push({ type: "text", value: line.substring(index) });
return {
tokens: tokens,
state: JSON.stringify(["start"])
};
} else {
throw e;
}
}
}
if(this.tokens[row] !== undefined) {
var cachedLine = this.lines[row];
var begin = sharedStart([line, cachedLine]);
var diff = cachedLine.length - line.length;
var idx = 0;
var col = 0;
for(var i = 0; i < tokens.length; i++) {
var token = tokens[i];
for(var j = 0; j < this.tokens[row].length; j++) {
var semanticToken = this.tokens[row][j];
if(
((col + token.value.length) <= begin.length && semanticToken.sc === col && semanticToken.ec === (col + token.value.length)) ||
(semanticToken.sc === (col + diff) && semanticToken.ec === (col + token.value.length + diff))
) {
idx = i;
tokens[i].type = semanticToken.type;
}
}
col += token.value.length;
}
}
return {
tokens: tokens,
state: JSON.stringify(stack)
};
};
function sharedStart(A) {
var tem1, tem2, s, A = A.slice(0).sort();
tem1 = A[0];
s = tem1.length;
tem2 = A.pop();
while(s && tem2.indexOf(tem1) == -1) {
tem1 = tem1.substring(0, --s);
}
return tem1;
}
};
});

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,543 +0,0 @@
<?xqlint
/* ***** 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 XQueryTokenizer = exports.XQueryTokenizer = function XQueryTokenizer(string, parsingEventHandler)
{
init(string, parsingEventHandler);
?>
start ::= '<![CDATA['
| '<!--'
| '<?'
| '(#'
| '(:~'
| '(:'
| '"'
| "'"
| "}"
| "{"
| "("
| ")"
| "/"
| "["
| "]"
| ","
| "."
| ";"
| ":"
| "!"
| "|"
| Annotation
| ModuleDecl
| OptionDecl
| AttrTest
| Wildcard
| IntegerLiteral
| DecimalLiteral
| DoubleLiteral
| Variable
| EQName
| Tag
| Operator
| EOF
StartTag ::= '>' | '/>' | QName | "=" | '"' | "'" | EOF
TagContent
::= ElementContentChar | Tag | EndTag | '<![CDATA[' | '<!--' | PredefinedEntityRef | CharRef | '{{' | '}}' | '{' | EOF
/* ws: explicit */
AposAttr
::= EscapeApos | AposAttrContentChar | PredefinedEntityRef | CharRef | '{{' | '}}' | '{' | "'" | EOF
/* ws: explicit */
QuotAttr
::= EscapeQuot | QuotAttrContentChar | PredefinedEntityRef | CharRef | '{{' | '}}' | '{' | '"' | EOF
/* ws: explicit */
CData ::= CDataSectionContents | ']]>' | EOF
/* ws: explicit */
XMLComment
::= DirCommentContents | '-->' | EOF
/* ws: explicit */
PI ::= DirPIContents | '?' | '?>' | EOF
/* ws: explicit */
Pragma ::= PragmaContents | '#' | '#)' | EOF
/* ws: explicit */
Comment ::= ':)' | '(:' | CommentContents | EOF
/* ws: explicit */
CommentDoc
::= DocTag | DocCommentContents | ':)' | '(:' | EOF
/* ws: explicit */
QuotString
::= PredefinedEntityRef | CharRef | EscapeQuot | QuotChar | '"' | EOF
/* ws: explicit */
AposString
::= PredefinedEntityRef | CharRef | EscapeApos | AposChar | "'" | EOF
/* ws: explicit */
Prefix ::= NCName
_EQName ::= EQName
Whitespace
::= S^WS
/* 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'
<?TOKENS?>
ModuleDecl
::= ('import' S)? ('module' | 'schema') S 'namespace'
Annotation
::= '%' EQName ?
OptionDecl
::= 'declare' S ( ( 'decimal-format' | 'option' )
| ('default' S 'decimal-format') )
Operator ::= '!=' | ':=' | '>=' | '<=' | '=' | '<' | '>' | '-' | '+' | 'div' | '||' | '?'
Variable ::= '$' EQName
Tag ::= '<' QName
EndTag ::= '</' QName S? '>'
PragmaContents
::= ( Char* - ( Char* '#' Char* ) )+
DirCommentContents
::= ( ( Char - '-' ) | '-' ( Char - '-' ) )+
DirPIContents
::= ( Char* - ( Char* '?' Char* ) )+
CDataSectionContents
::= ( Char+ - ( Char* ']]>' Char* ) ) & ']]'
| ( Char+ - ( Char* ']]>' Char* ) ) & $
AttrTest ::= "@" ( Wildcard | QName )
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 */
PredefinedEntityRef
::= '&' ( 'lt' | 'gt' | 'amp' | 'quot' | 'apos' ) ';'
/* ws: explicit */
EscapeQuot
::= '""'
EscapeApos
::= "''"
QuotChar ::= (Char - ["&])+
AposChar ::= (Char - [&'])+
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+ - ( Char* ( '(:' | ':)' ) Char* ) ) - ( Char* '(' ) ) & ':'
DocTag ::= ' @' NCName?
DocCommentContents
::= ( ( Char+ - ( Char* ( '(:' | ':)' | ' @' ) Char* ) ) - ( Char* '(' ) ) & ':'
| ( Char+ - ( Char* ( '(:' | ':)' | ' @' ) 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'
<?ENCORE?>
<?xqlint
});
?>

File diff suppressed because it is too large Load diff

View file

@ -1,76 +0,0 @@
/* ***** 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 SemanticHighlighter = exports.SemanticHighlighter = function(ast) {
this.tokens = {};
this.getTokens = function() {
this.visit(ast);
return this.tokens;
};
this.EQName = this.NCName = function(node)
{
var row = node.pos.sl;
this.tokens[row] = this.tokens[row] === undefined ? [] : this.tokens[row];
node.pos.type = "support.function";
this.tokens[row].push(node.pos);
return true;
};
this.visit = function(node) {
var name = node.name;
var skip = false;
if (typeof this[name] === "function") skip = this[name](node) === true ? true : false;
if (!skip) {
this.visitChildren(node);
}
};
this.visitChildren = function(node, handler) {
for (var i = 0; i < node.children.length; i++) {
var child = node.children[i];
if (handler !== undefined && typeof handler[child.name] === "function") {
handler[child.name](child);
}
else {
this.visit(child);
}
}
};
};
});

78451
lib/ace/mode/xquery/xqlint.js Normal file

File diff suppressed because it is too large Load diff

View file

@ -33,9 +33,7 @@ define(function(require, exports, module) {
var oop = require("../lib/oop");
var Mirror = require("../worker/mirror").Mirror;
var JSONParseTreeHandler = require("./xquery/JSONParseTreeHandler").JSONParseTreeHandler;
var XQueryParser = require("./xquery/XQueryParser").XQueryParser;
var SemanticHighlighter = require("./xquery/visitors/SemanticHighlighter").SemanticHighlighter;
var XQLint = require("./xquery/xqlint").XQLint;
var XQueryWorker = exports.XQueryWorker = function(sender) {
Mirror.call(this, sender);
@ -49,33 +47,9 @@ oop.inherits(XQueryWorker, Mirror);
this.onUpdate = function() {
this.sender.emit("start");
var value = this.doc.getValue();
var h = new JSONParseTreeHandler(value);
var parser = new XQueryParser(value, h);
try {
parser.parse_XQuery();
this.sender.emit("ok");
var ast = h.getParseTree();
var highlighter = new SemanticHighlighter(ast, value);
var tokens = highlighter.getTokens();
this.sender.emit("highlight", { tokens: tokens, lines: highlighter.lines });
} catch(e) {
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;
}
}
};
var xqlint = new XQLint('test', value);
this.sender.emit("markers", xqlint.getMarkers());
};
}).call(XQueryWorker.prototype);
});