rm k=1 chk to report early ambiguity.

This commit is contained in:
Terence Parr 2012-03-16 14:11:21 -07:00
parent 102980dffd
commit 9a0aaacbee
2 changed files with 5 additions and 9 deletions

View File

@ -239,7 +239,7 @@ import java.util.Set;
* holds the decision were evaluating * holds the decision were evaluating
*/ */
public class ParserATNSimulator<Symbol extends Token> extends ATNSimulator { public class ParserATNSimulator<Symbol extends Token> extends ATNSimulator {
public static boolean debug = false; public static boolean debug = false
public static boolean dfa_debug = false; public static boolean dfa_debug = false;
public static boolean retry_debug = false; public static boolean retry_debug = false;
@ -535,8 +535,7 @@ public class ParserATNSimulator<Symbol extends Token> extends ATNSimulator {
int k = input.index() - startIndex + 1; // how much input we used int k = input.index() - startIndex + 1; // how much input we used
// System.out.println("used k="+k); // System.out.println("used k="+k);
if ( outerContext == ParserRuleContext.EMPTY || // in grammar start rule if ( outerContext == ParserRuleContext.EMPTY || // in grammar start rule
!D.configset.dipsIntoOuterContext || !D.configset.dipsIntoOuterContext )
k == 1 ) // SLL(1) == LL(1)
{ {
if ( reportAmbiguities && !D.configset.hasSemanticContext ) { if ( reportAmbiguities && !D.configset.hasSemanticContext ) {
reportAmbiguity(dfa, D, startIndex, input.index(), D.configset.conflictingAlts, D.configset); reportAmbiguity(dfa, D, startIndex, input.index(), D.configset.conflictingAlts, D.configset);

View File

@ -1,9 +1,6 @@
grammar T; grammar T;
s : a a a; s : f f EOF;
a : {false}? ID f : | x;
| {true}? ID x : 'a' 'b';
| INT
;
ID : 'a'..'z'+ ;
INT : '0'..'9'+; INT : '0'..'9'+;
WS : (' '|'\n') {skip();} ; WS : (' '|'\n') {skip();} ;