Merge pull request #1340 from parrt/fix-1337
Fixes #1337. Add's sync() call back to LL(1) decisions
This commit is contained in:
commit
bbfca7c99c
|
@ -16,7 +16,7 @@ Output() ::= <<
|
|||
>>
|
||||
|
||||
Errors() ::= <<
|
||||
line 1:2 mismatched input '~FORCE_ERROR~' expecting ')'<\n>
|
||||
line 1:2 mismatched input '~FORCE_ERROR~' expecting {')', ID}<\n>
|
||||
>>
|
||||
|
||||
grammar(grammarName) ::= <<
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
package org.antlr.v4.test.runtime.csharp;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestParserErrors extends BaseTest {
|
||||
|
@ -551,7 +550,7 @@ public class TestParserErrors extends BaseTest {
|
|||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "stat", input, false);
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:2 mismatched input '~FORCE_ERROR~' expecting ')'\n", this.stderrDuringParse);
|
||||
assertEquals("line 1:2 mismatched input '~FORCE_ERROR~' expecting {')', ID}\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.go;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestParserErrors extends BaseTest {
|
||||
|
||||
|
@ -585,7 +585,7 @@ public class TestParserErrors extends BaseTest {
|
|||
"TListener", "TVisitor", "stat", input, false);
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:2 mismatched input '~FORCE_ERROR~' expecting ')'\n", this.stderrDuringParse);
|
||||
assertEquals("line 1:2 mismatched input '~FORCE_ERROR~' expecting {')', ID}\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.java;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestParserErrors extends BaseTest {
|
||||
|
||||
|
@ -679,7 +679,7 @@ public class TestParserErrors extends BaseTest {
|
|||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "stat", input, false);
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:2 mismatched input '~FORCE_ERROR~' expecting ')'\n", this.stderrDuringParse);
|
||||
assertEquals("line 1:2 mismatched input '~FORCE_ERROR~' expecting {')', ID}\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.javascript.node;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestParserErrors extends BaseTest {
|
||||
|
@ -617,7 +617,7 @@ public class TestParserErrors extends BaseTest {
|
|||
"stat", input, false);
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:2 mismatched input '~FORCE_ERROR~' expecting ')'\n", this.stderrDuringParse);
|
||||
assertEquals("line 1:2 mismatched input '~FORCE_ERROR~' expecting {')', ID}\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python2;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestParserErrors extends BasePython2Test {
|
||||
|
@ -710,9 +711,9 @@ public class TestParserErrors extends BasePython2Test {
|
|||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:2 mismatched input '~FORCE_ERROR~' expecting ')'\n", this.stderrDuringParse);
|
||||
assertEquals("line 1:2 mismatched input '~FORCE_ERROR~' expecting {')', ID}\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python3;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestParserErrors extends BasePython3Test {
|
||||
|
@ -710,9 +711,9 @@ public class TestParserErrors extends BasePython3Test {
|
|||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:2 mismatched input '~FORCE_ERROR~' expecting ')'\n", this.stderrDuringParse);
|
||||
assertEquals("line 1:2 mismatched input '~FORCE_ERROR~' expecting {')', ID}\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -537,6 +537,7 @@ CodeBlockForAlt(currentAltCodeBlock, locals, preamble, ops) ::= <<
|
|||
|
||||
LL1AltBlock(choice, preamble, alts, error) ::= <<
|
||||
State = <choice.stateNumber>;
|
||||
ErrorHandler.Sync(this);
|
||||
<if(choice.label)><labelref(choice.label)> = TokenStream.Lt(1);<endif>
|
||||
<preamble; separator="\n">
|
||||
switch (TokenStream.La(1)) {
|
||||
|
@ -550,6 +551,7 @@ default:
|
|||
|
||||
LL1OptionalBlock(choice, alts, error) ::= <<
|
||||
State = <choice.stateNumber>;
|
||||
ErrorHandler.Sync(this);
|
||||
switch (TokenStream.La(1)) {
|
||||
<choice.altLook,alts:{look,alt| <cases(ttypes=look)>
|
||||
<alt>
|
||||
|
@ -561,6 +563,7 @@ default:
|
|||
|
||||
LL1OptionalBlockSingleAlt(choice, expr, alts, preamble, error, followExpr) ::= <<
|
||||
State = <choice.stateNumber>;
|
||||
ErrorHandler.Sync(this);
|
||||
<preamble; separator="\n">
|
||||
if (<expr>) {
|
||||
<alts; separator="\n">
|
||||
|
|
|
@ -519,6 +519,7 @@ CodeBlockForAlt(currentAltCodeBlock, locals, preamble, ops) ::= <<
|
|||
|
||||
LL1AltBlock(choice, preamble, alts, error) ::= <<
|
||||
p.SetState(<choice.stateNumber>)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
<if(choice.label)>
|
||||
<labelref(choice.label)> = p.GetTokenStream().LT(1)
|
||||
<endif>
|
||||
|
@ -544,6 +545,7 @@ default:
|
|||
|
||||
LL1OptionalBlock(choice, alts, error) ::= <<
|
||||
p.SetState(<choice.stateNumber>)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
|
||||
switch p.GetTokenStream().LA(1) {
|
||||
<if(choice.altLook && alts)>
|
||||
|
@ -561,6 +563,11 @@ default:
|
|||
|
||||
LL1OptionalBlockSingleAlt(choice, expr, alts, preamble, error, followExpr) ::= <<
|
||||
p.SetState(<choice.stateNumber>)
|
||||
<! TODO: this should not consume anything but does I think;
|
||||
See TokenMismatch2 test, which fails w/o this sync.
|
||||
But, see TestLeftRecursion.testJavaExpressions_10, 11 which fails with sync()
|
||||
!>
|
||||
p.GetErrorHandler().Sync(p)
|
||||
<if(preamble)>
|
||||
<preamble; separator="\n">
|
||||
|
||||
|
|
|
@ -469,6 +469,7 @@ CodeBlockForAlt(currentAltCodeBlock, locals, preamble, ops) ::= <<
|
|||
|
||||
LL1AltBlock(choice, preamble, alts, error) ::= <<
|
||||
setState(<choice.stateNumber>);
|
||||
_errHandler.sync(this);
|
||||
<if(choice.label)><labelref(choice.label)> = _input.LT(1);<endif>
|
||||
<preamble; separator="\n">
|
||||
switch (_input.LA(1)) {
|
||||
|
@ -482,6 +483,7 @@ default:
|
|||
|
||||
LL1OptionalBlock(choice, alts, error) ::= <<
|
||||
setState(<choice.stateNumber>);
|
||||
_errHandler.sync(this);
|
||||
switch (_input.LA(1)) {
|
||||
<choice.altLook,alts:{look,alt| <cases(ttypes=look)>
|
||||
<alt>
|
||||
|
@ -493,6 +495,7 @@ default:
|
|||
|
||||
LL1OptionalBlockSingleAlt(choice, expr, alts, preamble, error, followExpr) ::= <<
|
||||
setState(<choice.stateNumber>);
|
||||
_errHandler.sync(this);
|
||||
<preamble; separator="\n">
|
||||
if (<expr>) {
|
||||
<alts; separator="\n">
|
||||
|
|
|
@ -340,6 +340,7 @@ CodeBlockForAlt(currentAltCodeBlock, locals, preamble, ops) ::= <<
|
|||
|
||||
LL1AltBlock(choice, preamble, alts, error) ::= <<
|
||||
this.state = <choice.stateNumber>;
|
||||
this._errHandler.sync(this);
|
||||
<if(choice.label)><labelref(choice.label)> = this._input.LT(1);<endif>
|
||||
<preamble; separator="\n">
|
||||
switch(this._input.LA(1)) {
|
||||
|
@ -353,6 +354,7 @@ default:
|
|||
|
||||
LL1OptionalBlock(choice, alts, error) ::= <<
|
||||
this.state = <choice.stateNumber>;
|
||||
this._errHandler.sync(this);
|
||||
switch (this._input.LA(1)) {
|
||||
<choice.altLook,alts:{look,alt| <cases(ttypes=look)>
|
||||
<alt>
|
||||
|
@ -364,6 +366,7 @@ default:
|
|||
|
||||
LL1OptionalBlockSingleAlt(choice, expr, alts, preamble, error, followExpr) ::= <<
|
||||
this.state = <choice.stateNumber>;
|
||||
this._errHandler.sync(this);
|
||||
<preamble; separator="\n">
|
||||
if(<expr>) {
|
||||
<alts; separator="\n">
|
||||
|
|
|
@ -314,6 +314,7 @@ CodeBlockForAlt(currentAltCodeBlock, locals, preamble, ops) ::= <<
|
|||
|
||||
LL1AltBlock(choice, preamble, alts, error) ::= <<
|
||||
self.state = <choice.stateNumber>
|
||||
self._errHandler.sync(self)
|
||||
<if(choice.label)><labelref(choice.label)> = _input.LT(1)<endif>
|
||||
<preamble; separator="\n">
|
||||
token = self._input.LA(1)
|
||||
|
@ -327,6 +328,7 @@ else:
|
|||
|
||||
LL1OptionalBlock(choice, alts, error) ::= <<
|
||||
self.state = <choice.stateNumber>
|
||||
self._errHandler.sync(self)
|
||||
token = self._input.LA(1)
|
||||
<choice.altLook,alts:{look,alt| <cases(ttypes=look)>
|
||||
<alt>
|
||||
|
@ -337,6 +339,7 @@ else:
|
|||
|
||||
LL1OptionalBlockSingleAlt(choice, expr, alts, preamble, error, followExpr) ::= <<
|
||||
self.state = <choice.stateNumber>
|
||||
self._errHandler.sync(self)
|
||||
<preamble; separator="\n">
|
||||
if <expr>:
|
||||
<alts; separator="\n">
|
||||
|
|
|
@ -322,6 +322,7 @@ CodeBlockForAlt(currentAltCodeBlock, locals, preamble, ops) ::= <<
|
|||
|
||||
LL1AltBlock(choice, preamble, alts, error) ::= <<
|
||||
self.state = <choice.stateNumber>
|
||||
self._errHandler.sync(self)
|
||||
<if(choice.label)><labelref(choice.label)> = _input.LT(1)<endif>
|
||||
<preamble; separator="\n">
|
||||
token = self._input.LA(1)
|
||||
|
@ -335,6 +336,7 @@ else:
|
|||
|
||||
LL1OptionalBlock(choice, alts, error) ::= <<
|
||||
self.state = <choice.stateNumber>
|
||||
self._errHandler.sync(self)
|
||||
token = self._input.LA(1)
|
||||
<choice.altLook,alts:{look,alt| <cases(ttypes=look)>
|
||||
<alt>
|
||||
|
@ -345,6 +347,7 @@ else:
|
|||
|
||||
LL1OptionalBlockSingleAlt(choice, expr, alts, preamble, error, followExpr) ::= <<
|
||||
self.state = <choice.stateNumber>
|
||||
self._errHandler.sync(self)
|
||||
<preamble; separator="\n">
|
||||
if <expr>:
|
||||
<alts; separator="\n">
|
||||
|
|
Loading…
Reference in New Issue