[ragel-users] Actions executing too often.

Iñaki Baz Castillo ibc at aliax.net
Tue Dec 8 11:47:33 UTC 2009


El Martes, 8 de Diciembre de 2009, Richard Osborn escribió:
> Hi,
> 	I've just recently started learning Ragel. I have read the guide pdf
> and I can't seem to find a solution to this problem.
> Let's say I have this grammar:
> 	%%{
> 		op = '+'+;
> 		word = alpha+;
> 		spaces = ' '+;
> 		base = 	  spaces
> 
> 				| word >start_word $in_word %end_word
> 				| op >start_op $in_op %end_op
> 
> 				;
> 		main := base+;
> 	}%%
> 
> What I would like to see is this:
> 	http://imgur.com/POP8U.png
> 
> What Ragel compiles is this:
> 	http://imgur.com/x36VA.png
> 
> Can anyone help me get the behavior I'm looking?

Imagine you parse "abc".
Note that "main := base+;".


So when Ragel reads "a" it performs ">start_word".

Then Ragel reads "b". How can Ragel know if "b" is part of the first 'base' or 
the first char of a new 'base'? Both options are valid, so Ragel runs action 
for both (in parallel), so it runs:

- ">start_word" because "b" could be the start of a new 'base'.

- "$in_word" because "b" could be part of the previous 'base' and it's a valid 
existing point.

- ">end_word" because when considering "b" as a new 'base' it means that first 
'base' ("a") has totally ended.

Of course, this will happen for each char. The main problem of your grammar is 
that Ragel cannot determine (who can?) how to split "base+;" into different 
"words" so it takes *all* the valid options *in parallel*.


Hope this helps. Regards.




-- 
Iñaki Baz Castillo <ibc at aliax.net>




More information about the ragel-users mailing list