user1097048
user1097048

Reputation:

Yacc, different execution for if part of if an if/else syntax

Following code gives "IFST2 rule is useless due to conficts" error. I am trying to print different things for if part of if and if/else blocks. How can I do this?

 IFST1:IF     {printf("if begin");};
 IFST2:IF     {printf("ifelse begin");};
 ELSEST:ELSE {};


singlestatement:
  '{' statement '}';
|
IFST1 '(' expr ')' singlestatement ELSEST singlestatement {};
|
IFST2 '(' expr ')' singlestatement %prec IFX {};

Upvotes: 0

Views: 316

Answers (1)

OmarOthman
OmarOthman

Reputation: 1728

Check this for a general help on the issue. I think you'll have to "specialize" your case to match the general form. Though this is bison, not YACC, both are LALR parser generators.

Upvotes: 1

Related Questions