Uncomment syncs before adaptivePredict

These allow slightly better error recovery before we run
`adaptivePredict`, as illustrated by the test.
This commit is contained in:
Michael Peyton Jones 2015-08-27 17:58:14 +01:00
parent 4617daaea7
commit 940cbcf19f
3 changed files with 31 additions and 2 deletions

View File

@ -11,6 +11,7 @@ TestTemplates ::= [
"LL2": [],
"LL3": [],
"LLStar": [],
"SingleTokenDeletionBeforePredict": [],
"SingleTokenDeletionBeforeLoop": [],
"MultiTokenDeletionBeforeLoop": [],
"SingleTokenDeletionDuringLoop": [],

View File

@ -0,0 +1,28 @@
TestType() ::= "Parser"
Options ::= [
"Debug": false
]
Grammar ::= [
"T": {<grammar("T")>}
]
Input() ::= "caaab"
Rule() ::= "a"
Output() ::= <<
>>
Errors() ::= <<
line 1:0 extraneous input 'c' expecting 'a'
>>
grammar(grammarName) ::= <<
grammar <grammarName>;
a : 'a'+ 'b'
| 'a'+ 'c'
;
q : 'e' ;
>>

View File

@ -531,7 +531,7 @@ do {
AltBlock(choice, preamble, alts, error) ::= <<
setState(<choice.stateNumber>);
<!_errHandler.sync(this);!>
_errHandler.sync(this);
<if(choice.label)><labelref(choice.label)> = _input.LT(1);<endif>
<preamble; separator="\n">
switch ( getInterpreter().adaptivePredict(_input,<choice.decision>,_ctx) ) {
@ -544,7 +544,7 @@ case <i>:
OptionalBlock(choice, alts, error) ::= <<
setState(<choice.stateNumber>);
<!_errHandler.sync(this);!>
_errHandler.sync(this);
switch ( getInterpreter().adaptivePredict(_input,<choice.decision>,_ctx) ) {
<alts:{alt |
case <i><if(!choice.ast.greedy)>+1<endif>: