fix the lexer

master
jakeallen 11 months ago
parent c3fae88b83
commit c1bbdf01ef

@ -581,9 +581,10 @@ char *yytext;
#include "ast.h"
#include "parser.h"
#define TESTINFO(type,value) printf("LexToken(%s,%s,%d))\n",type,value,yylineno)
int line_cnt = 1;
#line 586 "lexer.c"
#line 587 "lexer.c"
#line 588 "lexer.c"
#define INITIAL 0
@ -800,9 +801,9 @@ YY_DECL
}
{
#line 19 "lexer.l"
#line 21 "lexer.l"
#line 806 "lexer.c"
#line 807 "lexer.c"
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{
@ -871,13 +872,13 @@ do_action: /* This label is used only to access EOF actions. */
case 1:
YY_RULE_SETUP
#line 20 "lexer.l"
#line 22 "lexer.l"
{ }
YY_BREAK
case 2:
/* rule 2 can match eol */
YY_RULE_SETUP
#line 21 "lexer.l"
#line 23 "lexer.l"
{
int len = strlen(yytext);
for (int i = 0; i < len; i++)
@ -888,182 +889,182 @@ YY_RULE_SETUP
case 3:
/* rule 3 can match eol */
YY_RULE_SETUP
#line 27 "lexer.l"
#line 29 "lexer.l"
{ line_cnt++; }
YY_BREAK
case 4:
YY_RULE_SETUP
#line 28 "lexer.l"
#line 30 "lexer.l"
{ }
YY_BREAK
case 5:
YY_RULE_SETUP
#line 29 "lexer.l"
{ return INT; }
#line 31 "lexer.l"
{ TESTINFO("INT","int"); return INT; }
YY_BREAK
case 6:
YY_RULE_SETUP
#line 30 "lexer.l"
{ return FLOAT; }
#line 32 "lexer.l"
{ TESTINFO("FLOAT","float"); return FLOAT; }
YY_BREAK
case 7:
YY_RULE_SETUP
#line 31 "lexer.l"
{ return VOID; }
#line 33 "lexer.l"
{ TESTINFO("VOID","void");return VOID; }
YY_BREAK
case 8:
YY_RULE_SETUP
#line 32 "lexer.l"
{ return CONST; }
#line 34 "lexer.l"
{ TESTINFO("CONST","const"); return CONST; }
YY_BREAK
case 9:
YY_RULE_SETUP
#line 33 "lexer.l"
{ return RETURN; }
#line 35 "lexer.l"
{ TESTINFO("RETURN","return"); return RETURN; }
YY_BREAK
case 10:
YY_RULE_SETUP
#line 34 "lexer.l"
{ return IF; }
#line 36 "lexer.l"
{ TESTINFO("IF","if"); return IF; }
YY_BREAK
case 11:
YY_RULE_SETUP
#line 35 "lexer.l"
{ return ELSE; }
#line 37 "lexer.l"
{ TESTINFO("ELSE","else"); return ELSE; }
YY_BREAK
case 12:
YY_RULE_SETUP
#line 36 "lexer.l"
{ return WHILE; }
#line 38 "lexer.l"
{ TESTINFO("WHILE","while");return WHILE; }
YY_BREAK
case 13:
YY_RULE_SETUP
#line 37 "lexer.l"
{ return BREAK; }
#line 39 "lexer.l"
{ TESTINFO("BREAK","break");return BREAK; }
YY_BREAK
case 14:
YY_RULE_SETUP
#line 38 "lexer.l"
{ return CONTINUE; }
#line 40 "lexer.l"
{ TESTINFO("CONTINUE","continue"); return CONTINUE; }
YY_BREAK
case 15:
YY_RULE_SETUP
#line 39 "lexer.l"
{ return LP; }
#line 41 "lexer.l"
{ TESTINFO("LP","()");return LP; }
YY_BREAK
case 16:
YY_RULE_SETUP
#line 40 "lexer.l"
{ return RP; }
#line 42 "lexer.l"
{ TESTINFO("RP",")");return RP; }
YY_BREAK
case 17:
YY_RULE_SETUP
#line 41 "lexer.l"
{ return LB; }
#line 43 "lexer.l"
{ TESTINFO("LB","[");return LB; }
YY_BREAK
case 18:
YY_RULE_SETUP
#line 42 "lexer.l"
{ return RB; }
#line 44 "lexer.l"
{ TESTINFO("RB","]");return RB; }
YY_BREAK
case 19:
YY_RULE_SETUP
#line 43 "lexer.l"
{ return LC; }
#line 45 "lexer.l"
{ TESTINFO("LC","{");return LC; }
YY_BREAK
case 20:
YY_RULE_SETUP
#line 44 "lexer.l"
{ return RC; }
#line 46 "lexer.l"
{ TESTINFO("RC","}");return RC; }
YY_BREAK
case 21:
YY_RULE_SETUP
#line 45 "lexer.l"
{ return COMMA; }
#line 47 "lexer.l"
{ TESTINFO("COMMA",",");return COMMA; }
YY_BREAK
case 22:
YY_RULE_SETUP
#line 46 "lexer.l"
{ return SEMICOLON; }
#line 48 "lexer.l"
{ TESTINFO("SEMI",";");return SEMICOLON; }
YY_BREAK
case 23:
YY_RULE_SETUP
#line 47 "lexer.l"
{ return PLUS; }
#line 49 "lexer.l"
{ TESTINFO("PLUS","+");return PLUS; }
YY_BREAK
case 24:
YY_RULE_SETUP
#line 48 "lexer.l"
{ return MINUS; }
#line 50 "lexer.l"
{ TESTINFO("MINUS","-");return MINUS; }
YY_BREAK
case 25:
YY_RULE_SETUP
#line 49 "lexer.l"
{ return NOT; }
#line 51 "lexer.l"
{ TESTINFO("NOT","!");return NOT; }
YY_BREAK
case 26:
YY_RULE_SETUP
#line 50 "lexer.l"
{ return ASSIGN; }
#line 52 "lexer.l"
{ TESTINFO("ASSIGN","=");return ASSIGN; }
YY_BREAK
case 27:
YY_RULE_SETUP
#line 51 "lexer.l"
{ return MUL; }
#line 53 "lexer.l"
{ TESTINFO("MUL","*");return MUL; }
YY_BREAK
case 28:
YY_RULE_SETUP
#line 52 "lexer.l"
{ return DIV; }
#line 54 "lexer.l"
{ TESTINFO("DIV","/");return DIV; }
YY_BREAK
case 29:
YY_RULE_SETUP
#line 53 "lexer.l"
{ return MOD; }
#line 55 "lexer.l"
{ TESTINFO("MOD","%");return MOD; }
YY_BREAK
case 30:
YY_RULE_SETUP
#line 54 "lexer.l"
{ return AND; }
#line 56 "lexer.l"
{ TESTINFO("AND","&&");return AND; }
YY_BREAK
case 31:
YY_RULE_SETUP
#line 55 "lexer.l"
{ return OR; }
#line 57 "lexer.l"
{ TESTINFO("OR","||");return OR; }
YY_BREAK
case 32:
YY_RULE_SETUP
#line 56 "lexer.l"
{ return EQ; }
#line 58 "lexer.l"
{ TESTINFO("EQ","==");return EQ; }
YY_BREAK
case 33:
YY_RULE_SETUP
#line 57 "lexer.l"
{ return NE; }
#line 59 "lexer.l"
{ TESTINFO("NE","!=");return NE; }
YY_BREAK
case 34:
YY_RULE_SETUP
#line 58 "lexer.l"
{ return LT; }
#line 60 "lexer.l"
{ TESTINFO("LT","<");return LT; }
YY_BREAK
case 35:
YY_RULE_SETUP
#line 59 "lexer.l"
{ return LE; }
#line 61 "lexer.l"
{ TESTINFO("LE","<=");return LE; }
YY_BREAK
case 36:
YY_RULE_SETUP
#line 60 "lexer.l"
{ return GT; }
#line 62 "lexer.l"
{ TESTINFO("GT",">");return GT; }
YY_BREAK
case 37:
YY_RULE_SETUP
#line 61 "lexer.l"
{ return GE; }
#line 63 "lexer.l"
{ TESTINFO("GE",">=");return GE; }
YY_BREAK
case 38:
YY_RULE_SETUP
#line 62 "lexer.l"
#line 64 "lexer.l"
{
int val = 0;
int len = strlen(yytext);
@ -1075,57 +1076,63 @@ YY_RULE_SETUP
val += yytext[i] - 'a' + 10;
}
yylval.int_val = val;
TESTINFO("INT_LIT","int_lit");
return INT_LIT;
}
YY_BREAK
case 39:
YY_RULE_SETUP
#line 76 "lexer.l"
#line 79 "lexer.l"
{
yylval.str_val = (char *)malloc(strlen(yytext) + 1);
strcpy(yylval.str_val, yytext);
yylval.str_val[strlen(yytext)] = '\0';
TESTINFO("ID","id");
return ID;
}
YY_BREAK
case 40:
YY_RULE_SETUP
#line 82 "lexer.l"
{ yylval.float_val = atof(yytext); return FLOAT_LIT; }
#line 86 "lexer.l"
{
yylval.float_val = atof(yytext);
TESTINFO("FLOAT_LIT","float_lit");
return FLOAT_LIT; }
YY_BREAK
case 41:
YY_RULE_SETUP
#line 83 "lexer.l"
#line 90 "lexer.l"
{ return LEX_ERR; }
YY_BREAK
case 42:
YY_RULE_SETUP
#line 84 "lexer.l"
#line 91 "lexer.l"
{ yylval.int_val = atoi(yytext); return INT_LIT; }
YY_BREAK
case 43:
YY_RULE_SETUP
#line 85 "lexer.l"
#line 92 "lexer.l"
{
int val = 0;
int len = strlen(yytext);
for (int i = 1; i < len; i++)
val = (val << 3) + yytext[i] - '0';
yylval.int_val = val;
TESTINFO("INT_LIT","int_lit");
return INT_LIT;
}
YY_BREAK
case 44:
YY_RULE_SETUP
#line 93 "lexer.l"
#line 101 "lexer.l"
{ }
YY_BREAK
case 45:
YY_RULE_SETUP
#line 94 "lexer.l"
#line 102 "lexer.l"
ECHO;
YY_BREAK
#line 1129 "lexer.c"
#line 1136 "lexer.c"
case YY_STATE_EOF(INITIAL):
yyterminate();
@ -2142,6 +2149,6 @@ void yyfree (void * ptr )
#define YYTABLES_NAME "yytables"
#line 94 "lexer.l"
#line 102 "lexer.l"

@ -28,39 +28,39 @@ Lex_err [1-9][0-9]*[a-zA-Z]+[0-9]*|0[0-7]*[8-9a-zA-Z_]+[0-9a-zA-Z_]*
}
"\n" { line_cnt++; }
[ \t] { }
"int" { TESTINFO("INT"); return INT; }
"float" { TESTINFO("FLOAT"); return FLOAT; }
"void" { TESTINFO("VOID");return VOID; }
"const" { TESTINFO("CONST"); return CONST; }
"return" { TESTINFO("RETURN"); return RETURN; }
"if" { TESTINFO("IF"); return IF; }
"else" { TESTINFO("ELSE") return ELSE; }
"while" { TESTINFO("WHILE");return WHILE; }
"break" { TESTINFO("BREAK");return BREAK; }
"continue" { TESTINFO("CONTINUE"); return CONTINUE; }
"(" { TESTINFO("LP");return LP; }
")" { TESTINFO("RP");return RP; }
"[" { TESTINFO("LB");return LB; }
"]" { TESTINFO("RB");return RB; }
"{" { TESTINFO("LC");return LC; }
"}" { TESTINFO("RC");return RC; }
"," { TESTINFO("COMMA");return COMMA; }
";" { TESTINFO("SEMI");return SEMICOLON; }
"+" { TESTINFO("PLUS");return PLUS; }
"-" { TESTINFO(MINUS);return MINUS; }
"!" { TESTINFO("NOT");return NOT; }
"=" { TESTINFO("ASSIGN");return ASSIGN; }
"*" { TESTINFO("MUL");return MUL; }
"/" { TESTINFO("DIV");return DIV; }
"%" { TESTINFO("MOD");return MOD; }
"&&" { TESTINFO("AND");return AND; }
"||" { TESTINFO("OR");return OR; }
"==" { TESTINFO("EQ");return EQ; }
"!=" { TESTINFO("NE");return NE; }
"<" { TESTINFO("LT");return LT; }
"<=" { TESTINFO("LE");return LE; }
">" { TESTINFO("GT");return GT; }
">=" { TESTINFO("GE");return GE; }
"int" { TESTINFO("INT","int"); return INT; }
"float" { TESTINFO("FLOAT","float"); return FLOAT; }
"void" { TESTINFO("VOID","void");return VOID; }
"const" { TESTINFO("CONST","const"); return CONST; }
"return" { TESTINFO("RETURN","return"); return RETURN; }
"if" { TESTINFO("IF","if"); return IF; }
"else" { TESTINFO("ELSE","else"); return ELSE; }
"while" { TESTINFO("WHILE","while");return WHILE; }
"break" { TESTINFO("BREAK","break");return BREAK; }
"continue" { TESTINFO("CONTINUE","continue"); return CONTINUE; }
"(" { TESTINFO("LP","()");return LP; }
")" { TESTINFO("RP",")");return RP; }
"[" { TESTINFO("LB","[");return LB; }
"]" { TESTINFO("RB","]");return RB; }
"{" { TESTINFO("LC","{");return LC; }
"}" { TESTINFO("RC","}");return RC; }
"," { TESTINFO("COMMA",",");return COMMA; }
";" { TESTINFO("SEMI",";");return SEMICOLON; }
"+" { TESTINFO("PLUS","+");return PLUS; }
"-" { TESTINFO("MINUS","-");return MINUS; }
"!" { TESTINFO("NOT","!");return NOT; }
"=" { TESTINFO("ASSIGN","=");return ASSIGN; }
"*" { TESTINFO("MUL","*");return MUL; }
"/" { TESTINFO("DIV","/");return DIV; }
"%" { TESTINFO("MOD","%");return MOD; }
"&&" { TESTINFO("AND","&&");return AND; }
"||" { TESTINFO("OR","||");return OR; }
"==" { TESTINFO("EQ","==");return EQ; }
"!=" { TESTINFO("NE","!=");return NE; }
"<" { TESTINFO("LT","<");return LT; }
"<=" { TESTINFO("LE","<=");return LE; }
">" { TESTINFO("GT",">");return GT; }
">=" { TESTINFO("GE",">=");return GE; }
0[xX][0-9a-fA-F]* {
int val = 0;
int len = strlen(yytext);
@ -72,7 +72,7 @@ Lex_err [1-9][0-9]*[a-zA-Z]+[0-9]*|0[0-7]*[8-9a-zA-Z_]+[0-9a-zA-Z_]*
val += yytext[i] - 'a' + 10;
}
yylval.int_val = val;
TESTINFO("INT_LIT");
TESTINFO("INT_LIT","int_lit");
return INT_LIT;
}
@ -80,12 +80,12 @@ Lex_err [1-9][0-9]*[a-zA-Z]+[0-9]*|0[0-7]*[8-9a-zA-Z_]+[0-9a-zA-Z_]*
yylval.str_val = (char *)malloc(strlen(yytext) + 1);
strcpy(yylval.str_val, yytext);
yylval.str_val[strlen(yytext)] = '\0';
TESTINFO("ID");
TESTINFO("ID","id");
return ID;
}
[0-9]*\.[0-9]+f?|[0-9]+e-?[0-9]+f? {
yylval.float_val = atof(yytext);
TESTINFO("FLOAT_LIT");
TESTINFO("FLOAT_LIT","float_lit");
return FLOAT_LIT; }
{Lex_err} { return LEX_ERR; }
[1-9][0-9]*|0 { yylval.int_val = atoi(yytext); return INT_LIT; }
@ -95,7 +95,7 @@ Lex_err [1-9][0-9]*[a-zA-Z]+[0-9]*|0[0-7]*[8-9a-zA-Z_]+[0-9a-zA-Z_]*
for (int i = 1; i < len; i++)
val = (val << 3) + yytext[i] - '0';
yylval.int_val = val;
TESTINFO("INT_LIT");
TESTINFO("INT_LIT","int_lit");
return INT_LIT;
}
. { }

