On 25 Mar 2010, at 00:34, Philip Herron wrote:
I was just thinking until now in my language i haven't allowed
operators like '++' or '+=' etc. Though in the Lex and Yacc book i
took the example of using:
'-' express %prec UMINUS
inline with my usual:
exp '+' exp etc, so this allows '-2 + x' and the like. Which i guess
is half way to allowing: x++ or x-- or x+=2 and the nice short hand
operators.
Would be nice if you could point me in the right direction of how to
handle the grammar of these kinds of operators.
Have you tried just adding
%token PLUSPLUS "++"
..
expr: expr "++"
..
etc. with some %prec, possibly %left, %right?
Hans
_______________________________________________
help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison