Skip to content

Commit

Permalink
Skip some unnecessary checks after a reduction.
Browse files Browse the repository at this point in the history
  • Loading branch information
teo-tsirpanis committed Sep 11, 2023
1 parent fb6eda5 commit 80d702d
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ private RunResult Run(ref ParserInputReader<TChar> input, ref ValueStack<int> st
result = null;
return RunResult.NeedsMoreInput;
}
RetryEof:
LrEndOfFileAction eofAction = _lrStateMachine.GetEndOfFileAction(currentState);
if (eofAction.IsAccept)
{
Expand All @@ -82,7 +83,7 @@ private RunResult Run(ref ParserInputReader<TChar> input, ref ValueStack<int> st
if (eofAction.IsReduce)
{
currentState = Reduce(ref input, in hotData, ref stateStack, ref semanticValueStack, eofAction.ReduceProduction);
continue;
goto RetryEof;
}
}
else if (!token.IsSuccess)
Expand All @@ -92,6 +93,7 @@ private RunResult Run(ref ParserInputReader<TChar> input, ref ValueStack<int> st
}
else
{
RetryToken:
LrAction action = _lrStateMachine.GetAction(currentState, token.Symbol);
if (action.IsShift)
{
Expand All @@ -104,7 +106,7 @@ private RunResult Run(ref ParserInputReader<TChar> input, ref ValueStack<int> st
if (action.IsReduce)
{
currentState = Reduce(ref input, in hotData, ref stateStack, ref semanticValueStack, action.ReduceProduction);
continue;
goto RetryToken;
}
}
TextPosition errorPos = foundToken ? token.Position : input.State.CurrentPosition;
Expand Down

0 comments on commit 80d702d

Please sign in to comment.