fix unit tests; all pass

[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 6720]
This commit is contained in:
parrt 2010-02-23 11:36:12 -08:00
parent 2e6aee85af
commit 3872f92017
6 changed files with 128 additions and 125 deletions

View File

@ -1,4 +1,4 @@
// $ANTLR ${project.version} ${buildNumber} ANTLRLexer.g 2010-02-19 17:45:05
// $ANTLR ${project.version} ${buildNumber} ANTLRLexer.g 2010-02-23 11:32:31
/*
[The "BSD licence"]
@ -263,7 +263,7 @@ public class ANTLRLexer extends Lexer {
if ( (( input.LA(2) != '/')) ) {
alt3=1;
}
else if ( (((( true )&&( !(input.LA(1) == '*' && input.LA(2) == '/') ))||( true ))) ) {
else if ( ((( true )||(( true )&&( !(input.LA(1) == '*' && input.LA(2) == '/') )))) ) {
alt3=2;
}
else {

View File

@ -141,8 +141,8 @@ public void displayRecognitionError(String[] tokenNames,
String paraphrase = (String)paraphrases.peek();
msg = msg+" while "+paraphrase;
}
List stack = getRuleInvocationStack(e, this.getClass().getName());
msg += ", rule stack = "+stack;
// List stack = getRuleInvocationStack(e, this.getClass().getName());
// msg += ", rule stack = "+stack;
ErrorManager.syntaxError(ErrorType.SYNTAX_ERROR, getSourceName(), e.token, e, msg);
}
}

View File

@ -1,4 +1,4 @@
// $ANTLR ${project.version} ${buildNumber} ANTLRParser.g 2010-02-20 17:27:09
// $ANTLR ${project.version} ${buildNumber} ANTLRParser.g 2010-02-23 11:32:34
/*
[The "BSD licence"]
@ -178,8 +178,8 @@ public class ANTLRParser extends Parser {
String paraphrase = (String)paraphrases.peek();
msg = msg+" while "+paraphrase;
}
List stack = getRuleInvocationStack(e, this.getClass().getName());
msg += ", rule stack = "+stack;
// List stack = getRuleInvocationStack(e, this.getClass().getName());
// msg += ", rule stack = "+stack;
ErrorManager.syntaxError(ErrorType.SYNTAX_ERROR, getSourceName(), e.token, e, msg);
}
@ -317,7 +317,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: id, prequelConstruct, rules, DOC_COMMENT, grammarType
// elements: rules, id, DOC_COMMENT, grammarType, prequelConstruct
// token labels:
// rule labels: retval
// token list labels:
@ -821,7 +821,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: OPTIONS, option
// elements: option, OPTIONS
// token labels:
// rule labels: retval
// token list labels:
@ -1437,7 +1437,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: TOKENS, tokenSpec
// elements: tokenSpec, TOKENS
// token labels:
// rule labels: retval
// token list labels:
@ -1592,7 +1592,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: ASSIGN, id, STRING_LITERAL
// elements: ASSIGN, STRING_LITERAL, id
// token labels:
// rule labels: retval
// token list labels:
@ -1732,7 +1732,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: id, ACTION, SCOPE
// elements: ACTION, id, SCOPE
// token labels:
// rule labels: retval
// token list labels:
@ -1886,7 +1886,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: AT, id, actionScopeName, ACTION
// elements: ACTION, AT, actionScopeName, id
// token labels:
// rule labels: retval
// token list labels:
@ -2424,7 +2424,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: DOC_COMMENT, ARG_ACTION, rulePrequels, id, ruleReturns, exceptionGroup, ruleBlock, ruleModifiers
// elements: rulePrequels, ruleReturns, ruleModifiers, DOC_COMMENT, id, exceptionGroup, ARG_ACTION, ruleBlock
// token labels:
// rule labels: retval
// token list labels:
@ -2653,7 +2653,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: CATCH, ARG_ACTION, ACTION
// elements: ARG_ACTION, CATCH, ACTION
// token labels:
// rule labels: retval
// token list labels:
@ -2736,7 +2736,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: FINALLY, ACTION
// elements: ACTION, FINALLY
// token labels:
// rule labels: retval
// token list labels:
@ -3300,7 +3300,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: SCOPE, ACTION
// elements: ACTION, SCOPE
// token labels:
// rule labels: retval
// token list labels:
@ -3478,7 +3478,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: AT, ACTION, id
// elements: AT, id, ACTION
// token labels:
// rule labels: retval
// token list labels:
@ -4367,7 +4367,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: labeledElement, ebnfSuffix
// elements: ebnfSuffix, labeledElement
// token labels:
// rule labels: retval
// token list labels:
@ -4706,7 +4706,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: ebnfSuffix, treeSpec
// elements: treeSpec, ebnfSuffix
// token labels:
// rule labels: retval
// token list labels:
@ -5074,7 +5074,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: element, TREE_BEGIN
// elements: TREE_BEGIN, element
// token labels:
// rule labels: retval
// token list labels:
@ -5189,7 +5189,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: blockSuffixe, block
// elements: block, blockSuffixe
// token labels:
// rule labels: retval
// token list labels:
@ -5695,7 +5695,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: DOT, id, ruleref
// elements: ruleref, id, DOT
// token labels:
// rule labels: retval
// token list labels:
@ -5992,7 +5992,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: block, NOT
// elements: NOT, block
// token labels:
// rule labels: retval
// token list labels:
@ -6226,7 +6226,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: altList, ra, optionsSpec
// elements: optionsSpec, ra, altList
// token labels:
// rule labels: retval
// token list labels:
@ -6401,7 +6401,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: RULE_REF, op, ARG_ACTION
// elements: ARG_ACTION, op, RULE_REF
// token labels: op
// rule labels: retval
// token list labels:
@ -6943,7 +6943,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: ROOT, terminal
// elements: terminal, ROOT
// token labels:
// rule labels: retval
// token list labels:
@ -6980,7 +6980,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: BANG, terminal
// elements: terminal, BANG
// token labels:
// rule labels: retval
// token list labels:
@ -7432,7 +7432,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: predicatedRewrite, nakedRewrite
// elements: nakedRewrite, predicatedRewrite
// token labels:
// rule labels: retval
// token list labels:
@ -8062,7 +8062,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: rewriteTree, ebnfSuffix
// elements: ebnfSuffix, rewriteTree
// token labels:
// rule labels: retval
// token list labels:
@ -8301,7 +8301,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: ARG_ACTION, TOKEN_REF, elementOptions
// elements: ARG_ACTION, elementOptions, TOKEN_REF
// token labels:
// rule labels: retval
// token list labels:
@ -8385,7 +8385,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: elementOptions, STRING_LITERAL
// elements: STRING_LITERAL, elementOptions
// token labels:
// rule labels: retval
// token list labels:
@ -8679,7 +8679,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: rewriteTreeElement, TREE_BEGIN, rewriteTreeAtom
// elements: rewriteTreeAtom, rewriteTreeElement, TREE_BEGIN
// token labels:
// rule labels: retval
// token list labels:
@ -8983,7 +8983,7 @@ public class ANTLRParser extends Parser {
// AST REWRITE
// elements: rewriteTemplateArgs, id
// elements: id, rewriteTemplateArgs
// token labels:
// rule labels: retval
// token list labels:

View File

@ -1,4 +1,4 @@
// $ANTLR ${project.version} ${buildNumber} ASTVerifier.g 2010-02-19 17:45:08
// $ANTLR ${project.version} ${buildNumber} ASTVerifier.g 2010-02-23 11:32:35
/*
[The "BSD license"]

View File

@ -1,4 +1,4 @@
// $ANTLR ${project.version} ${buildNumber} ActionSplitter.g 2010-02-19 17:45:08
// $ANTLR ${project.version} ${buildNumber} ActionSplitter.g 2010-02-23 11:32:34
package org.antlr.v4.parse;
@ -2175,6 +2175,20 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer {
state.failed=false;
return success;
}
public final boolean synpred12_ActionSplitter() {
state.backtracking++;
int start = input.mark();
try {
synpred12_ActionSplitter_fragment(); // can never throw exception
} catch (RecognitionException re) {
System.err.println("impossible: "+re);
}
boolean success = !state.failed;
input.rewind(start);
state.backtracking--;
state.failed=false;
return success;
}
public final boolean synpred17_ActionSplitter() {
state.backtracking++;
int start = input.mark();
@ -2203,20 +2217,6 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer {
state.failed=false;
return success;
}
public final boolean synpred12_ActionSplitter() {
state.backtracking++;
int start = input.mark();
try {
synpred12_ActionSplitter_fragment(); // can never throw exception
} catch (RecognitionException re) {
System.err.println("impossible: "+re);
}
boolean success = !state.failed;
input.rewind(start);
state.backtracking--;
state.failed=false;
return success;
}
public final boolean synpred9_ActionSplitter() {
state.backtracking++;
int start = input.mark();
@ -2301,11 +2301,11 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer {
state.failed=false;
return success;
}
public final boolean synpred18_ActionSplitter() {
public final boolean synpred1_ActionSplitter() {
state.backtracking++;
int start = input.mark();
try {
synpred18_ActionSplitter_fragment(); // can never throw exception
synpred1_ActionSplitter_fragment(); // can never throw exception
} catch (RecognitionException re) {
System.err.println("impossible: "+re);
}
@ -2315,11 +2315,11 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer {
state.failed=false;
return success;
}
public final boolean synpred1_ActionSplitter() {
public final boolean synpred18_ActionSplitter() {
state.backtracking++;
int start = input.mark();
try {
synpred1_ActionSplitter_fragment(); // can never throw exception
synpred18_ActionSplitter_fragment(); // can never throw exception
} catch (RecognitionException re) {
System.err.println("impossible: "+re);
}
@ -2491,36 +2491,28 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer {
}
}
static final String DFA29_eotS =
"\31\uffff";
"\32\uffff";
static final String DFA29_eofS =
"\31\uffff";
"\32\uffff";
static final String DFA29_minS =
"\1\0\1\uffff\1\0\12\uffff\1\0\2\uffff\1\0\6\uffff\1\0\1\uffff";
"\2\0\2\uffff\1\0\3\uffff\1\0\6\uffff\1\0\12\uffff";
static final String DFA29_maxS =
"\1\uffff\1\uffff\1\0\12\uffff\1\0\2\uffff\1\0\6\uffff\1\0\1\uffff";
"\1\uffff\1\0\2\uffff\1\0\3\uffff\1\0\6\uffff\1\0\12\uffff";
static final String DFA29_acceptS =
"\1\uffff\1\24\1\uffff\1\4\1\5\1\6\1\7\1\10\1\11\1\12\1\13\1\14\1"+
"\15\1\uffff\1\1\1\2\1\uffff\1\16\1\17\1\20\1\21\1\22\1\23\1\uffff"+
"\1\3";
"\2\uffff\1\3\1\24\1\uffff\1\1\1\2\1\24\1\uffff\1\16\1\17\1\20\1"+
"\21\1\22\1\23\1\uffff\1\4\1\5\1\6\1\7\1\10\1\11\1\12\1\13\1\14\1"+
"\15";
static final String DFA29_specialS =
"\1\0\1\uffff\1\1\12\uffff\1\2\2\uffff\1\3\6\uffff\1\4\1\uffff}>";
"\1\0\1\1\2\uffff\1\2\3\uffff\1\3\6\uffff\1\4\12\uffff}>";
static final String[] DFA29_transitionS = {
"\44\1\1\2\1\20\11\1\1\15\54\1\1\27\uffa3\1",
"",
"\44\7\1\17\1\10\11\7\1\4\54\7\1\1\uffa3\7",
"\1\uffff",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"\1\uffff",
"",
"",
"",
"\1\uffff",
"",
"",
@ -2529,6 +2521,15 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer {
"",
"",
"\1\uffff",
"",
"",
"",
"",
"",
"",
"",
"",
"",
""
};
@ -2572,102 +2573,102 @@ public class ActionSplitter extends org.antlr.v4.runtime.Lexer {
int LA29_0 = input.LA(1);
s = -1;
if ( ((LA29_0>='\u0000' && LA29_0<='#')||(LA29_0>='&' && LA29_0<='.')||(LA29_0>='0' && LA29_0<='[')||(LA29_0>=']' && LA29_0<='\uFFFF')) ) {s = 1;}
if ( (LA29_0=='\\') ) {s = 1;}
else if ( (LA29_0=='$') ) {s = 2;}
else if ( (LA29_0=='/') ) {s = 4;}
else if ( (LA29_0=='/') ) {s = 13;}
else if ( ((LA29_0>='\u0000' && LA29_0<='#')||(LA29_0>='&' && LA29_0<='.')||(LA29_0>='0' && LA29_0<='[')||(LA29_0>=']' && LA29_0<='\uFFFF')) ) {s = 7;}
else if ( (LA29_0=='%') ) {s = 16;}
else if ( (LA29_0=='%') ) {s = 8;}
else if ( (LA29_0=='\\') ) {s = 23;}
else if ( (LA29_0=='$') ) {s = 15;}
if ( s>=0 ) return s;
break;
case 1 :
int LA29_2 = input.LA(1);
int LA29_1 = input.LA(1);
int index29_2 = input.index();
int index29_1 = input.index();
input.rewind();
s = -1;
if ( (synpred4_ActionSplitter()) ) {s = 3;}
if ( (synpred3_ActionSplitter()) ) {s = 2;}
else if ( (synpred5_ActionSplitter()) ) {s = 4;}
else if ( (synpred6_ActionSplitter()) ) {s = 5;}
else if ( (synpred7_ActionSplitter()) ) {s = 6;}
else if ( (synpred8_ActionSplitter()) ) {s = 7;}
else if ( (synpred9_ActionSplitter()) ) {s = 8;}
else if ( (synpred10_ActionSplitter()) ) {s = 9;}
else if ( (synpred11_ActionSplitter()) ) {s = 10;}
else if ( (synpred12_ActionSplitter()) ) {s = 11;}
else if ( (synpred13_ActionSplitter()) ) {s = 12;}
else if ( (true) ) {s = 3;}
input.seek(index29_2);
input.seek(index29_1);
if ( s>=0 ) return s;
break;
case 2 :
int LA29_13 = input.LA(1);
int LA29_4 = input.LA(1);
int index29_13 = input.index();
int index29_4 = input.index();
input.rewind();
s = -1;
if ( (synpred1_ActionSplitter()) ) {s = 14;}
if ( (synpred1_ActionSplitter()) ) {s = 5;}
else if ( (synpred2_ActionSplitter()) ) {s = 15;}
else if ( (synpred2_ActionSplitter()) ) {s = 6;}
else if ( (true) ) {s = 1;}
else if ( (true) ) {s = 3;}
input.seek(index29_13);
input.seek(index29_4);
if ( s>=0 ) return s;
break;
case 3 :
int LA29_16 = input.LA(1);
int LA29_8 = input.LA(1);
int index29_16 = input.index();
int index29_8 = input.index();
input.rewind();
s = -1;
if ( (synpred14_ActionSplitter()) ) {s = 17;}
if ( (synpred14_ActionSplitter()) ) {s = 9;}
else if ( (synpred15_ActionSplitter()) ) {s = 18;}
else if ( (synpred15_ActionSplitter()) ) {s = 10;}
else if ( (synpred16_ActionSplitter()) ) {s = 19;}
else if ( (synpred16_ActionSplitter()) ) {s = 11;}
else if ( (synpred17_ActionSplitter()) ) {s = 20;}
else if ( (synpred17_ActionSplitter()) ) {s = 12;}
else if ( (synpred18_ActionSplitter()) ) {s = 21;}
else if ( (synpred18_ActionSplitter()) ) {s = 13;}
else if ( (synpred19_ActionSplitter()) ) {s = 22;}
else if ( (synpred19_ActionSplitter()) ) {s = 14;}
input.seek(index29_16);
input.seek(index29_8);
if ( s>=0 ) return s;
break;
case 4 :
int LA29_23 = input.LA(1);
int LA29_15 = input.LA(1);
int index29_23 = input.index();
int index29_15 = input.index();
input.rewind();
s = -1;
if ( (synpred3_ActionSplitter()) ) {s = 24;}
if ( (synpred4_ActionSplitter()) ) {s = 16;}
else if ( (true) ) {s = 1;}
else if ( (synpred5_ActionSplitter()) ) {s = 17;}
else if ( (synpred6_ActionSplitter()) ) {s = 18;}
else if ( (synpred7_ActionSplitter()) ) {s = 19;}
else if ( (synpred8_ActionSplitter()) ) {s = 20;}
else if ( (synpred9_ActionSplitter()) ) {s = 21;}
else if ( (synpred10_ActionSplitter()) ) {s = 22;}
else if ( (synpred11_ActionSplitter()) ) {s = 23;}
else if ( (synpred12_ActionSplitter()) ) {s = 24;}
else if ( (synpred13_ActionSplitter()) ) {s = 25;}
input.seek(index29_23);
input.seek(index29_15);
if ( s>=0 ) return s;
break;
}

View File

@ -11,10 +11,10 @@ public class TestSyntaxErrors extends BaseTest {
"error(63): A.g::: grammar A has no rules",
"A;",
"error(17): <string>:1:0: 'A'<TOKEN_REF> came as a complete surprise to me",
"error(17): <string>:1:0: 'A' came as a complete surprise to me",
"grammar ;",
"error(17): <string>:1:8: ';'<SEMI> came as a complete surprise to me",
"error(17): <string>:1:8: ';' came as a complete surprise to me while looking for an identifier",
"grammar A\n" +
"a : ID ;\n",
@ -23,20 +23,22 @@ public class TestSyntaxErrors extends BaseTest {
"grammar A;\n" +
"a : ID ;;\n"+
"b : B ;",
"error(17): A.g:2:8: ';'<SEMI> came as a complete surprise to me",
"error(17): A.g:2:8: ';' came as a complete surprise to me",
"grammar A;;\n" +
"a : ID ;\n",
"error(17): A;.g:1:10: ';'<SEMI> came as a complete surprise to me",
"error(17): A;.g:1:10: ';' came as a complete surprise to me",
"grammar A;\n" +
"a @init : ID ;\n",
"error(17): A.g:2:8: missing ACTION at ':' while matching a rule",
"error(17): A.g:2:8: mismatched input ':' expecting ACTION while matching rule preamble",
"grammar A;\n" +
"a ( A | B ) D ;\n" +
"b : B ;",
"error(17): A.g:2:3: missing COLON at '(' while matching a rule",
"error(17): A.g:2:3: '(' came as a complete surprise to me while matching rule preamble\n" +
"error(17): A.g:2:11: mismatched input ')' expecting SEMI while matching a rule\n" +
"error(17): A.g:2:15: ';' came as a complete surprise to me while matching rule preamble",
};
@Test public void testA() { super.testErrors(A, true); }
@ -46,7 +48,7 @@ public class TestSyntaxErrors extends BaseTest {
"grammar A;\n" +
"a : : A ;\n" +
"b : B ;",
"error(17): A.g:2:4: ':'<COLON> came as a complete surprise to me while matching alternative",
"error(17): A.g:2:4: ':' came as a complete surprise to me while matching alternative",
};
super.testErrors(pair, true);
}