Statements of the below form resulted in shift-reduce conflict since asm was directly reduced to a statement production.
if (expr)
asm();
else
asm();
The above if-else clause is ambiguous when the state of the parser is
IF LPAREN expression RPAREN asm --> LookAheadToken(';') since asm can be reduced to a statement the parser performs a right most derivation of "asm" as statement with the next look_ahead token as semi-colon (';) matching the production IF LPAREN expression RPAREN statement as a selection statement. In the new state ';' (as look ahead token) is an invalid/unexpected token as selection statements can only be of the form
selection_statement: IF LPAREN expression RPAREN statement
selection_statement: IF LPAREN expression RPAREN statement else statement
The solution is to reduce asm followed by semi-colon as a statement expression so as to remove the ambiguity when the next token is ELSE or something else.
I have added the concerned test-cases in the test file and it seems to be running fine with the new grammar changes.
Statements of the below form resulted in shift-reduce conflict since asm was directly reduced to a statement production.
I have added the concerned test-cases in the test file and it seems to be running fine with the new grammar changes.