diff options
Diffstat (limited to '')
-rw-r--r-- | edify/Android.mk | 2 | ||||
-rw-r--r-- | edify/expr.c | 2 | ||||
-rw-r--r-- | edify/expr.h | 2 | ||||
-rw-r--r-- | edify/main.c | 7 | ||||
-rw-r--r-- | edify/parser.y | 9 |
5 files changed, 15 insertions, 7 deletions
diff --git a/edify/Android.mk b/edify/Android.mk index fac0ba712..61ed6fa17 100644 --- a/edify/Android.mk +++ b/edify/Android.mk @@ -23,6 +23,7 @@ LOCAL_SRC_FILES := \ LOCAL_CFLAGS := $(edify_cflags) -g -O0 LOCAL_MODULE := edify LOCAL_YACCFLAGS := -v +LOCAL_CFLAGS += -Wno-unused-parameter include $(BUILD_HOST_EXECUTABLE) @@ -34,6 +35,7 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := $(edify_src_files) LOCAL_CFLAGS := $(edify_cflags) +LOCAL_CFLAGS += -Wno-unused-parameter LOCAL_MODULE := libedify include $(BUILD_STATIC_LIBRARY) diff --git a/edify/expr.c b/edify/expr.c index a2f1f99d7..79f6282d8 100644 --- a/edify/expr.c +++ b/edify/expr.c @@ -287,13 +287,11 @@ Value* LessThanIntFn(const char* name, State* state, int argc, Expr* argv[]) { long l_int = strtol(left, &end, 10); if (left[0] == '\0' || *end != '\0') { - printf("[%s] is not an int\n", left); goto done; } long r_int = strtol(right, &end, 10); if (right[0] == '\0' || *end != '\0') { - printf("[%s] is not an int\n", right); goto done; } diff --git a/edify/expr.h b/edify/expr.h index 0d8ed8f57..a9ed2f9c5 100644 --- a/edify/expr.h +++ b/edify/expr.h @@ -164,6 +164,8 @@ Value* StringValue(char* str); // Free a Value object. void FreeValue(Value* v); +int parse_string(const char* str, Expr** root, int* error_count); + #ifdef __cplusplus } // extern "C" #endif diff --git a/edify/main.c b/edify/main.c index 9e6bab7ca..b3fad53b8 100644 --- a/edify/main.c +++ b/edify/main.c @@ -30,9 +30,7 @@ int expect(const char* expr_str, const char* expected, int* errors) { printf("."); - yy_scan_string(expr_str); - int error_count = 0; - error = yyparse(&e, &error_count); + int error_count = parse_string(expr_str, &e, &error_count); if (error > 0 || error_count > 0) { printf("error parsing \"%s\" (%d errors)\n", expr_str, error_count); @@ -193,8 +191,7 @@ int main(int argc, char** argv) { Expr* root; int error_count = 0; - yy_scan_bytes(buffer, size); - int error = yyparse(&root, &error_count); + int error = parse_string(buffer, &root, &error_count); printf("parse returned %d; %d errors encountered\n", error, error_count); if (error == 0 || error_count > 0) { diff --git a/edify/parser.y b/edify/parser.y index 3f9ade144..f8fb2d12f 100644 --- a/edify/parser.y +++ b/edify/parser.y @@ -29,6 +29,10 @@ extern int gColumn; void yyerror(Expr** root, int* error_count, const char* s); int yyparse(Expr** root, int* error_count); +struct yy_buffer_state; +void yy_switch_to_buffer(struct yy_buffer_state* new_buffer); +struct yy_buffer_state* yy_scan_string(const char* yystr); + %} %locations @@ -128,3 +132,8 @@ void yyerror(Expr** root, int* error_count, const char* s) { printf("line %d col %d: %s\n", gLine, gColumn, s); ++*error_count; } + +int parse_string(const char* str, Expr** root, int* error_count) { + yy_switch_to_buffer(yy_scan_string(str)); + return yyparse(root, error_count); +} |