Binary file not shown.

Binary file not shown.

@ -586,12 +586,12 @@ static const yytype_uint8 yyrline[] =
70, 71, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 85, 86, 87, 88, 89, 90, 91,
92, 93, 94, 95, 96, 97, 98, 100, 101, 102,
103, 104, 112, 113, 114, 115, 116, 117, 118, 119,
120, 121, 122, 127, 128, 129, 130, 131, 132, 133,
134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
144, 145, 146, 147, 149, 150, 151, 152, 154, 155,
157, 159, 160, 161, 163, 164, 165, 166, 167, 169,
170
103, 104, 107, 108, 109, 110, 111, 112, 113, 114,
115, 116, 117, 122, 123, 124, 125, 126, 127, 128,
129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
139, 140, 141, 142, 144, 145, 146, 147, 149, 150,
152, 154, 155, 156, 158, 159, 160, 161, 162, 164,
165
};
#endif
@ -1987,295 +1987,295 @@ yyreduce:
break;
case 52: /* Stmt: LVal ASSIGN Exp SEMICOLON */
#line 112 "parser.y"
#line 107 "parser.y"
{(yyval.node_val) = new_node(Stmt,(yyvsp[-3].node_val),NULL,(yyvsp[-1].node_val),0,0,NULL,NonType);}
#line 1993 "parser.c"
break;
case 53: /* Stmt: Exp SEMICOLON */
#line 113 "parser.y"
#line 108 "parser.y"
{(yyval.node_val) = new_node(Stmt,NULL,NULL,(yyvsp[-1].node_val),0,0,NULL,NonType);}
#line 1999 "parser.c"
break;
case 54: /* Stmt: SEMICOLON */
#line 114 "parser.y"
#line 109 "parser.y"
{(yyval.node_val) = NULL;}
#line 2005 "parser.c"
break;
case 55: /* Stmt: Block */
#line 115 "parser.y"
#line 110 "parser.y"
{(yyval.node_val) = new_node(Stmt,NULL,NULL,(yyvsp[0].node_val),0,0,NULL,NonType);}
#line 2011 "parser.c"
break;
case 56: /* Stmt: IF LP Cond RP Stmt */
#line 116 "parser.y"
#line 111 "parser.y"
{(yyval.node_val) = new_node(Stmt,(yyvsp[-2].node_val),NULL,(yyvsp[0].node_val),0,0,NULL,NonType);}
#line 2017 "parser.c"
break;
case 57: /* Stmt: IF LP Cond RP Stmt ELSE Stmt */
#line 117 "parser.y"
#line 112 "parser.y"
{(yyval.node_val) = new_node(Stmt,(yyvsp[-4].node_val),(yyvsp[0].node_val),(yyvsp[-2].node_val),0,0,NULL,NonType);}
#line 2023 "parser.c"
break;
case 58: /* Stmt: WHILE LP Cond RP Stmt */
#line 118 "parser.y"
#line 113 "parser.y"
{(yyval.node_val) = new_node(Stmt,(yyvsp[-2].node_val),NULL,(yyvsp[0].node_val),0,0,NULL,NonType);}
#line 2029 "parser.c"
break;
case 59: /* Stmt: BREAK SEMICOLON */
#line 119 "parser.y"
#line 114 "parser.y"
{(yyval.node_val) = NULL;}
#line 2035 "parser.c"
break;
case 60: /* Stmt: CONTINUE SEMICOLON */
#line 120 "parser.y"
#line 115 "parser.y"
{(yyval.node_val) = NULL;}
#line 2041 "parser.c"
break;
case 61: /* Stmt: RETURN SEMICOLON */
#line 121 "parser.y"
#line 116 "parser.y"
{(yyval.node_val) = NULL;}
#line 2047 "parser.c"
break;
case 62: /* Stmt: RETURN Exp SEMICOLON */
#line 122 "parser.y"
#line 117 "parser.y"
{(yyval.node_val) = new_node(Stmt,NULL,NULL,(yyvsp[-1].node_val),0,0,NULL,NonType);}
#line 2053 "parser.c"
break;
case 63: /* Exp: AddExp */
#line 127 "parser.y"
#line 122 "parser.y"
{ (yyval.node_val) = new_node(Exp, NULL, NULL, (yyvsp[0].node_val), 0, 0, NULL, NonType); }
#line 2059 "parser.c"
break;
case 64: /* AddExp: MulExp */
#line 128 "parser.y"
#line 123 "parser.y"
{ (yyval.node_val) = new_node(AddExp, NULL, NULL, (yyvsp[0].node_val), MUL, 0, NULL, NonType); }
#line 2065 "parser.c"
break;
case 65: /* AddExp: MulExp PLUS AddExp */
#line 129 "parser.y"
#line 124 "parser.y"
{ (yyval.node_val) = new_node(AddExp, (yyvsp[0].node_val), NULL, (yyvsp[-2].node_val), PLUS, 0, NULL, NonType); }
#line 2071 "parser.c"
break;
case 66: /* AddExp: MulExp MINUS AddExp */
#line 130 "parser.y"
#line 125 "parser.y"
{ (yyval.node_val) = new_node(AddExp, (yyvsp[0].node_val), NULL, (yyvsp[-2].node_val), MINUS, 0, NULL, NonType); }
#line 2077 "parser.c"
break;
case 67: /* MulExp: UnaryExp */
#line 131 "parser.y"
#line 126 "parser.y"
{ (yyval.node_val) = new_node(MulExp, NULL, NULL, (yyvsp[0].node_val), UnaryExp, 0, NULL, NonType); }
#line 2083 "parser.c"
break;
case 68: /* MulExp: UnaryExp MUL MulExp */
#line 132 "parser.y"
#line 127 "parser.y"
{ (yyval.node_val) = new_node(MulExp, (yyvsp[0].node_val), NULL, (yyvsp[-2].node_val), MUL, 0, NULL, NonType); }
#line 2089 "parser.c"
break;
case 69: /* MulExp: UnaryExp DIV MulExp */
#line 133 "parser.y"
#line 128 "parser.y"
{ (yyval.node_val) = new_node(MulExp, (yyvsp[0].node_val), NULL, (yyvsp[-2].node_val), DIV, 0, NULL, NonType); }
#line 2095 "parser.c"
break;
case 70: /* MulExp: UnaryExp MOD MulExp */
#line 134 "parser.y"
#line 129 "parser.y"
{ (yyval.node_val) = new_node(MulExp, (yyvsp[0].node_val), NULL, (yyvsp[-2].node_val), MOD, 0, NULL, NonType); }
#line 2101 "parser.c"
break;
case 71: /* UnaryExp: PrimaryExp */
#line 135 "parser.y"
#line 130 "parser.y"
{ (yyval.node_val) = new_node(UnaryExp, NULL, NULL, (yyvsp[0].node_val), PrimaryExp, 0, NULL, NonType); }
#line 2107 "parser.c"
break;
case 72: /* UnaryExp: ID LP RP */
#line 136 "parser.y"
#line 131 "parser.y"
{ (yyval.node_val) = new_node(UnaryExp, NULL, NULL, NULL, FuncRParams, 0, (yyvsp[-2].str_val), NonType); }
#line 2113 "parser.c"
break;
case 73: /* UnaryExp: ID LP FuncRParams RP */
#line 137 "parser.y"
#line 132 "parser.y"
{ (yyval.node_val) = new_node(UnaryExp, NULL, NULL, (yyvsp[-1].node_val), FuncRParams, 0, (yyvsp[-3].str_val), NonType); }
#line 2119 "parser.c"
break;
case 74: /* UnaryExp: PLUS UnaryExp */
#line 138 "parser.y"
#line 133 "parser.y"
{ (yyval.node_val) = new_node(UnaryExp, NULL, NULL, (yyvsp[0].node_val), Plus, 0, NULL, NonType); }
#line 2125 "parser.c"
break;
case 75: /* UnaryExp: MINUS UnaryExp */
#line 139 "parser.y"
#line 134 "parser.y"
{ (yyval.node_val) = new_node(UnaryExp, NULL, NULL, (yyvsp[0].node_val), Minus, 0, NULL, NonType); }
#line 2131 "parser.c"
break;
case 76: /* UnaryExp: NOT UnaryExp */
#line 140 "parser.y"
#line 135 "parser.y"
{ (yyval.node_val) = new_node(UnaryExp, NULL, NULL, (yyvsp[0].node_val), NOT, 0, NULL, NonType); }
#line 2137 "parser.c"
break;
case 77: /* FuncRParams: Exp */
#line 141 "parser.y"
#line 136 "parser.y"
{ (yyval.node_val) = new_node(FuncRParams, NULL, NULL, (yyvsp[0].node_val), 0, 0, NULL, NonType); }
#line 2143 "parser.c"
break;
case 78: /* FuncRParams: Exp COMMA FuncRParams */
#line 142 "parser.y"
#line 137 "parser.y"
{ (yyval.node_val) = new_node(FuncRParams, (yyvsp[0].node_val), NULL, (yyvsp[-2].node_val), 0, 0, NULL, NonType); }
#line 2149 "parser.c"
break;
case 79: /* PrimaryExp: LP Exp RP */
#line 143 "parser.y"
#line 138 "parser.y"
{ (yyval.node_val) = new_node(PrimaryExp, NULL, NULL, (yyvsp[-1].node_val), Exp, 0, NULL, NonType); }
#line 2155 "parser.c"
break;
case 80: /* PrimaryExp: LVal */
#line 144 "parser.y"
#line 139 "parser.y"
{ (yyval.node_val) = new_node(PrimaryExp, NULL, NULL, (yyvsp[0].node_val), LVal, 0, NULL, NonType); }
#line 2161 "parser.c"
break;
case 81: /* PrimaryExp: INT_LIT */
#line 145 "parser.y"
#line 140 "parser.y"
{ (yyval.node_val) = new_node(PrimaryExp, NULL, NULL, NULL, (yyvsp[0].int_val), 0, NULL, Int); }
#line 2167 "parser.c"
break;
case 82: /* PrimaryExp: FLOAT_LIT */
#line 146 "parser.y"
#line 141 "parser.y"
{ (yyval.node_val) = new_node(PrimaryExp, NULL, NULL, NULL, 0, (yyvsp[0].float_val), NULL, Float); }
#line 2173 "parser.c"
break;
case 83: /* LVal: ID ExpArray */
#line 147 "parser.y"
#line 142 "parser.y"
{ (yyval.node_val) = new_node(LVal, NULL, NULL, (yyvsp[0].node_val), 0, 0, (yyvsp[-1].str_val), NonType); }
#line 2179 "parser.c"
break;
case 84: /* Cond: LOrExp */
#line 149 "parser.y"
#line 144 "parser.y"
{ (yyval.node_val) = new_node(Cond, NULL, NULL, (yyvsp[0].node_val), 0, 0, NULL, NonType); }
#line 2185 "parser.c"
break;
case 85: /* LOrExp: LAndExp */
#line 150 "parser.y"
#line 145 "parser.y"
{ (yyval.node_val) = new_node(Cond, NULL, NULL, (yyvsp[0].node_val), 0, 0, NULL, NonType); }
#line 2191 "parser.c"
break;
case 86: /* LOrExp: LAndExp OR LOrExp */
#line 151 "parser.y"
#line 146 "parser.y"
{ (yyval.node_val) = new_node(Cond, (yyvsp[0].node_val), NULL, (yyvsp[-2].node_val), OR, 0, 0, NonType); }
#line 2197 "parser.c"
break;
case 87: /* LOrExp: LNotExp */
#line 152 "parser.y"
#line 147 "parser.y"
{ (yyval.node_val) = new_node(Cond, NULL, NULL, (yyvsp[0].node_val), 0, 0, NULL, NonType); }
#line 2203 "parser.c"
break;
case 88: /* LAndExp: EqExp */
#line 154 "parser.y"
#line 149 "parser.y"
{ (yyval.node_val) = new_node(LAndExp, NULL, NULL, (yyvsp[0].node_val), 0, 0, NULL, NonType); }
#line 2209 "parser.c"
break;
case 89: /* LAndExp: EqExp AND LAndExp */
#line 155 "parser.y"
#line 150 "parser.y"
{ (yyval.node_val) = new_node(LAndExp, (yyvsp[0].node_val), NULL, (yyvsp[-2].node_val), AND, 0, NULL, NonType); }
#line 2215 "parser.c"
break;
case 90: /* LNotExp: NOT LP EqExp RP */
#line 157 "parser.y"
#line 152 "parser.y"
{ (yyval.node_val) = new_node(LNotExp, NULL, NULL, (yyvsp[-1].node_val), 0, 0, NULL, NonType);}
#line 2221 "parser.c"
break;
case 91: /* EqExp: RelExp */
#line 159 "parser.y"
#line 154 "parser.y"
{ (yyval.node_val) = new_node(EqExp, NULL, NULL, (yyvsp[0].node_val), 0, 0, NULL, NonType);}
#line 2227 "parser.c"
break;
case 92: /* EqExp: RelExp EQ EqExp */
#line 160 "parser.y"
#line 155 "parser.y"
{ (yyval.node_val) = new_node(EqExp, (yyvsp[0].node_val), NULL, (yyvsp[-2].node_val), EQ, 0, NULL, NonType); }
#line 2233 "parser.c"
break;
case 93: /* EqExp: RelExp NE EqExp */
#line 161 "parser.y"
#line 156 "parser.y"
{ (yyval.node_val) = new_node(EqExp, (yyvsp[0].node_val), NULL, (yyvsp[-2].node_val), NE, 0, NULL, NonType); }
#line 2239 "parser.c"
break;
case 94: /* RelExp: AddExp */
#line 163 "parser.y"
#line 158 "parser.y"
{ (yyval.node_val) = new_node(RelExp, NULL, NULL, (yyvsp[0].node_val), 0, 0, NULL, NonType); }
#line 2245 "parser.c"
break;
case 95: /* RelExp: AddExp LT RelExp */
#line 164 "parser.y"
#line 159 "parser.y"
{ (yyval.node_val) = new_node(RelExp, (yyvsp[0].node_val), NULL, (yyvsp[-2].node_val), LT, 0, NULL, NonType); }
#line 2251 "parser.c"
break;
case 96: /* RelExp: AddExp GT RelExp */
#line 165 "parser.y"
#line 160 "parser.y"
{ (yyval.node_val) = new_node(RelExp, (yyvsp[0].node_val), NULL, (yyvsp[-2].node_val), GT, 0, NULL, NonType);}
#line 2257 "parser.c"
break;
case 97: /* RelExp: AddExp LE RelExp */
#line 166 "parser.y"
#line 161 "parser.y"
{ (yyval.node_val) = new_node(RelExp, (yyvsp[0].node_val), NULL, (yyvsp[-2].node_val), LE, 0, NULL, NonType); }
#line 2263 "parser.c"
break;
case 98: /* RelExp: AddExp GE RelExp */
#line 167 "parser.y"
#line 162 "parser.y"
{ (yyval.node_val) = new_node(RelExp, (yyvsp[0].node_val), NULL, (yyvsp[-2].node_val), GE, 0, NULL, NonType); }
#line 2269 "parser.c"
break;
case 99: /* ExpArray: %empty */
#line 169 "parser.y"
#line 164 "parser.y"
{ (yyval.node_val) = NULL; }
#line 2275 "parser.c"
break;
case 100: /* ExpArray: LB Exp RB ExpArray */
#line 170 "parser.y"
#line 165 "parser.y"
{ (yyval.node_val) = new_node(ExpArray, (yyvsp[0].node_val), NULL, (yyvsp[-2].node_val), 0, 0, NULL, NonType); }
#line 2281 "parser.c"
break;
@ -2510,7 +2510,7 @@ yyreturnlab:
return yyresult;
}
#line 171 "parser.y"
#line 166 "parser.y"
int main(int argc, char *argv[]) {

Loading…
Cancel
Save