[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Implicit Multiplication
From: |
Aaron Hurst |
Subject: |
Implicit Multiplication |
Date: |
Fri, 05 Aug 2005 18:05:46 -0700 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030922 |
Hi... maybe someone with more bison experience could lend a hand? Any
help is greatly appreciated.
I'm trying to parse a simple algebraic (Boolean) expression using the
grammar described below. However, I would like to be able to parse
implicit multiplication (i.e. if two expression appear next to each
other without an operator, they should be mulitplied). For example,
a b + (c + d)g
should parse the same as
a * b + (c + d) * g
As written below, there are several shift/reduce conflicts caused by the
last rule (the implicit multiplication). I have no idea how to rewrite
this unambiguously.
%left '|' '+'
%left '^'
%left '&' '*'
%nonassoc '\''
%nonassoc '!'
expression:
IDENTIFIER
| '(' expression ')'
| expression '*' expression
| expression '&' expression
| expression '+' expression
| expression '|' expression
| expression '^' expression
| '!' expression
| expression '\''
| expression expression %prec '*' /* this rule causes problems */
;
----------------------------------
Aaron Hurst
address@hidden
- Implicit Multiplication,
Aaron Hurst <=