[ragel-users] Problem with an indetermination

Iñaki Baz Castillo ibc at aliax.net
Wed Feb 11 23:55:38 UTC 2009


El Jueves, 12 de Febrero de 2009, Adrian Thurston escribió:
> The problem here is an ambiguity. When a space is seen it is unknown
> whether or not the space extends the name or is the beginning of the end
> ("<"). You can change it to this:
>
> name = ( token ( SP token )* )   > { _tag = p }
>     %{ @value = data[_tag..p-1].pack("c*") };
>
> full = name SP* %{ puts "--name=#{@value}--" } "<" [a-z]+ ">";
>
> main := full;
>
> Now on each space the value is only stored. Basically you need to mark
> the end separately from doing something about it because ever time you
> think you see the end, it may not be the end.

Thanks a lot. But, isn't inefficient? I mean: if 'name' is "A B C D E F G H I" 
then the % action will be called 9 times and for each time it will store the 
data in @value.


> An alternative would be to include the SP* in name and strip trailing
> whitespace after.

Unfortunatelly that change would involve more changes in the whole grammar, 
and would require changes in the original BNF grammar of SIP protocol. SIP 
has a really bad designed grammar, full of ambiguities :(

Really thanks a lot.


-- 
Iñaki Baz Castillo




More information about the ragel-users mailing list