simpleparse - what is wrong with my grammar?

Laszlo Nagy gandalf at shopzeus.com
Mon Feb 25 09:10:12 EST 2008


>>  
> You've created an infinitely recursing grammar.  SimpleParse is a 
> straightforward recursive descent parser without look-ahead (unless 
> explicitly coded) or ambiguity resolution.  You are asking it to parse 
> "expr" to see if "expr,binop,expr" is matched.  It will continue 
> recursing down into "expr" until it runs out of ram or otherwise 
> encounters a system-level fault.
>
> You need to disambiguate your grammar to have it work with 
> SimpleParse.  How you do that will depend on what you really meant by 
> expr,binop,expr:
>
>    a&b&c
>
> could be parsed as either:
>
>    ((a&b)&c)
>
> or:
>
>    (a&(b&c))
>
> the following creates a parser that produces the first option (which 
> is, I *think* what you wanted):
Is there any way I can specify precedence tables? Or do I have to use a 
different parser generator then?

Thanks,

   Laszlo




More information about the Python-list mailing list