It's because of the fws in between hosts and the fws? inside field. You could lower the priority of the inner one and raise the priority of the outer one to resolve the ambiguity.

    wsp            = [ \t];
    fws            = ( ( wsp* crlf )? wsp+ ) ;

    opt_fws        = ( fws? )$(fws,0);
    sep_fws        = ( fws )$(fws,1);

    field          = (opt_fws alpha+ opt_fws);
    host           = (field ('.' field)*) >mark %print;
    main          := host (sep_fws host)*;

-Adrian

Husam Senussi wrote:
Hi,

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.

Thanks _______________________________________________
ragel-users mailing list
[email protected]
http://www.complang.org/mailman/listinfo/ragel-users


_______________________________________________
ragel-users mailing list
[email protected]
http://www.complang.org/mailman/listinfo/ragel-users

Reply via email to