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





_______________________________________________
help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to