Fix bugs in the XQuery parser and lexer.

This commit is contained in:
William Candillon 2012-04-09 19:17:22 +02:00
commit afa970767a
10 changed files with 140065 additions and 133838 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,12 +1,11 @@
// $ANTLR 3.3 Nov 30, 2010 12:50:56 StringLexer.g 2012-04-03 22:00:05
define(function(require, exports, module) {
// $ANTLR 3.3 Nov 30, 2010 12:50:56 xquery/StringLexer.g 2012-04-09 19:06:41
var org = require("./antlr3-all").org;
var XQDTLexer = require("./XQDTLexer").XQDTLexer;
define(function(require, exports, module){
var org = require("./antlr3-all").org;
var XQDTLexer = require("./XQDTLexer").XQDTLexer;
var StringLexer = exports.StringLexer = function(input, state) {
var StringLexer = function(input, state) {
// alternate constructor @todo
// public StringLexer(CharStream input)
// public StringLexer(CharStream input, RecognizerSharedState state) {
@ -154,109 +153,109 @@ org.antlr.lang.augmentObject(StringLexer, {
COUNT: 115,
DECIMAL_FORMAT: 116,
DECIMAL_SEPARATOR: 117,
DETERMINISTIC: 118,
DIGIT: 119,
END: 120,
GROUP: 121,
GROUPING_SEPARATOR: 122,
INFINITY: 123,
MINUS_SIGN: 124,
NAMESPACE_NODE: 125,
NAN: 126,
NEXT: 127,
ONLY: 128,
PATTERN_SEPARATOR: 129,
PERCENT: 130,
PER_MILLE: 131,
PREVIOUS: 132,
SLIDING: 133,
START: 134,
SWITCH: 135,
TRY: 136,
TUMBLING: 137,
TYPE: 138,
WHEN: 139,
WINDOW: 140,
ZERO_DIGIT: 141,
AFTER: 142,
BEFORE: 143,
COPY: 144,
DELETE: 145,
FIRST: 146,
INSERT: 147,
INTO: 148,
LAST: 149,
MODIFY: 150,
NODES: 151,
RENAME: 152,
REPLACE: 153,
REVALIDATION: 154,
SKIP: 155,
UPDATING: 156,
VALUE: 157,
WITH: 158,
ALL: 159,
ANY: 160,
CONTAINS: 161,
CONTENT: 162,
DIACRITICS: 163,
DIFFERENT: 164,
DISTANCE: 165,
ENTIRE: 166,
EXACTLY: 167,
FROM: 168,
FT_OPTION: 169,
FTAND: 170,
FTNOT: 171,
FTOR: 172,
INSENSITIVE: 173,
LANGUAGE: 174,
LEVELS: 175,
LOWERCASE: 176,
MOST: 177,
NO: 178,
NOT: 179,
OCCURS: 180,
PARAGRAPH: 181,
PARAGRAPHS: 182,
PHRASE: 183,
RELATIONSHIP: 184,
SAME: 185,
SCORE: 186,
SENSITIVE: 187,
SENTENCE: 188,
SENTENCES: 189,
STEMMING: 190,
STOP: 191,
THESAURUS: 192,
TIMES: 193,
UPPERCASE: 194,
USING: 195,
WEIGHT: 196,
WILDCARDS: 197,
WITHOUT: 198,
WORD: 199,
WORDS: 200,
BREAK: 201,
CONTINUE: 202,
EXIT: 203,
LOOP: 204,
RETURNING: 205,
WHILE: 206,
CHECK: 207,
COLLECTION: 208,
CONSTRAINT: 209,
FOREACH: 210,
FOREIGN: 211,
INDEX: 212,
INTEGRITY: 213,
KEY: 214,
ON: 215,
UNIQUE: 216,
BINARY: 217,
AMP_ER: 218,
APOS_ER: 219,
QUOT_ER: 220,
DIGIT: 118,
END: 119,
GROUP: 120,
GROUPING_SEPARATOR: 121,
INFINITY: 122,
MINUS_SIGN: 123,
NAMESPACE_NODE: 124,
NAN: 125,
NEXT: 126,
ONLY: 127,
PATTERN_SEPARATOR: 128,
PERCENT: 129,
PER_MILLE: 130,
PREVIOUS: 131,
SLIDING: 132,
START: 133,
SWITCH: 134,
TRY: 135,
TUMBLING: 136,
TYPE: 137,
WHEN: 138,
WINDOW: 139,
ZERO_DIGIT: 140,
AFTER: 141,
BEFORE: 142,
COPY: 143,
DELETE: 144,
FIRST: 145,
INSERT: 146,
INTO: 147,
LAST: 148,
MODIFY: 149,
NODES: 150,
RENAME: 151,
REPLACE: 152,
REVALIDATION: 153,
SKIP: 154,
UPDATING: 155,
VALUE: 156,
WITH: 157,
ALL: 158,
ANY: 159,
CONTAINS: 160,
CONTENT: 161,
DIACRITICS: 162,
DIFFERENT: 163,
DISTANCE: 164,
ENTIRE: 165,
EXACTLY: 166,
FROM: 167,
FT_OPTION: 168,
FTAND: 169,
FTNOT: 170,
FTOR: 171,
INSENSITIVE: 172,
LANGUAGE: 173,
LEVELS: 174,
LOWERCASE: 175,
MOST: 176,
NO: 177,
NOT: 178,
OCCURS: 179,
PARAGRAPH: 180,
PARAGRAPHS: 181,
PHRASE: 182,
RELATIONSHIP: 183,
SAME: 184,
SCORE: 185,
SENSITIVE: 186,
SENTENCE: 187,
SENTENCES: 188,
STEMMING: 189,
STOP: 190,
THESAURUS: 191,
TIMES: 192,
UPPERCASE: 193,
USING: 194,
WEIGHT: 195,
WILDCARDS: 196,
WITHOUT: 197,
WORD: 198,
WORDS: 199,
BREAK: 200,
CONTINUE: 201,
EXIT: 202,
LOOP: 203,
RETURNING: 204,
WHILE: 205,
CHECK: 206,
COLLECTION: 207,
CONSTRAINT: 208,
FOREACH: 209,
FOREIGN: 210,
INDEX: 211,
INTEGRITY: 212,
KEY: 213,
ON: 214,
UNIQUE: 215,
BINARY: 216,
AMP_ER: 217,
APOS_ER: 218,
QUOT_ER: 219,
CONCAT: 220,
LPAREN: 221,
RPAREN: 222,
DOLLAR: 223,
@ -442,109 +441,109 @@ org.antlr.lang.extend(StringLexer, XQDTLexer, {
COUNT : 115,
DECIMAL_FORMAT : 116,
DECIMAL_SEPARATOR : 117,
DETERMINISTIC : 118,
DIGIT : 119,
END : 120,
GROUP : 121,
GROUPING_SEPARATOR : 122,
INFINITY : 123,
MINUS_SIGN : 124,
NAMESPACE_NODE : 125,
NAN : 126,
NEXT : 127,
ONLY : 128,
PATTERN_SEPARATOR : 129,
PERCENT : 130,
PER_MILLE : 131,
PREVIOUS : 132,
SLIDING : 133,
START : 134,
SWITCH : 135,
TRY : 136,
TUMBLING : 137,
TYPE : 138,
WHEN : 139,
WINDOW : 140,
ZERO_DIGIT : 141,
AFTER : 142,
BEFORE : 143,
COPY : 144,
DELETE : 145,
FIRST : 146,
INSERT : 147,
INTO : 148,
LAST : 149,
MODIFY : 150,
NODES : 151,
RENAME : 152,
REPLACE : 153,
REVALIDATION : 154,
SKIP : 155,
UPDATING : 156,
VALUE : 157,
WITH : 158,
ALL : 159,
ANY : 160,
CONTAINS : 161,
CONTENT : 162,
DIACRITICS : 163,
DIFFERENT : 164,
DISTANCE : 165,
ENTIRE : 166,
EXACTLY : 167,
FROM : 168,
FT_OPTION : 169,
FTAND : 170,
FTNOT : 171,
FTOR : 172,
INSENSITIVE : 173,
LANGUAGE : 174,
LEVELS : 175,
LOWERCASE : 176,
MOST : 177,
NO : 178,
NOT : 179,
OCCURS : 180,
PARAGRAPH : 181,
PARAGRAPHS : 182,
PHRASE : 183,
RELATIONSHIP : 184,
SAME : 185,
SCORE : 186,
SENSITIVE : 187,
SENTENCE : 188,
SENTENCES : 189,
STEMMING : 190,
STOP : 191,
THESAURUS : 192,
TIMES : 193,
UPPERCASE : 194,
USING : 195,
WEIGHT : 196,
WILDCARDS : 197,
WITHOUT : 198,
WORD : 199,
WORDS : 200,
BREAK : 201,
CONTINUE : 202,
EXIT : 203,
LOOP : 204,
RETURNING : 205,
WHILE : 206,
CHECK : 207,
COLLECTION : 208,
CONSTRAINT : 209,
FOREACH : 210,
FOREIGN : 211,
INDEX : 212,
INTEGRITY : 213,
KEY : 214,
ON : 215,
UNIQUE : 216,
BINARY : 217,
AMP_ER : 218,
APOS_ER : 219,
QUOT_ER : 220,
DIGIT : 118,
END : 119,
GROUP : 120,
GROUPING_SEPARATOR : 121,
INFINITY : 122,
MINUS_SIGN : 123,
NAMESPACE_NODE : 124,
NAN : 125,
NEXT : 126,
ONLY : 127,
PATTERN_SEPARATOR : 128,
PERCENT : 129,
PER_MILLE : 130,
PREVIOUS : 131,
SLIDING : 132,
START : 133,
SWITCH : 134,
TRY : 135,
TUMBLING : 136,
TYPE : 137,
WHEN : 138,
WINDOW : 139,
ZERO_DIGIT : 140,
AFTER : 141,
BEFORE : 142,
COPY : 143,
DELETE : 144,
FIRST : 145,
INSERT : 146,
INTO : 147,
LAST : 148,
MODIFY : 149,
NODES : 150,
RENAME : 151,
REPLACE : 152,
REVALIDATION : 153,
SKIP : 154,
UPDATING : 155,
VALUE : 156,
WITH : 157,
ALL : 158,
ANY : 159,
CONTAINS : 160,
CONTENT : 161,
DIACRITICS : 162,
DIFFERENT : 163,
DISTANCE : 164,
ENTIRE : 165,
EXACTLY : 166,
FROM : 167,
FT_OPTION : 168,
FTAND : 169,
FTNOT : 170,
FTOR : 171,
INSENSITIVE : 172,
LANGUAGE : 173,
LEVELS : 174,
LOWERCASE : 175,
MOST : 176,
NO : 177,
NOT : 178,
OCCURS : 179,
PARAGRAPH : 180,
PARAGRAPHS : 181,
PHRASE : 182,
RELATIONSHIP : 183,
SAME : 184,
SCORE : 185,
SENSITIVE : 186,
SENTENCE : 187,
SENTENCES : 188,
STEMMING : 189,
STOP : 190,
THESAURUS : 191,
TIMES : 192,
UPPERCASE : 193,
USING : 194,
WEIGHT : 195,
WILDCARDS : 196,
WITHOUT : 197,
WORD : 198,
WORDS : 199,
BREAK : 200,
CONTINUE : 201,
EXIT : 202,
LOOP : 203,
RETURNING : 204,
WHILE : 205,
CHECK : 206,
COLLECTION : 207,
CONSTRAINT : 208,
FOREACH : 209,
FOREIGN : 210,
INDEX : 211,
INTEGRITY : 212,
KEY : 213,
ON : 214,
UNIQUE : 215,
BINARY : 216,
AMP_ER : 217,
APOS_ER : 218,
QUOT_ER : 219,
CONCAT : 220,
LPAREN : 221,
RPAREN : 222,
DOLLAR : 223,
@ -609,7 +608,7 @@ org.antlr.lang.extend(StringLexer, XQDTLexer, {
L_AnyChar : 282,
L_QuotStringLiteralChar : 283,
L_AposStringLiteralChar : 284,
getGrammarFileName: function() { return "StringLexer.g"; }
getGrammarFileName: function() { return "xquery/StringLexer.g"; }
});
org.antlr.lang.augmentObject(StringLexer.prototype, {
// $ANTLR start QUOT
@ -617,8 +616,8 @@ org.antlr.lang.augmentObject(StringLexer.prototype, {
try {
var _type = this.QUOT;
var _channel = org.antlr.runtime.BaseRecognizer.DEFAULT_TOKEN_CHANNEL;
// StringLexer.g:29:6: ({...}? => '\"' )
// StringLexer.g:29:8: {...}? => '\"'
// xquery/StringLexer.g:31:6: ({...}? => '\"' )
// xquery/StringLexer.g:31:8: {...}? => '\"'
if ( !(( this.inQuotStr )) ) {
throw new org.antlr.runtime.FailedPredicateException(this.input, "QUOT", " this.inQuotStr ");
}
@ -640,8 +639,8 @@ org.antlr.lang.augmentObject(StringLexer.prototype, {
try {
var _type = this.APOS;
var _channel = org.antlr.runtime.BaseRecognizer.DEFAULT_TOKEN_CHANNEL;
// StringLexer.g:30:6: ({...}? => '\\'' )
// StringLexer.g:30:8: {...}? => '\\''
// xquery/StringLexer.g:32:6: ({...}? => '\\'' )
// xquery/StringLexer.g:32:8: {...}? => '\\''
if ( !(( this.inAposStr )) ) {
throw new org.antlr.runtime.FailedPredicateException(this.input, "APOS", " this.inAposStr ");
}
@ -663,8 +662,8 @@ org.antlr.lang.augmentObject(StringLexer.prototype, {
try {
var _type = this.ESCAPE_QUOT;
var _channel = org.antlr.runtime.BaseRecognizer.DEFAULT_TOKEN_CHANNEL;
// StringLexer.g:31:13: ({...}? => '\"\"' )
// StringLexer.g:31:15: {...}? => '\"\"'
// xquery/StringLexer.g:33:13: ({...}? => '\"\"' )
// xquery/StringLexer.g:33:15: {...}? => '\"\"'
if ( !(( this.inQuotStr )) ) {
throw new org.antlr.runtime.FailedPredicateException(this.input, "ESCAPE_QUOT", " this.inQuotStr ");
}
@ -686,8 +685,8 @@ org.antlr.lang.augmentObject(StringLexer.prototype, {
try {
var _type = this.ESCAPE_APOS;
var _channel = org.antlr.runtime.BaseRecognizer.DEFAULT_TOKEN_CHANNEL;
// StringLexer.g:32:13: ({...}? => '\\'\\'' )
// StringLexer.g:32:15: {...}? => '\\'\\''
// xquery/StringLexer.g:34:13: ({...}? => '\\'\\'' )
// xquery/StringLexer.g:34:15: {...}? => '\\'\\''
if ( !(( this.inAposStr )) ) {
throw new org.antlr.runtime.FailedPredicateException(this.input, "ESCAPE_APOS", " this.inAposStr ");
}
@ -709,13 +708,13 @@ org.antlr.lang.augmentObject(StringLexer.prototype, {
try {
var _type = this.L_PredefinedEntityRef;
var _channel = org.antlr.runtime.BaseRecognizer.DEFAULT_TOKEN_CHANNEL;
// StringLexer.g:36:2: ({...}? => '&' ( 'lt' | 'gt' | 'apos' | 'quot' | 'amp' ) ';' )
// StringLexer.g:36:4: {...}? => '&' ( 'lt' | 'gt' | 'apos' | 'quot' | 'amp' ) ';'
// xquery/StringLexer.g:38:2: ({...}? => '&' ( 'lt' | 'gt' | 'apos' | 'quot' | 'amp' ) ';' )
// xquery/StringLexer.g:38:4: {...}? => '&' ( 'lt' | 'gt' | 'apos' | 'quot' | 'amp' ) ';'
if ( !(( this.inQuotStr | this.inAposStr )) ) {
throw new org.antlr.runtime.FailedPredicateException(this.input, "L_PredefinedEntityRef", " this.inQuotStr | this.inAposStr ");
}
this.match('&');
// StringLexer.g:36:48: ( 'lt' | 'gt' | 'apos' | 'quot' | 'amp' )
// xquery/StringLexer.g:38:48: ( 'lt' | 'gt' | 'apos' | 'quot' | 'amp' )
var alt1=5;
switch ( this.input.LA(1) ) {
case 'l':
@ -752,35 +751,35 @@ org.antlr.lang.augmentObject(StringLexer.prototype, {
switch (alt1) {
case 1 :
// StringLexer.g:36:49: 'lt'
// xquery/StringLexer.g:38:49: 'lt'
this.match("lt");
break;
case 2 :
// StringLexer.g:36:56: 'gt'
// xquery/StringLexer.g:38:56: 'gt'
this.match("gt");
break;
case 3 :
// StringLexer.g:36:63: 'apos'
// xquery/StringLexer.g:38:63: 'apos'
this.match("apos");
break;
case 4 :
// StringLexer.g:36:72: 'quot'
// xquery/StringLexer.g:38:72: 'quot'
this.match("quot");
break;
case 5 :
// StringLexer.g:36:81: 'amp'
// xquery/StringLexer.g:38:81: 'amp'
this.match("amp");
@ -806,7 +805,7 @@ org.antlr.lang.augmentObject(StringLexer.prototype, {
try {
var _type = this.L_CharRef;
var _channel = org.antlr.runtime.BaseRecognizer.DEFAULT_TOKEN_CHANNEL;
// StringLexer.g:41:2: ({...}? => '&#' ( '0' .. '9' )+ ';' | '&#x' ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' )+ ';' )
// xquery/StringLexer.g:43:2: ({...}? => '&#' ( '0' .. '9' )+ ';' | '&#x' ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' )+ ';' )
var alt4=2;
var LA4_0 = this.input.LA(1);
@ -844,13 +843,13 @@ org.antlr.lang.augmentObject(StringLexer.prototype, {
}
switch (alt4) {
case 1 :
// StringLexer.g:41:4: {...}? => '&#' ( '0' .. '9' )+ ';'
// xquery/StringLexer.g:43:4: {...}? => '&#' ( '0' .. '9' )+ ';'
if ( !(( this.inQuotStr | this.inAposStr )) ) {
throw new org.antlr.runtime.FailedPredicateException(this.input, "L_CharRef", " this.inQuotStr | this.inAposStr ");
}
this.match("&#");
// StringLexer.g:41:49: ( '0' .. '9' )+
// xquery/StringLexer.g:43:49: ( '0' .. '9' )+
var cnt2=0;
loop2:
do {
@ -864,7 +863,7 @@ org.antlr.lang.augmentObject(StringLexer.prototype, {
switch (alt2) {
case 1 :
// StringLexer.g:41:49: '0' .. '9'
// xquery/StringLexer.g:43:49: '0' .. '9'
this.matchRange('0','9');
@ -885,10 +884,10 @@ org.antlr.lang.augmentObject(StringLexer.prototype, {
break;
case 2 :
// StringLexer.g:41:65: '&#x' ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' )+ ';'
// xquery/StringLexer.g:43:65: '&#x' ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' )+ ';'
this.match("&#x");
// StringLexer.g:41:71: ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' )+
// xquery/StringLexer.g:43:71: ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' )+
var cnt3=0;
loop3:
do {
@ -902,7 +901,7 @@ org.antlr.lang.augmentObject(StringLexer.prototype, {
switch (alt3) {
case 1 :
// StringLexer.g:
// xquery/StringLexer.g:
if ( (this.input.LA(1)>='0' && this.input.LA(1)<='9')||(this.input.LA(1)>='A' && this.input.LA(1)<='F')||(this.input.LA(1)>='a' && this.input.LA(1)<='f') ) {
this.input.consume();
@ -945,12 +944,12 @@ org.antlr.lang.augmentObject(StringLexer.prototype, {
try {
var _type = this.L_QuotStringLiteralChar;
var _channel = org.antlr.runtime.BaseRecognizer.DEFAULT_TOKEN_CHANNEL;
// StringLexer.g:45:2: ({...}? => ( '\\u0009' | '\\u000A' | '\\u000D' | '\\u0020' .. '\\u0021' | '\\u0023' .. '\\u0025' | '\\u0027' .. '\\uD7FF' | '\\uE000' .. '\\uFFFD' )+ )
// StringLexer.g:45:4: {...}? => ( '\\u0009' | '\\u000A' | '\\u000D' | '\\u0020' .. '\\u0021' | '\\u0023' .. '\\u0025' | '\\u0027' .. '\\uD7FF' | '\\uE000' .. '\\uFFFD' )+
// xquery/StringLexer.g:47:2: ({...}? => ( '\\u0009' | '\\u000A' | '\\u000D' | '\\u0020' .. '\\u0021' | '\\u0023' .. '\\u0025' | '\\u0027' .. '\\uD7FF' | '\\uE000' .. '\\uFFFD' )+ )
// xquery/StringLexer.g:47:4: {...}? => ( '\\u0009' | '\\u000A' | '\\u000D' | '\\u0020' .. '\\u0021' | '\\u0023' .. '\\u0025' | '\\u0027' .. '\\uD7FF' | '\\uE000' .. '\\uFFFD' )+
if ( !(( this.inQuotStr )) ) {
throw new org.antlr.runtime.FailedPredicateException(this.input, "L_QuotStringLiteralChar", " this.inQuotStr ");
}
// StringLexer.g:46:3: ( '\\u0009' | '\\u000A' | '\\u000D' | '\\u0020' .. '\\u0021' | '\\u0023' .. '\\u0025' | '\\u0027' .. '\\uD7FF' | '\\uE000' .. '\\uFFFD' )+
// xquery/StringLexer.g:48:3: ( '\\u0009' | '\\u000A' | '\\u000D' | '\\u0020' .. '\\u0021' | '\\u0023' .. '\\u0025' | '\\u0027' .. '\\uD7FF' | '\\uE000' .. '\\uFFFD' )+
var cnt5=0;
loop5:
do {
@ -964,7 +963,7 @@ org.antlr.lang.augmentObject(StringLexer.prototype, {
switch (alt5) {
case 1 :
// StringLexer.g:
// xquery/StringLexer.g:
if ( (this.input.LA(1)>='\t' && this.input.LA(1)<='\n')||this.input.LA(1)=='\r'||(this.input.LA(1)>=' ' && this.input.LA(1)<='!')||(this.input.LA(1)>='#' && this.input.LA(1)<='%')||(this.input.LA(1)>='\'' && this.input.LA(1)<='\uD7FF')||(this.input.LA(1)>='\uE000' && this.input.LA(1)<='\uFFFD') ) {
this.input.consume();
@ -1004,12 +1003,12 @@ org.antlr.lang.augmentObject(StringLexer.prototype, {
try {
var _type = this.L_AposStringLiteralChar;
var _channel = org.antlr.runtime.BaseRecognizer.DEFAULT_TOKEN_CHANNEL;
// StringLexer.g:51:2: ({...}? => ( '\\u0009' | '\\u000A' | '\\u000D' | '\\u0020' .. '\\u0025' | '\\u0028' .. '\\uD7FF' | '\\uE000' .. '\\uFFFD' )+ )
// StringLexer.g:51:4: {...}? => ( '\\u0009' | '\\u000A' | '\\u000D' | '\\u0020' .. '\\u0025' | '\\u0028' .. '\\uD7FF' | '\\uE000' .. '\\uFFFD' )+
// xquery/StringLexer.g:53:2: ({...}? => ( '\\u0009' | '\\u000A' | '\\u000D' | '\\u0020' .. '\\u0025' | '\\u0028' .. '\\uD7FF' | '\\uE000' .. '\\uFFFD' )+ )
// xquery/StringLexer.g:53:4: {...}? => ( '\\u0009' | '\\u000A' | '\\u000D' | '\\u0020' .. '\\u0025' | '\\u0028' .. '\\uD7FF' | '\\uE000' .. '\\uFFFD' )+
if ( !(( this.inAposStr )) ) {
throw new org.antlr.runtime.FailedPredicateException(this.input, "L_AposStringLiteralChar", " this.inAposStr ");
}
// StringLexer.g:52:3: ( '\\u0009' | '\\u000A' | '\\u000D' | '\\u0020' .. '\\u0025' | '\\u0028' .. '\\uD7FF' | '\\uE000' .. '\\uFFFD' )+
// xquery/StringLexer.g:54:3: ( '\\u0009' | '\\u000A' | '\\u000D' | '\\u0020' .. '\\u0025' | '\\u0028' .. '\\uD7FF' | '\\uE000' .. '\\uFFFD' )+
var cnt6=0;
loop6:
do {
@ -1023,7 +1022,7 @@ org.antlr.lang.augmentObject(StringLexer.prototype, {
switch (alt6) {
case 1 :
// StringLexer.g:
// xquery/StringLexer.g:
if ( (this.input.LA(1)>='\t' && this.input.LA(1)<='\n')||this.input.LA(1)=='\r'||(this.input.LA(1)>=' ' && this.input.LA(1)<='%')||(this.input.LA(1)>='(' && this.input.LA(1)<='\uD7FF')||(this.input.LA(1)>='\uE000' && this.input.LA(1)<='\uFFFD') ) {
this.input.consume();
@ -1063,12 +1062,12 @@ org.antlr.lang.augmentObject(StringLexer.prototype, {
try {
var _type = this.L_AnyChar;
var _channel = org.antlr.runtime.BaseRecognizer.DEFAULT_TOKEN_CHANNEL;
// StringLexer.g:61:5: ({...}? => ( '\\u0009' | '\\u000A' | '\\u000D' | '\\u0020' .. '\\u0025' | '\\u0027' .. '\\u003B' | '\\u003D' .. '\\u007A' | '\\u007C' | '\\u007E' .. '\\uD7FF' | '\\uE000' .. '\\uFFFD' )+ )
// StringLexer.g:61:9: {...}? => ( '\\u0009' | '\\u000A' | '\\u000D' | '\\u0020' .. '\\u0025' | '\\u0027' .. '\\u003B' | '\\u003D' .. '\\u007A' | '\\u007C' | '\\u007E' .. '\\uD7FF' | '\\uE000' .. '\\uFFFD' )+
// xquery/StringLexer.g:63:5: ({...}? => ( '\\u0009' | '\\u000A' | '\\u000D' | '\\u0020' .. '\\u0025' | '\\u0027' .. '\\u003B' | '\\u003D' .. '\\u007A' | '\\u007C' | '\\u007E' .. '\\uD7FF' | '\\uE000' .. '\\uFFFD' )+ )
// xquery/StringLexer.g:63:9: {...}? => ( '\\u0009' | '\\u000A' | '\\u000D' | '\\u0020' .. '\\u0025' | '\\u0027' .. '\\u003B' | '\\u003D' .. '\\u007A' | '\\u007C' | '\\u007E' .. '\\uD7FF' | '\\uE000' .. '\\uFFFD' )+
if ( !(( !this.inQuotStr && !this.inAposStr )) ) {
throw new org.antlr.runtime.FailedPredicateException(this.input, "L_AnyChar", " !this.inQuotStr && !this.inAposStr ");
}
// StringLexer.g:62:9: ( '\\u0009' | '\\u000A' | '\\u000D' | '\\u0020' .. '\\u0025' | '\\u0027' .. '\\u003B' | '\\u003D' .. '\\u007A' | '\\u007C' | '\\u007E' .. '\\uD7FF' | '\\uE000' .. '\\uFFFD' )+
// xquery/StringLexer.g:64:9: ( '\\u0009' | '\\u000A' | '\\u000D' | '\\u0020' .. '\\u0025' | '\\u0027' .. '\\u003B' | '\\u003D' .. '\\u007A' | '\\u007C' | '\\u007E' .. '\\uD7FF' | '\\uE000' .. '\\uFFFD' )+
var cnt7=0;
loop7:
do {
@ -1082,7 +1081,7 @@ org.antlr.lang.augmentObject(StringLexer.prototype, {
switch (alt7) {
case 1 :
// StringLexer.g:
// xquery/StringLexer.g:
if ( (this.input.LA(1)>='\t' && this.input.LA(1)<='\n')||this.input.LA(1)=='\r'||(this.input.LA(1)>=' ' && this.input.LA(1)<='%')||(this.input.LA(1)>='\'' && this.input.LA(1)<=';')||(this.input.LA(1)>='=' && this.input.LA(1)<='z')||this.input.LA(1)=='|'||(this.input.LA(1)>='~' && this.input.LA(1)<='\uD7FF')||(this.input.LA(1)>='\uE000' && this.input.LA(1)<='\uFFFD') ) {
this.input.consume();
@ -1118,60 +1117,60 @@ org.antlr.lang.augmentObject(StringLexer.prototype, {
// $ANTLR end "L_AnyChar",
mTokens: function() {
// StringLexer.g:1:8: ( QUOT | APOS | ESCAPE_QUOT | ESCAPE_APOS | L_PredefinedEntityRef | L_CharRef | L_QuotStringLiteralChar | L_AposStringLiteralChar | L_AnyChar )
// xquery/StringLexer.g:1:8: ( QUOT | APOS | ESCAPE_QUOT | ESCAPE_APOS | L_PredefinedEntityRef | L_CharRef | L_QuotStringLiteralChar | L_AposStringLiteralChar | L_AnyChar )
var alt8=9;
alt8 = this.dfa8.predict(this.input);
switch (alt8) {
case 1 :
// StringLexer.g:1:10: QUOT
// xquery/StringLexer.g:1:10: QUOT
this.mQUOT();
break;
case 2 :
// StringLexer.g:1:15: APOS
// xquery/StringLexer.g:1:15: APOS
this.mAPOS();
break;
case 3 :
// StringLexer.g:1:20: ESCAPE_QUOT
// xquery/StringLexer.g:1:20: ESCAPE_QUOT
this.mESCAPE_QUOT();
break;
case 4 :
// StringLexer.g:1:32: ESCAPE_APOS
// xquery/StringLexer.g:1:32: ESCAPE_APOS
this.mESCAPE_APOS();
break;
case 5 :
// StringLexer.g:1:44: L_PredefinedEntityRef
// xquery/StringLexer.g:1:44: L_PredefinedEntityRef
this.mL_PredefinedEntityRef();
break;
case 6 :
// StringLexer.g:1:66: L_CharRef
// xquery/StringLexer.g:1:66: L_CharRef
this.mL_CharRef();
break;
case 7 :
// StringLexer.g:1:76: L_QuotStringLiteralChar
// xquery/StringLexer.g:1:76: L_QuotStringLiteralChar
this.mL_QuotStringLiteralChar();
break;
case 8 :
// StringLexer.g:1:100: L_AposStringLiteralChar
// xquery/StringLexer.g:1:100: L_AposStringLiteralChar
this.mL_AposStringLiteralChar();
break;
case 9 :
// StringLexer.g:1:124: L_AnyChar
// xquery/StringLexer.g:1:124: L_AnyChar
this.mL_AnyChar();
@ -1648,5 +1647,5 @@ org.antlr.lang.extend(StringLexer.DFA8, org.antlr.runtime.DFA, {
});
})();
});
exports.StringLexer = StringLexer;
});

File diff suppressed because it is too large Load diff

View file

@ -10,9 +10,11 @@ var XQDTLexer = exports.XQDTLexer = function(input, state)
org.antlr.lang.extend(XQDTLexer, org.antlr.runtime.Lexer, {
isWsExplicit: false,
setIsWsExplicit: function (wsExplicit) {
isWsExplicit = wsExplicit;
//console.log("A WS: " + wsExplicit);
this.isWsExplicit = wsExplicit;
//console.log("B WS: " + wsExplicit);
},
addToStack: function (stack) {

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -23,7 +23,6 @@ var NewLazyTokenStream = exports.NewLazyTokenStream = function(tokenSource) {
this.isWsExplicit = false;
this.p = 0;
this.channel = org.antlr.runtime.Token.DEFAULT_CHANNEL;
this.lastMarker = null;
this.LT = function(k) {
if (k == 0)
@ -37,7 +36,8 @@ var NewLazyTokenStream = exports.NewLazyTokenStream = function(tokenSource) {
this.get = function(i) {
if (i >= this.tokens.length)
return org.antlr.runtime.Token.EOF_TOKEN;
return this.tokens[i];
else
return this.tokens[i];
};
this.getTokenSource = function() {
@ -93,8 +93,9 @@ var NewLazyTokenStream = exports.NewLazyTokenStream = function(tokenSource) {
// }
this.consume = function() {
if (this.done)
return;
if (this.done) {
return;
}
this.p++;
if (!this.isWsExplicit) {
this.jumpToFirstValidToken();
@ -118,10 +119,11 @@ var NewLazyTokenStream = exports.NewLazyTokenStream = function(tokenSource) {
};
this.rewind = function(marker) {
if(marker == undefined)
this.seek(this.lastMarker);
else
if(arguments.length == 1) {
this.seek(marker);
} else {
this.seek(this.lastMarker);
}
};
this.seek = function(index) {
@ -136,7 +138,6 @@ var NewLazyTokenStream = exports.NewLazyTokenStream = function(tokenSource) {
this.setTokenSource = function(source) {
this.tokenSource = source;
this.setWsExplicit(source.isWsExplicit);
// un-read the unused tokens
// they are different for the new source
if (this.p < this.tokens.length) {
@ -156,7 +157,7 @@ var NewLazyTokenStream = exports.NewLazyTokenStream = function(tokenSource) {
this.setWsExplicit = function(explicit) {
this.isWsExplicit = explicit;
if (!explicit) {
this.jumpToFirstValidToken();
this.jumpToFirstValidToken();
}
};
@ -178,9 +179,8 @@ var NewLazyTokenStream = exports.NewLazyTokenStream = function(tokenSource) {
t.setTokenIndex(count++);
this.tokens.push(t);
}
if (this.isWsExplicit || t.getChannel() == this.channel) {
i++;
i++;
}
j++;
}
@ -215,7 +215,7 @@ var NewLazyTokenStream = exports.NewLazyTokenStream = function(tokenSource) {
t = this.tokenSource.nextToken();
if (t == org.antlr.runtime.Token.EOF_TOKEN)
return;
t.setTokenIndex(this.p + i);
this.tokens.push(t);
}
@ -3001,6 +3001,7 @@ org.antlr.runtime.ANTLRStringStream.prototype = {
* Consume the next character of data in the stream.
*/
consume: function() {
//console.log("prev p="+ this.p +", c="+ this.data.charAt(this.p));
if ( this.p < this.n ) {
this.charPositionInLine++;
if ( this.data.charAt(this.p)==="\n" ) {
@ -3008,6 +3009,7 @@ org.antlr.runtime.ANTLRStringStream.prototype = {
this.charPositionInLine=0;
}
this.p++;
//console.log("p moves to " + this.p + " (c='"+ this.data.charAt(this.p) +"')");
}
},
@ -4838,6 +4840,25 @@ org.antlr.runtime.BaseRecognizer.prototype = {
* @param {org.antlr.runtime.RecognitionException} e the error to be reported.
*/
reportError: function(e) {
if(this.input.size() != 0) {
var token = this.input.get(e.index);
var errorMessage = "";
var column = 0;
var line = 0;
if(token.getType() == -1) {
token = this.input.get(this.input.size() - 1);
}
errorMessage = this.getErrorMessage(e, this.getTokenNames());
column = token.getStartIndex();
line = token.getLine() - 1;
var error = {
line: line,
message: errorMessage,
column: column
};
this.addError(error);
}
// if we've already reported an error and have not matched a token
// yet successfully, don't report any errors.
if ( this.state.errorRecovery ) {
@ -4881,8 +4902,8 @@ org.antlr.runtime.BaseRecognizer.prototype = {
* @param {String} msg the error message to be displayed.
*/
emitErrorMessage: function(msg) {
throw msg;
//console.log(msg);
//throw msg;
console.log(msg);
},
/** What error message should be generated for the various
@ -5567,11 +5588,11 @@ org.antlr.lang.extend(org.antlr.runtime.Lexer, org.antlr.runtime.BaseRecognizer,
return this.state.token;
}
catch (re) {
if ( re instanceof org.antlr.runtime.RecognitionException ) {
this.reportError(re);
} else if (re instanceof org.antlr.runtime.NoViableAltException) {
if (re instanceof org.antlr.runtime.NoViableAltException) {
this.reportError(re);
this.recover(re);
} else if ( re instanceof org.antlr.runtime.RecognitionException ) {
this.reportError(re);
} else {
throw re;
}

View file

@ -43,14 +43,14 @@ define(function(require, exports, module) {
var XQueryLexer = require("./XQueryLexer").XQueryLexer;
var XQueryParser = require("./XQueryParser").XQueryParser;
exports.parse = function(code) {
var cstream = new org.antlr.runtime.ANTLRStringStream(code);
var lexer = new XQueryLexer(cstream);
var tstream = new NewLazyTokenStream(lexer);
tstream.jumpToFirstValidToken();
var parser = new XQueryParser(tstream);
parser.source = cstream;
parser.stream = tstream;
parser.p_Module();
exports.getParser = function(code) {
var cstream = new org.antlr.runtime.ANTLRStringStream(code);
var lexer = new XQueryLexer(cstream);
var tstream = new NewLazyTokenStream(lexer);
tstream.jumpToFirstValidToken();
var parser = new XQueryParser(tstream);
parser.source = cstream;
parser.stream = tstream;
return parser;
};
});

View file

@ -54,46 +54,26 @@ oop.inherits(XQueryWorker, Mirror);
(function() {
this.onUpdate = function() {
var value = this.doc.getValue();
try {
xquery.parse(value);
} catch(e) {
console.log(e);
var m = e.match(/line (\d+):\-?(\d+) (.*)/);
if (m) {
var line = parseInt(m[1]) - 1;
line = line <= 0 ? 0 : line;
var col = parseInt(m[2]);
console.log("Row: " + line);
console.log("Col: " + col);
this.sender.emit("error", {
row: line,
column: col,
text: m[3],
type: "error"
});
return;
}
/*
if (e instanceof SyntaxError) {
var m = e.message.match(/ on line (\d+)/);
if (m) {
this.sender.emit("error", {
row: parseInt(m[1]) - 1,
column: null,
text: e.message.replace(m[0], ""),
type: "error"
});
}
}
*/
return;
}
this.sender.emit("ok");
};
this.onUpdate = function() {
var value = this.doc.getValue();
var parser = xquery.getParser(value);
var ast = parser.p_Module();
if(parser.hasErrors()) {
var errors = parser.getErrors();
var i = 0;
for(i in errors) {
var error = errors[i];
this.sender.emit("error", {
row: error.line,
column: error.column,
text: error.message,
type: "error"
});
}
return;
}
this.sender.emit("ok");
};
}).call(XQueryWorker.prototype);