Skip to content

Commit

Permalink
rm k=1 chk to report early ambiguity.
Browse files Browse the repository at this point in the history
  • Loading branch information
parrt committed Mar 16, 2012
1 parent 102980d commit 9a0aaac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ So, we now cover what I hope is the vast majority of the cases (in
* holds the decision were evaluating
*/
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 retry_debug = false;

Expand Down Expand Up @@ -535,8 +535,7 @@ public int execATN(@NotNull DFA dfa, @NotNull DFAState s0,
int k = input.index() - startIndex + 1; // how much input we used
// System.out.println("used k="+k);
if ( outerContext == ParserRuleContext.EMPTY || // in grammar start rule
!D.configset.dipsIntoOuterContext ||
k == 1 ) // SLL(1) == LL(1)
!D.configset.dipsIntoOuterContext )
{
if ( reportAmbiguities && !D.configset.hasSemanticContext ) {
reportAmbiguity(dfa, D, startIndex, input.index(), D.configset.conflictingAlts, D.configset);
Expand Down
9 changes: 3 additions & 6 deletions tool/playground/T.g
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
grammar T;
s : a a a;
a : {false}? ID
| {true}? ID
| INT
;
ID : 'a'..'z'+ ;
s : f f EOF;
f : | x;
x : 'a' 'b';
INT : '0'..'9'+;
WS : (' '|'\n') {skip();} ;

0 comments on commit 9a0aaac

Please sign in to comment.