From: Sebastian Harl Date: Sat, 11 Apr 2015 16:04:27 +0000 (+0200) Subject: frontend/parser: Renamed SDB_PARSE_EXPR to SDB_PARSE_ARITH. X-Git-Tag: sysdb-0.8.0~115 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=69051e83ae92193bdff1e2e95bc761147075d563;p=sysdb.git frontend/parser: Renamed SDB_PARSE_EXPR to SDB_PARSE_ARITH. That's a bit more specific ;-) --- diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y index 70e6c3c..31b71a0 100644 --- a/src/frontend/grammar.y +++ b/src/frontend/grammar.y @@ -78,7 +78,7 @@ sdb_fe_yyerrorf(YYLTYPE *lval, sdb_fe_yyscan_t scanner, const char *fmt, ...); #define MODE_TO_STRING(m) \ (((m) == SDB_PARSE_DEFAULT) ? "statement" \ : ((m) == SDB_PARSE_COND) ? "condition" \ - : ((m) == SDB_PARSE_EXPR) ? "expression" \ + : ((m) == SDB_PARSE_ARITH) ? "arithmetic expression" \ : "UNKNOWN") %} @@ -244,7 +244,7 @@ statements: expression { /* only accepted in expression parse mode */ - if (! (parser_mode & SDB_PARSE_EXPR)) { + if (! (parser_mode & SDB_PARSE_ARITH)) { sdb_fe_yyerrorf(&yylloc, scanner, YY_("syntax error, unexpected expression, " "expecting %s"), MODE_TO_STRING(parser_mode)); diff --git a/src/frontend/parser.c b/src/frontend/parser.c index c82a514..8d608d6 100644 --- a/src/frontend/parser.c +++ b/src/frontend/parser.c @@ -162,7 +162,7 @@ sdb_fe_parse_expr(const char *expr, int len, sdb_strbuf_t *errbuf) if (scanner_init(expr, len, &scanner, &yyextra, errbuf)) return NULL; - yyextra.mode = SDB_PARSE_EXPR; + yyextra.mode = SDB_PARSE_ARITH; yyres = sdb_fe_yyparse(scanner); sdb_fe_scanner_destroy(scanner); diff --git a/src/include/frontend/parser.h b/src/include/frontend/parser.h index b451ed5..7665701 100644 --- a/src/include/frontend/parser.h +++ b/src/include/frontend/parser.h @@ -39,9 +39,14 @@ extern "C" { /* parser modes */ enum { + /* parser accepts any command statement */ SDB_PARSE_DEFAULT = 0, + + /* parser accepts any conditional statement */ SDB_PARSE_COND = 1 << 1, - SDB_PARSE_EXPR = 1 << 2, + + /* parser accepts any arithmetic expression */ + SDB_PARSE_ARITH = 1 << 2, }; /* YY_EXTRA data */