Merge pull request #2111 from wcandillon/patch-3

Update XQLint dependency
This commit is contained in:
Harutyun Amirjanyan 2014-09-20 12:35:08 +04:00
commit 79eda6d2a8
4 changed files with 85801 additions and 85702 deletions

View file

@ -1,7 +1,7 @@
define(function(require, exports, module) { define(function(require, exports, module) {
module.exports = (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({ module.exports = (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({
1:[function(_dereq_,module,exports){ 1:[function(_dereq_,module,exports){
// This file was generated on Sun Mar 23, 2014 21:29 (UTC+01) by REx v5.30 which is Copyright (c) 1979-2014 by Gunther Rademacher <grd@gmx.net> // This file was generated on Thu Jul 24, 2014 15:01 (UTC+01) by REx v5.30 which is Copyright (c) 1979-2014 by Gunther Rademacher <grd@gmx.net>
// REx command line: JSONiqTokenizer.ebnf -ll 2 -backtrack -tree -javascript -a xqlint // REx command line: JSONiqTokenizer.ebnf -ll 2 -backtrack -tree -javascript -a xqlint
// line 2 "JSONiqTokenizer.ebnf" // line 2 "JSONiqTokenizer.ebnf"
@ -4212,33 +4212,7 @@ JSONiqTokenizer.TOKEN =
'use strict'; 'use strict';
var JSONiqTokenizer = _dereq_('./JSONiqTokenizer').JSONiqTokenizer; var JSONiqTokenizer = _dereq_('./JSONiqTokenizer').JSONiqTokenizer;
var Lexer = _dereq_('./lexer').Lexer;
var TokenHandler = function(code) {
var input = code;
this.tokens = [];
this.reset = function() {
input = input;
this.tokens = [];
};
this.startNonterminal = function() {};
this.endNonterminal = function() {};
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 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 keywords = keys.map(function(val) { return { name: '\'' + val + '\'', token: 'keyword' }; });
@ -4368,7 +4342,40 @@ var Rules = {
] ]
}; };
exports.JSONiqLexer = function() { exports.JSONiqLexer = function(){ return new Lexer(JSONiqTokenizer, Rules); };
},
{"./JSONiqTokenizer":1,"./lexer":3}],
3:[function(_dereq_,module,exports){
'use strict';
var TokenHandler = function(code) {
var input = code;
this.tokens = [];
this.reset = function() {
input = input;
this.tokens = [];
};
this.startNonterminal = function() {};
this.endNonterminal = function() {};
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)
});
};
};
exports.Lexer = function(Tokenizer, Rules) {
this.tokens = []; this.tokens = [];
@ -4376,7 +4383,7 @@ exports.JSONiqLexer = function() {
state = (state === 'start' || !state) ? '["start"]' : state; state = (state === 'start' || !state) ? '["start"]' : state;
var stack = JSON.parse(state); var stack = JSON.parse(state);
var h = new TokenHandler(line); var h = new TokenHandler(line);
var tokenizer = new JSONiqTokenizer(line, h); var tokenizer = new Tokenizer(line, h);
var tokens = []; var tokens = [];
while(true) { while(true) {
@ -4440,7 +4447,7 @@ exports.JSONiqLexer = function() {
}; };
}; };
}, },
{"./JSONiqTokenizer":1}]},{},[2]) {}]},{},[2])
(2) (2)
}); });

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
define(function(require, exports, module) { define(function(require, exports, module) {
module.exports = (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({ module.exports = (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({
1:[function(_dereq_,module,exports){ 1:[function(_dereq_,module,exports){
// This file was generated on Sun Mar 23, 2014 21:29 (UTC+01) by REx v5.30 which is Copyright (c) 1979-2014 by Gunther Rademacher <grd@gmx.net> // This file was generated on Thu Jul 24, 2014 15:01 (UTC+01) by REx v5.30 which is Copyright (c) 1979-2014 by Gunther Rademacher <grd@gmx.net>
// REx command line: XQueryTokenizer.ebnf -ll 2 -backtrack -tree -javascript -a xqlint // REx command line: XQueryTokenizer.ebnf -ll 2 -backtrack -tree -javascript -a xqlint
// line 2 "XQueryTokenizer.ebnf" // line 2 "XQueryTokenizer.ebnf"
@ -4178,8 +4178,6 @@ XQueryTokenizer.TOKEN =
2:[function(_dereq_,module,exports){ 2:[function(_dereq_,module,exports){
'use strict'; 'use strict';
var XQueryTokenizer = _dereq_('./XQueryTokenizer').XQueryTokenizer;
var TokenHandler = function(code) { var TokenHandler = function(code) {
var input = code; var input = code;
this.tokens = []; this.tokens = [];
@ -4207,6 +4205,85 @@ var TokenHandler = function(code) {
}; };
}; };
exports.Lexer = function(Tokenizer, Rules) {
this.tokens = [];
this.getLineTokens = function(line, state) {
state = (state === 'start' || !state) ? '["start"]' : state;
var stack = JSON.parse(state);
var h = new TokenHandler(line);
var tokenizer = new Tokenizer(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;
}
}
}
return {
tokens: tokens,
state: JSON.stringify(stack)
};
};
};
},
{}],
3:[function(_dereq_,module,exports){
'use strict';
var XQueryTokenizer = _dereq_('./XQueryTokenizer').XQueryTokenizer;
var Lexer = _dereq_('./lexer').Lexer;
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 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 keywords = keys.map(function(val) { return { name: '\'' + val + '\'', token: 'keyword' }; });
@ -4337,114 +4414,9 @@ var Rules = {
] ]
}; };
exports.XQueryLexer = function() { exports.XQueryLexer = function(){ return new Lexer(XQueryTokenizer, Rules); };
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 t = tokens[i];
for(var j = 0; j < this.tokens[row].length; j++) {
var semanticToken = this.tokens[row][j];
if(
((col + t.value.length) <= begin.length && semanticToken.sc === col && semanticToken.ec === (col + t.value.length)) ||
(semanticToken.sc === (col + diff) && semanticToken.ec === (col + t.value.length + diff))
) {
idx = i;
t.type = semanticToken.type;
}
}
col += t.value.length;
}
}
return {
tokens: tokens,
state: JSON.stringify(stack)
};
};
function sharedStart(A) {
A = A.slice(0).sort();
var tem1, tem2, s;
tem1 = A[0];
s = tem1.length;
tem2 = A.pop();
while(s && tem2.indexOf(tem1) === -1) {
tem1 = tem1.substring(0, --s);
}
return tem1;
}
};
}, },
{"./XQueryTokenizer":1}]},{},[2]) {"./XQueryTokenizer":1,"./lexer":2}]},{},[3])
(2) (3)
}); });

View file

@ -72,7 +72,7 @@ var deps = {
xqlint: { xqlint: {
path: "mode/xquery/xqlint.js", path: "mode/xquery/xqlint.js",
browserify: { browserify: {
npmModule: "git+https://github.com/wcandillon/xqlint.git#0.0.8", npmModule: "git+https://github.com/wcandillon/xqlint.git#master",
path: "xqlint/lib/xqlint.js", path: "xqlint/lib/xqlint.js",
exports: "XQLint" exports: "XQLint"
}, },