summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 33d51d5)
raw | patch | inline | side by side (parent: 33d51d5)
author | Sebastian Harl <sh@tokkee.org> | |
Tue, 22 Jul 2014 06:17:20 +0000 (08:17 +0200) | ||
committer | Sebastian 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 | patch | blob | history | |
src/frontend/parser.c | patch | blob | history | |
src/include/frontend/parser.h | patch | blob | history |
diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y
index d5054854c3153a1298a238ad1bee2026a965cd51..a607ee0aba96bd0698147b81e0d441ab55182451 100644 (file)
--- a/src/frontend/grammar.y
+++ b/src/frontend/grammar.y
fetch_statement
list_statement
lookup_statement
- expression
+ condition
%type <m> matcher
compare_matcher
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;
}
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;
}
}
}
|
- 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;
;
/*
- * 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")) {
}
;
-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 76382d34b099756b09348e0afa67ab013a9ab7ca..0e0534e4af3c9c0be6bb93c5ed1dfda319cf75b1 100644 (file)
--- a/src/frontend/parser.c
+++ b/src/frontend/parser.c
} /* 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;
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)
/* parser modes */
enum {
SDB_PARSE_DEFAULT = 0,
- SDB_PARSE_EXPR,
+ SDB_PARSE_COND,
};
/* YY_EXTRA data */
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" */