[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*To*: sablecc-list@sable.mcgill.ca*Subject*: Operator precedence*From*: Andrew Cooke <andrew@intertrader.com>*Date*: Mon, 12 Oct 1998 11:37:54 +0100

Hi, Has anyone got any quick tips on implementing several layers of operator precedence? Yacc has %prec which helps reduce conflicts, but SableCC seems to expect me to do this in the grammar. The thesis includes an example where * and / take precedence over + and - so I am going to see if I can extend this to have more "layers" ( http://www.sable.mcgill.ca/sablecc/thesis.html#PAGE26 ), but if anyone has any simple advice or pointers they would be appreciated... To put this in context: I am writing an interpreter (for "fun") and it needs to parse something like: z + 2 < 3 * y + 1 and x > y > z so I need the following precendence: * > + > ">" > and (and then there's "not" to add in). Cheers, Andrew PS. x > y > z is interesting when it comes to storing temporary results by node :-) PPS. I guess one could implement this later using rotations to arrange the tree as required, but that seems like a lot of work!

- Prev by Date:
**Re: Question?** - Next by Date:
**Re: Operator precedence** - Prev by thread:
**Re: Question?** - Next by thread:
**Re: Operator precedence** - Index(es):