help-bison
[Top][All Lists]
Advanced

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

Re: Short hand expression operators


From: Hans Aberg
Subject: Re: Short hand expression operators
Date: Thu, 25 Mar 2010 01:17:47 +0100

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











reply via email to

[Prev in Thread] Current Thread [Next in Thread]