I'm writing a parser for a language called C-. I have to write the grammar so its not ambiguous and I can't use any %prec statements in Bison. I've corrected all but 1 shift/reduce conflict and I can't figure out where it is. Any ideas? My .output file gives the following info for where its occurring:
State 163
44 matched: IF '(' simpleExp ')' matched . ELSE matched
46 unmatched: IF '(' simpleExp ')' matched .
48 | IF '(' simpleExp ')' matched . ELSE unmatched
ELSE shift, and go to state 169
ELSE [reduce using rule 46 (unmatched)]
$default reduce using rule 46 (unmatched)
The grammar:
stmt : selectStmt
;
expStmt : exp ';'
| ';'
compoundStmt : '{' localDecls stmtList '}'
;
stmtList : stmtList stmt
|
;
otherStmt : compoundStmt
| expStmt
| iterStmt
| returnStmt
| breakStmt
;
localDecls : localDecls scopedVarDecl
|
;
selectStmt : matched
| unmatched
;
matched : IF '(' simpleExp ')' matched ELSE matched
| otherStmt
;
unmatched : IF '(' simpleExp ')' matched
| IF '(' simpleExp ')' unmatched
| IF '(' simpleExp ')' matched ELSE unmatched
;
iterStmt : WHILE simpleExp DO selectStmt
| FOR ID '=' iterRange DO selectStmt
;
iterRange : simpleExp
| simpleExp TO simpleExp
| simpleExp TO simpleExp BY simpleExp
;
returnStmt : RETURN ';'
| RETURN exp ';'
;
breakStmt : BREAK ';'
;