I would just set ts = 0 before breaking out. Usually the code I use to
manage the buffer when tokens cross buffer boundaries starts with
if ( ts != 0 ) {
}
The idea is that if no token is currently being matched (true when the
buffer actually ends on a token boundary) then there is nothing to do.
It might make sense for ragel to do that automatically, but I don't like
that because it rules out the possibility of making use of ts for the
times when it is actually wanted.
-Adrian
Matthieu Tourne wrote:
I have a scanner, that if an optional final state is reached can be
simplified to accept any input, and stop trying to match scanners
expressions.
For example :
final := any* :>> final_char @final_action any*;
main := |*
foo => { do_stuff(); };
bar => { do_more_stuff(); };
final_exp => { fgoto final; };
any => { reset_states(); }
*|;
The problem is that 'ts' will stay where final_exp matched, and the
amount of chars to backtrack will grow indefinitely as the last any* of
'final' matches.
Is there a good way to address this problem?
I could stop parsing the input after final_char is found, but we can
imagine a case where we would still want to match something after
'final_char' is found, but break away from the main scanner, to have a
simpler set of rules.
Thanks,
Matthieu.
--
Matthieu Tourne
------------------------------------------------------------------------
_______________________________________________
ragel-users mailing list
[email protected]
http://www.complang.org/mailman/listinfo/ragel-users
_______________________________________________
ragel-users mailing list
[email protected]
http://www.complang.org/mailman/listinfo/ragel-users