From 3b0d05e8e48d43ee3cf3fe86fcdffb35a8813e63 Mon Sep 17 00:00:00 2001 From: "Stephen M. Cameron" Date: Tue, 30 Sep 2014 11:21:20 -0500 Subject: [PATCH] remove unused bye symbol from arithmetic parser Signed-off-by: Jens Axboe --- exp/expression-parser.l | 9 ++++----- exp/expression-parser.y | 21 +++++++++------------ 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/exp/expression-parser.l b/exp/expression-parser.l index 6ec08661..11eb8330 100644 --- a/exp/expression-parser.l +++ b/exp/expression-parser.l @@ -31,7 +31,7 @@ extern int lexer_input(char* buffer, int *nbytes, int buffersize); lexer_input((buffer), &(bytes_read), (bytes_requested)) extern int yyerror(long long *result, double *dresult, - int *has_error, int *units_specified, int *bye, const char *msg); + int *has_error, int *units_specified, const char *msg); static void __attribute__((unused)) yyunput(int c,char *buf_ptr); static int __attribute__((unused)) input(void); @@ -47,7 +47,6 @@ static int __attribute__((unused)) input(void); %% -bye return BYE; [kK]|[kK][bB] { set_suffix_value(yylval, 1024, 1024.0, 0); return SUFFIX; @@ -122,7 +121,7 @@ bye return BYE; yylval.v.has_error = 0; return NUMBER; } else { - yyerror(0, 0, 0, 0, 0, "bad number\n"); + yyerror(0, 0, 0, 0, "bad number\n"); yylval.v.has_error = 1; return NUMBER; } @@ -137,7 +136,7 @@ bye return BYE; yylval.v.has_error = 0; return NUMBER; } else { - yyerror(0, 0, 0, 0, 0, "bad number\n"); + yyerror(0, 0, 0, 0, "bad number\n"); yylval.v.has_error = 1; return NUMBER; } @@ -152,7 +151,7 @@ bye return BYE; yylval.v.has_error = 0; return NUMBER; } else { - yyerror(0, 0, 0, 0, 0, "bad number\n"); + yyerror(0, 0, 0, 0, "bad number\n"); yylval.v.has_error = 1; return NUMBER; } diff --git a/exp/expression-parser.y b/exp/expression-parser.y index 1cc07918..e4373d4d 100644 --- a/exp/expression-parser.y +++ b/exp/expression-parser.y @@ -38,7 +38,7 @@ int yyerror(__attribute__((unused)) long long *result, __attribute__((unused)) double *dresult, __attribute__((unused)) int *has_error, __attribute__((unused)) int *units_specified, - __attribute__((unused)) int *bye, const char *msg); + __attribute__((unused)) const char *msg); extern int yylex(void); extern void yyrestart(FILE *file); @@ -67,7 +67,6 @@ extern void yyrestart(FILE *file); %parse-param { double *dresult } %parse-param { int *has_error } %parse-param { int *units_specified } -%parse-param { int *bye } %type expression %% @@ -108,11 +107,11 @@ expression: expression '+' expression { } | expression '/' expression { if ($3.ival == 0) - yyerror(0, 0, 0, 0, 0, "divide by zero"); + yyerror(0, 0, 0, 0, "divide by zero"); else $$.ival = $1.ival / $3.ival; if ($3.dval < 1e-20 && $3.dval > -1e-20) - yyerror(0, 0, 0, 0, 0, "divide by zero"); + yyerror(0, 0, 0, 0, "divide by zero"); else $$.dval = $1.dval / $3.dval; if ($3.has_dval || $1.has_dval) @@ -139,9 +138,9 @@ expression: expression '+' expression { } | expression '%' expression { if ($1.has_dval || $3.has_dval) - yyerror(0, 0, 0, 0, 0, "modulo on floats"); + yyerror(0, 0, 0, 0, "modulo on floats"); if ($3.ival == 0) - yyerror(0, 0, 0, 0, 0, "divide by zero"); + yyerror(0, 0, 0, 0, "divide by zero"); else { $$.ival = $1.ival % $3.ival; $$.dval = $$.ival; @@ -179,8 +178,7 @@ expression: expression '+' expression { $$.ival = (long long) $$.dval; } } - | NUMBER { $$ = $1; } - | BYE { $$ = $1; *bye = 1; }; + | NUMBER { $$ = $1; }; %% #include @@ -217,12 +215,12 @@ static void setup_to_parse_string(const char *string) int evaluate_arithmetic_expression(const char *buffer, long long *ival, double *dval, double implied_units) { - int rc, units_specified = 0, bye = 0, has_error = 0; + int rc, units_specified = 0, has_error = 0; setup_to_parse_string(buffer); - rc = yyparse(ival, dval, &has_error, &units_specified, &bye); + rc = yyparse(ival, dval, &has_error, &units_specified); yyrestart(NULL); - if (rc || bye || has_error) { + if (rc || has_error) { *ival = 0; *dval = 0; has_error = 1; @@ -238,7 +236,6 @@ int yyerror(__attribute__((unused)) long long *result, __attribute__((unused)) double *dresult, __attribute__((unused)) int *has_error, __attribute__((unused)) int *units_specified, - __attribute__((unused)) int *bye, __attribute__((unused)) const char *msg) { /* We do not need to do anything here. */ -- 2.25.1