addParseListener method
- ParseTreeListener listener
Registers listener
to receive events during the parsing process.
To support output-preserving grammar transformations (including but not limited to left-recursion removal, automated left-factoring, and optimized code generation), calls to listener methods during the parse may differ substantially from calls made by {@link ParseTreeWalker#DEFAULT} used after the parse is complete. In particular, rule entry and exit events may occur in a different order during the parse than after the parser. In addition, calls to certain rule entry methods may be omitted.
With the following specific exceptions, calls to listener events are deterministic, i.e. for identical input the calls to listener methods will be the same.
- Alterations to the grammar used to generate code may change the behavior of the listener calls.
- Alterations to the command line options passed to ANTLR 4 when generating the parser may change the behavior of the listener calls.
- Changing the version of the ANTLR Tool used to generate the parser may change the behavior of the listener calls.
@param listener the listener to add
@throws NullPointerException if {@code} listener is null
Implementation
void addParseListener(
ParseTreeListener listener,
) {
_parseListeners ??= [];
_parseListeners!.add(listener);
}