Open osa1 opened 2 years ago
With new_from_iter
it's more important to avoid clones in set_accepting_state
as not all iterators will be cheap to clone. For example, ropey's char iterator is quite a bit larger than std's Chars
: https://github.com/cessen/ropey/blob/36b21712ce9cdc125fa4580e573966a8bd3fd08c/src/iter.rs#L288-L296
In the Lua lexer I see code like
Here we don't need to set accepting state in line 2. Lines 6 and 23 call the semantic action set in line 2, and could call the function directly instead of going through
backtrack
. Lines 12 and 18 ignore accepting state entirely and call other semantic action functions.I think if we move
set_accepting_state
calls to the branches it may become easier in the code generator to handle these cases. In that case the code above would look like:Now in
generate_state_arm
, we can avoid generatingset_accepting_state
if we backtrack or call another semantic action function. We also need to usepeek
instead ofnext
.