From: Sebastian Harl Date: Tue, 22 Jul 2014 06:17:20 +0000 (+0200) Subject: Cleaned up nomenclature in the parser. X-Git-Tag: sysdb-0.3.0~28^2~1 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6b0247f801726c7536e0fa1a22aef88d15205b3a;p=sysdb.git Cleaned up nomenclature in the parser. Replace the generic "expression" with "condition". --- diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y index d505485..a607ee0 100644 --- a/src/frontend/grammar.y +++ b/src/frontend/grammar.y @@ -110,7 +110,7 @@ sdb_fe_yyerror(YYLTYPE *lval, sdb_fe_yyscan_t scanner, const char *msg); fetch_statement list_statement lookup_statement - expression + condition %type matcher compare_matcher @@ -131,7 +131,7 @@ statements: if (parser_mode != SDB_PARSE_DEFAULT) { sdb_fe_yyerror(&yylloc, scanner, YY_("syntax error, unexpected statement, " - "expecting expression")); + "expecting condition")); sdb_object_deref(SDB_OBJ($3)); YYABORT; } @@ -148,7 +148,7 @@ statements: if (parser_mode != SDB_PARSE_DEFAULT) { sdb_fe_yyerror(&yylloc, scanner, YY_("syntax error, unexpected statement, " - "expecting expression")); + "expecting condition")); sdb_object_deref(SDB_OBJ($1)); YYABORT; } @@ -159,12 +159,12 @@ statements: } } | - expression + condition { - /* only accept this in expression parse mode */ - if (! (parser_mode & SDB_PARSE_EXPR)) { + /* only accept this in condition parse mode */ + if (! (parser_mode & SDB_PARSE_COND)) { sdb_fe_yyerror(&yylloc, scanner, - YY_("syntax error, unexpected expression, " + YY_("syntax error, unexpected condition, " "expecting statement")); sdb_object_deref(SDB_OBJ($1)); YYABORT; @@ -221,12 +221,12 @@ list_statement: ; /* - * LOOKUP WHERE ; + * LOOKUP WHERE ; * - * Returns detailed information about matching expression. + * Returns detailed information about matching condition. */ lookup_statement: - LOOKUP IDENTIFIER WHERE expression + LOOKUP IDENTIFIER WHERE condition { /* TODO: support other types as well */ if (strcasecmp($2, "hosts")) { @@ -247,13 +247,13 @@ lookup_statement: } ; -expression: +condition: matcher { if (! $1) { /* TODO: improve error reporting */ sdb_fe_yyerror(&yylloc, scanner, - YY_("syntax error, invalid expression")); + YY_("syntax error, invalid condition")); YYABORT; } diff --git a/src/frontend/parser.c b/src/frontend/parser.c index 76382d3..0e0534e 100644 --- a/src/frontend/parser.c +++ b/src/frontend/parser.c @@ -88,7 +88,7 @@ sdb_fe_parse(const char *query, int len) } /* sdb_fe_parse */ sdb_store_matcher_t * -sdb_fe_parse_matcher(const char *expr, int len) +sdb_fe_parse_matcher(const char *cond, int len) { sdb_fe_yyscan_t scanner; sdb_fe_yyextra_t yyextra; @@ -98,10 +98,10 @@ sdb_fe_parse_matcher(const char *expr, int len) int yyres; - if (scanner_init(expr, len, &scanner, &yyextra)) + if (scanner_init(cond, len, &scanner, &yyextra)) return NULL; - yyextra.mode = SDB_PARSE_EXPR; + yyextra.mode = SDB_PARSE_COND; 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 738071b..c5fb4ab 100644 --- a/src/include/frontend/parser.h +++ b/src/include/frontend/parser.h @@ -38,7 +38,7 @@ extern "C" { /* parser modes */ enum { SDB_PARSE_DEFAULT = 0, - SDB_PARSE_EXPR, + SDB_PARSE_COND, }; /* YY_EXTRA data */ @@ -63,7 +63,7 @@ int sdb_fe_yyparse(sdb_fe_yyscan_t scanner); sdb_store_matcher_t * -sdb_fe_parse_matcher(const char *expr, int len); +sdb_fe_parse_matcher(const char *cond, int len); #ifdef __cplusplus } /* extern "C" */