[ragel-users] Actions executing too often.

Adrian Thurston thurston at complang.org
Wed Dec 23 04:19:27 UTC 2009


If you had base* you could just change it to base**. But you don't so 
you have to use:

main := base <: base**;

-Adrian

Richard Osborn wrote:
> Is there any way to refactor the code to get the behavior I desire? I  
> understand why I am getting the current behavior, but I am unsure of  
> how I can use the given actions to my liking. It seems as though there  
> should be another set of action types for transitioning to different  
> states.
> On Dec 8, 2009, at 5:47 AM, Iñaki Baz Castillo wrote:
> 
>> 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>
>>
>> _______________________________________________
>> 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