[ragel-users] Anchoring to the EOF

Adrian Thurston thurston at complang.org
Sun Jan 25 00:59:39 UTC 2009

Like this:

error_handler := any* :>> '\n' @{fgoto main;};

main := whatever $!{fgoto error_handler;};


Julian Morrison wrote:
> It certainly does help, thanks.
> OK, next, I wasn't able to figure out how to do an error recovery. That 
> is, when one of the (line*) starts to match, then fails, the error 
> action should log the error, jump to another regex that matches (any*) 
> :>> '\n', jump back and pick right back up trying to match more lines. 
> It's plainly obvious that Ragel can do that, but the wizardry level is a 
> bit above me. Please elucidate?
> 2009/1/23 Adrian Thurston <thurston at complang.org 
> <mailto:thurston at complang.org>>
>     In short, there isn't!
>     Ragel does not make any assumption about the input, and this includes
>     not assuming line-based input. If you want to anchor to something you
>     just put that something into the grammar at the end. If you want to see
>     if the machine finished in a final state (and thus consumed that
>     something) you test cs against machine_first_final.
>     Hope this helps,
>      Adrian
> ------------------------------------------------------------------------
> _______________________________________________
> ragel-users mailing list
> ragel-users at complang.org
> http://www.complang.org/mailman/listinfo/ragel-users

More information about the ragel-users mailing list