1///|
2type LookaheadIterator
3
4///|
5#borrow(self)
6extern "c" fn ts_lookahead_iterator_is_null(self : type LookaheadIterator
LookaheadIterator) -> Bool
Bool = "moonbit_c_is_null"
7
8///|
9impl trait Nullable {
is_null(Self) -> Bool
to_option(Self) -> Self?
}
Nullable for type LookaheadIterator
LookaheadIterator with (self : LookaheadIterator) -> Bool
is_null(LookaheadIterator
self : type LookaheadIterator
LookaheadIterator) -> Bool
Bool {
10 (self : LookaheadIterator) -> Bool
ts_lookahead_iterator_is_null(LookaheadIterator
self)
11}
12
13///|
14extern "c" fn ts_lookahead_iterator_new(
15 language : type Language @tree_sitter_language.Language
Language,
16 state : type StateId UInt16
StateId
17) -> type LookaheadIterator
LookaheadIterator = "moonbit_ts_lookahead_iterator_new"
18
19///|
20/// Create a new lookahead iterator for the given language and parse state.
21///
22/// This returns `None` if state is invalid for the language.
23///
24/// Repeatedly using `LookaheadIterator::next` and
25/// `LookaheadIterator::current_symbol` will generate valid symbols in the
26/// given parse state. Newly created lookahead iterators will contain the
27/// `ERROR` symbol.
28///
29/// Lookahead iterators can be useful to generate suggestions and improve syntax
30/// error diagnostics. To get symbols valid in an ERROR node, use the lookahead
31/// iterator on its first leaf node state. For `MISSING` nodes, a lookahead
32/// iterator created on the previous non-extra leaf node may be appropriate.
33pub fn type LookaheadIterator
LookaheadIterator::(language : Language, state : StateId) -> LookaheadIterator?
Create a new lookahead iterator for the given language and parse state.
This returns None if state is invalid for the language.
Repeatedly using LookaheadIterator::next and
LookaheadIterator::current_symbol will generate valid symbols in the
given parse state. Newly created lookahead iterators will contain the
ERROR symbol.
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. For MISSING nodes, a lookahead
iterator created on the previous non-extra leaf node may be appropriate.
new(
34 Language
language : type Language @tree_sitter_language.Language
Language,
35 StateId
state : type StateId UInt16
StateId
36) -> type LookaheadIterator
LookaheadIterator? {
37 (language : Language, state : StateId) -> LookaheadIterator
ts_lookahead_iterator_new(Language
language, StateId
state).(self : LookaheadIterator) -> LookaheadIterator?
to_option()
38}
39
40///|
41/// Reset the lookahead iterator to another state.
42///
43/// This returns `true` if the iterator was reset to the given state and `false`
44/// otherwise.
45#borrow(self)
46pub extern "c" fn type LookaheadIterator
LookaheadIterator::reset_state(
47 self : type LookaheadIterator
LookaheadIterator,
48 state : type StateId UInt16
StateId
49) -> Bool
Bool = "moonbit_ts_lookahead_iterator_reset_state"
50
51///|
52/// Reset the lookahead iterator.
53///
54/// This returns `true` if the language was set successfully and `false`
55/// otherwise.
56#borrow(self)
57pub extern "c" fn type LookaheadIterator
LookaheadIterator::reset(
58 self : type LookaheadIterator
LookaheadIterator,
59 language : type Language @tree_sitter_language.Language
Language,
60 state : type StateId UInt16
StateId
61) -> Bool
Bool = "moonbit_ts_lookahead_iterator_reset"
62
63///|
64/// Get the current language of the lookahead iterator.
65#borrow(self)
66pub extern "c" fn type LookaheadIterator
LookaheadIterator::language(
67 self : type LookaheadIterator
LookaheadIterator
68) -> type Language @tree_sitter_language.Language
Language = "moonbit_ts_lookahead_iterator_language"
69
70///|
71/// Advance the lookahead iterator to the next symbol.
72///
73/// This returns `true` if there is a new symbol and `false` otherwise.
74#borrow(self)
75pub extern "c" fn type LookaheadIterator
LookaheadIterator::next(self : type LookaheadIterator
LookaheadIterator) -> Bool
Bool = "moonbit_ts_lookahead_iterator_next"
76
77///|
78/// Get the current symbol of the lookahead iterator.
79#borrow(self)
80pub extern "c" fn type LookaheadIterator
LookaheadIterator::current_symbol(
81 self : type LookaheadIterator
LookaheadIterator
82) -> type Symbol UInt
Symbol = "moonbit_ts_lookahead_iterator_current_symbol"
83
84///|
85#borrow(self)
86extern "c" fn ts_lookahead_iterator_current_symbol_name(
87 self : type LookaheadIterator
LookaheadIterator
88) -> @c.Pointer[Byte
Byte] = "moonbit_ts_lookahead_iterator_current_symbol_name"
89
90///|
91/// Get the current symbol type of the lookahead iterator as a string.
92pub fn type LookaheadIterator
LookaheadIterator::(self : LookaheadIterator) -> String?
Get the current symbol type of the lookahead iterator as a string.
current_symbol_name(
93 LookaheadIterator
self : type LookaheadIterator
LookaheadIterator
94) -> String
String? {
95 let String
bytes = (self : LookaheadIterator) -> String
ts_lookahead_iterator_current_symbol_name(LookaheadIterator
self)
96 (c_string : ?, length? : Int) -> String?
decode_c_string(String
bytes)
97}
98