help-bison
[Top][All Lists]
Advanced

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

Priorities in reduce/reduce conflicts


From: Zdenek Prikryl
Subject: Priorities in reduce/reduce conflicts
Date: Thu, 12 Mar 2015 13:21:16 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.3.0

I have a valid reduce/reduce conflict. Bison selects one rule as a default one, and it uses the rule when the conflict occurs. Unfortunately, I need another rule to be the default because it's the way I like to handle the conflict.

I've tried to change an order of rules within the body of "conflict" rule, I've tried glr parser and %dprec too, but nothing helps.

Can someone give me a hint how to deal with this? Just a note, I'd like to keep the grammar as it is as much as possible.

Thanks.

"
%token ID NUMBER

%left '+'
%right UPLUS

%%

body
  : body conflict
  | conflict
  ;

conflict
  : id
  { /* sem act 1 */ }

  // preferred rule but never used
  | expr ':' expr
  { /* sem act 2 */ }

  ;

expr
  : '+' expr %prec UPLUS
  | expr '+' expr
  | NUMBER
  | id
  ;

id
  : ID
  ;

%%
"

--
Zdenek Prikryl




reply via email to

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