LookaheadIterator#
- class tree_sitter.LookaheadIterator#
Bases:
IteratorA 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
ERRORnode, use the lookahead iterator on its first leaf node state. ForMISSINGnodes, a lookahead iterator created on the previous non-extra leaf node may be appropriate.Methods#
- names()#
Get a list of all symbol names.
- reset(state, language=None)#
Reset the lookahead iterator.
- Returns:
Trueif it was reset successfully orFalseif it failed.
- symbols()#
Get a list of all symbol IDs.
Special Methods#
- __iter__()#
Implements
iter(self).
- __next__()#
Implements
next(self).
Attributes#
- current_symbol#
The current symbol ID.
Newly created iterators will return the
ERRORsymbol.
- current_symbol_name#
The current symbol name.
- language#
The current language.