[ragel-users] Solving ambiguity

Husam Senussi husam at senussi.com
Tue May 25 21:49:21 UTC 2010


I'm trying to use ragel to write parser for RFC2822 but I found some ambiguity in the grammar  so just want to see if
is solve it using priories.

Below is sample I found in the grammar with ambiguity

wsp           = [ \t];
fws             = ( ( wsp* crlf )? wsp+ ) 
field		   = (fws? alpha+ fws?);
host		   = (field ('.' field)*) >mark %print;
main        := host (fws host)*;

The problem I found with input like this "a.mydomain.com  b.mydomain.com" end up calling print 3 times

1. "a.mydomain.com"
2. "a.mydomain.com "
3. "b.mydomain.com"

where I was expecting:

2. "a.mydomain.com "
3. "b.mydomain.com"

I'm assuming the problem is having fws? in end of field and one in main between host, so is there
anyway  solve this without breaking the grammar.

Sorry if this sounds  like basic question I just started using Ragel.

ragel-users mailing list
ragel-users at complang.org

More information about the ragel-users mailing list