Skip to content

Commit 5f21a1f

Browse files
committed
[Add,Opti] add void return, optimize yyerror
1 parent af078ee commit 5f21a1f

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Eeyore/Eeyore.y

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,8 @@ while_stmt : WHILE '(' expr ')' stmt { $$ = new WhileStmt($3, $5);}
180180
;
181181

182182
return_stmt : RETURN expr ';' { $$ = new ReturnStmt($2); }
183-
/* disable empty return stmt
184-
| RETURN ';'
185-
*/
183+
| RETURN ';' { $$ = new ReturnStmt(); }
184+
186185
;
187186

188187
expr : IDENTIFIER '=' expr
@@ -256,7 +255,7 @@ type : TOKINT /* only provide int type currently */
256255

257256
void yyerror(const char *s)
258257
{
259-
fprintf(stderr, "Line: %d -- %s\n", yylineno, s);
258+
fprintf(stderr, "Line: %d -- " BOLD_KRED "Error: " KNRM "%s\n", yylineno, s);
260259
}
261260

262261
void yydebug(const char *s)

0 commit comments

Comments
 (0)