It's not correct to avoid full LL for k=1 SLL conflict; we found a counterexample. something to do with the fact that, while the class of LL(1)=SLL(1), that doesn't mean that the parser decisions are equally powerful. Anyway, Sam reports that it's a big optimization to put this back in. Then, if we get a syntax error, we fail over to full LL. That leaves us with 3 stages SLL -> LL+k=1 -> LL.
I said "LL(1) == SLL(1)", Sam says "this results in a faulty reportAmbiguity on the else in "{ if a then foo else bar }", when in fact it's only a conflict for "{ if a then if a then foo else bar }"
e : ID | e '.' ID;ID | e '.' ID; With the input "a.a.a" you get (select (select a a) a) the .stop value for the outer ctx is correct, but for the inner (select a a) it's null correction, i'm not sure it's correct for the outer due to a syntax error occuring in mine, but it's definitely null for the inner. yep, _localctx.stop is set at the very end of the rule, but it needs to be inside the postfix expr loop. right after "_prevctx = _localctx;" add "_prevctx.stop = _input.LT(-1);" Should be last real token; not conjured.tail call optimization. x : a b; closure can jump to b not pushing frame since if we ever fall out of entry rule, x, it'll compute FOLLOW in SLL mode. Slightly weaker since we might do FOLLOW when we could have specific call stack. but drops mem like 50%. this grammar would try to compute FOLLOW at end of x (stack is s calls a) since we didn't push calls site in a.
s : a INT; s2 : b ID; a : x; b : x; x : ID; |
s calls a then a pretends to make decision but doesn't push call. at end of x let's say we look further but have no stack in SLL mode so we do FOLLOW. It'll see ID in there but in real SLL, we'd see call site in a on stack.
Sam now reports that you can't skip the push when calling a rule from the decision entry rule in the lexer since we stop at stop state when stack empty in match(). This gives the wrong token type. Works to resolve weakness in SLL if we push tail call frame from dec entry rule since it doesn't fall back to FOLLOW too early.
tail call elimination has a big impact.
testNotSetRuleRootInLoop. ~set in LL1Analyzer doesn't compute ~
turn on predctx cache for lexer
fragment START_TAG : '<';
fragment WORDCHAR : 'a'..'z' | 'A'..'Z' | '0'..'9' | '_';
TAG_START : START_TAG WORDCHAR+ { pushMode(IN_TAG); };
ANY_GENERAL : ~START_TAG+;
// ANY_GENERAL : ~'<'+;
|
I don't understand why they are not doing the same thing?
expr returns [int r]
: '-' expr { $r = - $expr.r; }
|
In this example $expr should bind to the sub-expression in my opinion.
However, it does not. Since the rule is also named expr, $expr refers to
the rule context instead of the context of the sub-expression. I think
most of the time this is not what the user wants.