[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Grammar Troubles: "juxtaposition" operator
From: |
Hans Aberg |
Subject: |
Re: Grammar Troubles: "juxtaposition" operator |
Date: |
Tue, 17 Jun 2008 14:44:09 +0200 |
On 17 Jun 2008, at 01:55, Nick Johnson wrote:
I am trying to implement a grammar with an odd feature.
You might try the Usenet newsgroup comp.compilers.
The grammar is listed below in its barest terms. Here, the last rule
having the lowest precedence:
expr -> 'a'
expr -> '(' expr ')'
expr -> '~' expr
expr -> expr '*'
expr -> expr expr // juxtaposition operator
expr -> expr '|' expr
You might try rewrites like
expr1:
'a'
| '(' expr ')'
| '~' expr
| expr '*'
| expr_sequence
;
expr_sequence:
expr
| expr_sequence expr
;
expr:
expr -> expr '|' expr
;
Or try to let the lexer insert a juxtaposition token, as to making it
explicit in the grammar:
expr: expr JUXTA expr // juxtaposition operator
Hans Aberg