summaryrefslogtreecommitdiffstats
path: root/edify
diff options
context:
space:
mode:
authorDoug Zongker <dougz@android.com>2009-06-12 02:21:44 +0200
committerDoug Zongker <dougz@android.com>2009-06-12 18:40:37 +0200
commit8edb00c990e563e6f91b278a212f2edf877cf763 (patch)
treedcd6c0fb2ce82fcb5b43ed47dc74879cfe71b647 /edify
parentfix sim build in donut, too (diff)
downloadandroid_bootable_recovery-8edb00c990e563e6f91b278a212f2edf877cf763.tar
android_bootable_recovery-8edb00c990e563e6f91b278a212f2edf877cf763.tar.gz
android_bootable_recovery-8edb00c990e563e6f91b278a212f2edf877cf763.tar.bz2
android_bootable_recovery-8edb00c990e563e6f91b278a212f2edf877cf763.tar.lz
android_bootable_recovery-8edb00c990e563e6f91b278a212f2edf877cf763.tar.xz
android_bootable_recovery-8edb00c990e563e6f91b278a212f2edf877cf763.tar.zst
android_bootable_recovery-8edb00c990e563e6f91b278a212f2edf877cf763.zip
Diffstat (limited to 'edify')
-rw-r--r--edify/expr.c2
-rw-r--r--edify/main.c7
-rw-r--r--edify/parser.y10
3 files changed, 11 insertions, 8 deletions
diff --git a/edify/expr.c b/edify/expr.c
index 129fbd96b..5470a2bac 100644
--- a/edify/expr.c
+++ b/edify/expr.c
@@ -283,7 +283,7 @@ static int fn_size = 0;
NamedFunction* fn_table = NULL;
void RegisterFunction(const char* name, Function fn) {
- if (fn_entries <= fn_size) {
+ if (fn_entries >= fn_size) {
fn_size = fn_size*2 + 1;
fn_table = realloc(fn_table, fn_size * sizeof(NamedFunction));
}
diff --git a/edify/main.c b/edify/main.c
index c95968376..7da89e2ea 100644
--- a/edify/main.c
+++ b/edify/main.c
@@ -153,10 +153,11 @@ int main(int argc, char** argv) {
buffer[size] = '\0';
Expr* root;
+ int error_count = 0;
yy_scan_bytes(buffer, size);
- int error = yyparse(&root);
- printf("parse returned %d\n", error);
- if (error == 0) {
+ int error = yyparse(&root, &error_count);
+ printf("parse returned %d; %d errors encountered\n", error, error_count);
+ if (error == 0 || error_count > 0) {
char* result = Evaluate(NULL, root);
if (result == NULL) {
char* errmsg = GetError();
diff --git a/edify/parser.y b/edify/parser.y
index 67a210fca..cf163c026 100644
--- a/edify/parser.y
+++ b/edify/parser.y
@@ -25,8 +25,8 @@
extern int gLine;
extern int gColumn;
-void yyerror(Expr** root, const char* s);
-int yyparse(Expr** root);
+void yyerror(Expr** root, int* error_count, const char* s);
+int yyparse(Expr** root, int* error_count);
%}
@@ -45,6 +45,7 @@ int yyparse(Expr** root);
%type <args> arglist
%parse-param {Expr** root}
+%parse-param {int* error_count}
%error-verbose
/* declarations in increasing order of precedence */
@@ -86,7 +87,7 @@ expr: STRING {
if ($$->fn == NULL) {
char buffer[256];
snprintf(buffer, sizeof(buffer), "unknown function \"%s\"", $1);
- yyerror(root, buffer);
+ yyerror(root, error_count, buffer);
YYERROR;
}
$$->name = $1;
@@ -113,9 +114,10 @@ arglist: /* empty */ {
%%
-void yyerror(Expr** root, const char* s) {
+void yyerror(Expr** root, int* error_count, const char* s) {
if (strlen(s) == 0) {
s = "syntax error";
}
printf("line %d col %d: %s\n", gLine, gColumn, s);
+ ++*error_count;
}