ref: 298745960166f4881f8203e9353b36a9f5603ef1
parent: 84df6c68740f97dcd4ecac1b364987b6aa256fba
author: Roberto E. Vargas Caballero <[email protected]>
date: Wed Aug 29 16:00:16 EDT 2012
Making exp return NULL if doesn't match a expression This is really usefull because this means we can call expr() for example in the for statement without be worried about if the expression will be empty or not (it is also usefull in the case of return, where you can call it without be worried).
--- a/expr.c
+++ b/expr.c
@@ -29,7 +29,8 @@
expect(')');
break;
default:
- error("unexpected element");
+ np = NULL;
+ break;
}
return np;
}
--- a/flow.c
+++ b/flow.c
@@ -85,11 +85,11 @@
expect(FOR);
expect('(');
- exp1 = (yytoken != ';') ? expr() : NULL;
+ exp1 = expr();
expect(';');
- exp2 = (yytoken != ';') ? expr() : NULL;
+ exp2 = expr();
expect(';');
- exp3 = (yytoken != ')') ? expr() : NULL;
+ exp3 = expr();
expect(')');
push(OFOR);