LookaheadIterator#
- class tree_sitter.LookaheadIterator#
Bases:
Iterator
A class that is used to look up symbols valid in a specific parse state.
Tip
Lookahead iterators can be useful to generate suggestions and improve syntax error diagnostics.
To get symbols valid in an
ERROR
node, use the lookahead iterator on its first leaf node state. ForMISSING
nodes, a lookahead iterator created on the previous non-extra leaf node may be appropriate.Methods#
- iter_names()#
Iterate symbol names.
- reset_state(state, language=None)#
Reset the lookahead iterator.
- Returns:
True
if it was reset successfully orFalse
if it failed.
Special Methods#
- __iter__()#
Implements
iter(self)
.
- __next__()#
Implements
next(self)
.
Attributes#
- current_symbol#
The current symbol.
Newly created iterators will return the
ERROR
symbol.
- current_symbol_name#
The current symbol name.
- language#
The current language.