summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e5d9a91)
raw | patch | inline | side by side (parent: e5d9a91)
author | Sebastian Harl <sh@tokkee.org> | |
Sat, 11 Apr 2015 16:04:27 +0000 (18:04 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sat, 11 Apr 2015 16:04:27 +0000 (18:04 +0200) |
That's a bit more specific ;-)
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 70e6c3c2dc2fe0caf07e3ce9725667fddec4f48f..31b71a0eba7665b94de03bd47c50a0cd989ff24e 100644 (file)
--- a/src/frontend/grammar.y
+++ b/src/frontend/grammar.y
#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")
%}
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 c82a514a00e7ddb4831805dafbbed8c9c618888e..8d608d6dfd53726ce7f833f1d7bc20a6f8cb984e 100644 (file)
--- a/src/frontend/parser.c
+++ b/src/frontend/parser.c
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);
index b451ed5b6e88504980c008a42d132d871d50838c..766570157e426cfdab440db1b10be8ac958d8147 100644 (file)
/* 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 */