fix #1955 for Chsarp
This commit is contained in:
parent
d714d7ba9c
commit
f6537bf4ac
|
@ -1622,12 +1622,6 @@ namespace Antlr4.Runtime.Atn
|
||||||
depth == 0, fullCtx, treatEofAsEpsilon);
|
depth == 0, fullCtx, treatEofAsEpsilon);
|
||||||
if (c != null)
|
if (c != null)
|
||||||
{
|
{
|
||||||
if (!t.IsEpsilon && !closureBusy.Add(c))
|
|
||||||
{
|
|
||||||
// avoid infinite recursion for EOF* and EOF+
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int newDepth = depth;
|
int newDepth = depth;
|
||||||
if (config.state is RuleStopState)
|
if (config.state is RuleStopState)
|
||||||
{
|
{
|
||||||
|
@ -1637,12 +1631,6 @@ namespace Antlr4.Runtime.Atn
|
||||||
// come in handy and we avoid evaluating context dependent
|
// come in handy and we avoid evaluating context dependent
|
||||||
// preds if this is > 0.
|
// preds if this is > 0.
|
||||||
|
|
||||||
if (!closureBusy.Add(c))
|
|
||||||
{
|
|
||||||
// avoid infinite recursion for right-recursive rules
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (thisDfa != null && thisDfa.IsPrecedenceDfa)
|
if (thisDfa != null && thisDfa.IsPrecedenceDfa)
|
||||||
{
|
{
|
||||||
int outermostPrecedenceReturn = ((EpsilonTransition)t).OutermostPrecedenceReturn;
|
int outermostPrecedenceReturn = ((EpsilonTransition)t).OutermostPrecedenceReturn;
|
||||||
|
@ -1653,17 +1641,32 @@ namespace Antlr4.Runtime.Atn
|
||||||
}
|
}
|
||||||
|
|
||||||
c.reachesIntoOuterContext++;
|
c.reachesIntoOuterContext++;
|
||||||
|
if (!closureBusy.Add(c))
|
||||||
|
{
|
||||||
|
// avoid infinite recursion for right-recursive rules
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
configs.dipsIntoOuterContext = true; // TODO: can remove? only care when we add to set per middle of this method
|
configs.dipsIntoOuterContext = true; // TODO: can remove? only care when we add to set per middle of this method
|
||||||
newDepth--;
|
newDepth--;
|
||||||
if (debug)
|
if (debug)
|
||||||
ConsoleWriteLine("dips into outer ctx: " + c);
|
ConsoleWriteLine("dips into outer ctx: " + c);
|
||||||
}
|
}
|
||||||
else if (t is RuleTransition)
|
else
|
||||||
{
|
{
|
||||||
// latch when newDepth goes negative - once we step out of the entry context we can't return
|
|
||||||
if (newDepth >= 0)
|
if (!t.IsEpsilon && !closureBusy.Add(c))
|
||||||
{
|
{
|
||||||
newDepth++;
|
// avoid infinite recursion for EOF* and EOF+
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (t is RuleTransition)
|
||||||
|
{
|
||||||
|
// latch when newDepth goes negative - once we step out of the entry context we can't return
|
||||||
|
if (newDepth >= 0)
|
||||||
|
{
|
||||||
|
newDepth++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue