[ragel-users] Ragel goes while(1) with the following scanner.

Adrian Thurston thurston at complang.org
Mon Jun 8 00:58:13 UTC 2009


The reason ragel seems to run endlessly is that you're getting a state 
explosion. The machine:

comment = '#' any* -- newline;

Is not terminated with a newline. It's just a string that starts with 
'#' and cannot contain a newline. When you put this in front of alnum 
(in bulk?) you create an ambiguity that is costly for ragel to implement 
with a deterministic state machine.

Do this instead:

comment = '#' (any* -- newline) newline;

Or use :>> as you suggested.

Cheers,
  Adrian

david.keller at litchis.fr wrote:
> Hi
> 
> When using this scanner (I removed actions), ragel seems to loop endless.
> 
> %%{
>     machine configuration_parser;
>     include scanner_common "scanner.rl";
> 
>     newline = '\r'?  '\n';
> 
>     comment = '#' any* -- newline;
> 
>     bulk = ([\t\v\f\ ] | comment | newline)+;
> 
>     key = bulk? (alnum ([\_\.]? alnum)*);
> 
>     value = bulk? "\"" any* :>> "\"";
> 
>     values = bulk? value (bulk? ',' value)*;
> 
>     assign = key bulk? '=' values;
> 
>     main := assign* bulk?;
> }%%
> 
>  
> 
> But I works like a charm when:
> 
>     comment = '#' any* -- newline;
> 
> become:
> 
>     comment = '#' any* :>> newline;
> 
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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