Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

ANTLR must parse ahead to see if something matches. If it fails, then ANTLR tries the next viable alt. Upon failure, it's pretty hard to undo actions in general so ANTLR gates actions out with something like this:

Code Block

if ( backtracking==0 )

...

 {
     SymbolTable.getPredefinedType("void"), symtab.getDefaultPkg());

...


}

Labels are still defined, because semantic preds might need them:

Code Block

packageDefinition1=packageDefinition();

AST actions are off during backtracking:

Code Block

if ( backtracking==0 ) list_packageDefinition.add(packageDefinition1.tree);

Upon success, antlr still rewinds the input and then does the same parse again "with feeling". (wink)

...