Code

Cleaned up nomenclature in the parser.
authorSebastian Harl <sh@tokkee.org>
Tue, 22 Jul 2014 06:17:20 +0000 (08:17 +0200)
committerSebastian Harl <sh@tokkee.org>
Tue, 22 Jul 2014 06:17:20 +0000 (08:17 +0200)
Replace the generic "expression" with "condition".

src/frontend/grammar.y
src/frontend/parser.c
src/include/frontend/parser.h

index d5054854c3153a1298a238ad1bee2026a965cd51..a607ee0aba96bd0698147b81e0d441ab55182451 100644 (file)
@@ -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 <m> 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 <type> WHERE <expression>;
+ * LOOKUP <type> WHERE <condition>;
  *
- * Returns detailed information about <type> matching expression.
+ * Returns detailed information about <type> 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;
                        }
 
index 76382d34b099756b09348e0afa67ab013a9ab7ca..0e0534e4af3c9c0be6bb93c5ed1dfda319cf75b1 100644 (file)
@@ -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);
index 738071b75da0344a9b09e48cdc3e2d4226ea6135..c5fb4ab1207f399d5429923faa3c8181a39b66d2 100644 (file)
@@ -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" */