[ragel-users] Error State

Adrian Thurston thurston at complang.org
Wed Jul 21 06:03:23 UTC 2010


It must mean that you're using a scanner and that your patterns accept 
the inputs that your testing. The scanner resets the state to the start 
state every time a pattern is matched.

-Adrian

On 10-07-20 08:53 AM, Pete Gervais wrote:
> Gents,
>
> According to the ragel user guide:
>
> /“Two variables are written that may be used to test the state of the
> machine after a buffer block/
>
> /has been processed. The //name_error //variable gives the id of the
> state that the machine moves/
>
> /into when it cannot find a valid transition to take. The machine
> immediately breaks out of the/
>
> /processing loop when It finds itself in the error state. The error
> variable can be compared to the/
>
> /current state to determine if the machine has failed to parse the
> input. If the machine is complete,/
>
> /that is from every state there is a transition to a proper state on
> every possible character of the/
>
> /alphabet, then no error state is required and this variable will be set
> to -1./
>
> / /
>
> /The //name_first_final //variable stores the id of the first final
> state. All of the machine's states/
>
> /are sorted by their final state status before having their ids
> assigned. Checking if the machine has/
>
> /accepted its input can then be done by checking if the current state is
> greater-than or equal to the/
>
> /first final state.”/
>
> There are many examples shown that check to see if the machine has
> parsed the input correctly or something similar.
>
> /* Did parsing succeed? */
>
> if ( cs < name_first_final ) {
>
> result = ERR_PARSE_ERROR;
>
> goto fail;
>
> }
>
> The problem I have is no matter the final result, ( proper parse or not)
> , the cs variable is always reset to 0 which ensures the test above
> always fails. .
>
> If you look at the C code generated , its look like:
>
> st0:
>
> fsm->cs = 0;
>
> goto _out;
>
> This code gets called on valid exit or error .
>
> Is there something that needs to done in order to get actual state where
> the error occurred?
>
> Regards,
>
> Peter J. Gervais
>
> President, Simtree Information Systems
>
> 17621 Island Rd,
>
> RR#2 , Martintown,
>
> Martintown,Ont
>
> K0C 1S0
>
> Business: 613-938-6549
>
> Cell: 613-864-7370
>
> E-mail: pgervais at xplornet.com
>
>
>
> _______________________________________________
> ragel-users mailing list
> ragel-users at complang.org
> http://www.complang.org/mailman/listinfo/ragel-users

_______________________________________________
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