Hello again,
I'm trying to write a grammar that allows for space separated lists.
Here's my grammar:
%right NEG;
%left MINUS;
%nonassoc SHORT;
%nonassoc LONG;
expression ->
%prec(MINUS) expression SUB expression
| %prec(NEG) SUB expression
| CONSTANT
| %prec(LONG) LPAREN expression (expression)* RPAREN
| %prec(SHORT) LPAREN expression RPAREN
;
What I want is for something like this: "[1 - 2]" to be parsed to the
python form of [(1-2)], not [1, -2]. However, I can't seem to get this
to be unambiguous. For a more complicated example: this: "[1 2 3 - 4 5
- - 6]" should be parsed as this: [1,2,(3-4),(5 - (-6))]. Any idea how
I can get this grammar to work? Thanks again,
-e