solved shift-reduce errors

This commit is contained in:
Partho Bhattacharya
2025-02-28 11:50:18 -05:00
parent 078b059d1c
commit 046cb4b171
2 changed files with 22 additions and 4 deletions

View File

@ -18,6 +18,22 @@
int integ;
char * words;
}
//precedence order
%precedence RESERVE
%precedence RELEASE
%precedence DOT
%precedence SUB_OR_NEG
%precedence NOT
%left MUL
%left DIV
%left REM
%left ADD
//need subtraction only here
%left LESS_THAN
%left EQUAL_TO
%left AND
%left OR
%left ASSIGN
%token <words> ID 101
%token T_INTEGER
@ -50,7 +66,7 @@
%token COLON 508
%token COMMA 509
%token ARROW 510
%token ADD 601
/* %token ADD 601
%token SUB_OR_NEG 602
%token MUL 603
%token DIV 604
@ -63,8 +79,10 @@
%token OR 611
%token DOT 612
%token RESERVE 613
%token RELEASE 614
%token RELEASE 614 */
%token COMMENT 700
%%
program:
@ -140,7 +158,7 @@ expression:
constant
| UnaryOperator expression
| assignable
| expression binaryOperator expression
| constant binaryOperator expression
| L_PAREN expression R_PAREN
| memOp assignable
;
@ -197,7 +215,7 @@ int main() {
int a;
while ((a = yyparse()) != EOF){
printf("%d = a: yytext = %s: yychar = %d\n", a, yytext, yychar);
if(yytext[0] == '?'){
if(yytext[0] == '!'){
print_symbol_table(getAncestor(st),stdout);
break;
}