ualberta-smr/varclang

Refactor Parser::SplitOrConsume method

Opened this issue · 0 comments

After the TryAgain label, do something like this:

PP.Lex(Result);
if(this->getConditional()->ShouldSplitOnCondition(Result.getConditional())) {
  PP.EnableBacktrackAtThisPos();
} else if (this->getConditional()->ShouldSkipOnCondition(
               Result.getConditional())) {
  llvm::outs() << "skip token " << Result.getName() << " with pc: "
               << Result.getConditional()->toString() << "\n";
  goto TryAgain; // Avoid recursive tail call
} else {
  llvm::outs() << "accept token " << Result.getName() << " with pc: "
               << Result.getConditional()->toString() << "\n";
}

Make sure to test this rigorously