From: Sebastian Harl Date: Thu, 20 Mar 2014 07:36:54 +0000 (+0100) Subject: frontend: Let the parser not accept other grammars in default mode. X-Git-Tag: sysdb-0.1.0~171 X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=commitdiff_plain;h=df33553d47332afc7951ef6d54d0685ea26390c5 frontend: Let the parser not accept other grammars in default mode. --- diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y index f262f3e..551d171 100644 --- a/src/frontend/grammar.y +++ b/src/frontend/grammar.y @@ -87,6 +87,14 @@ sdb_fe_yyerror(YYLTYPE *lval, sdb_fe_yyscan_t scanner, const char *msg); statements: statements ';' statement { + /* only accept this in default parse mode */ + if (parser_mode != SDB_PARSE_DEFAULT) { + sdb_fe_yyerror(&yylloc, scanner, + YY_("syntax error, unexpected statement, " + "expecting expression")); + YYABORT; + } + if ($3) { sdb_llist_append(pt, SDB_OBJ($3)); sdb_object_deref(SDB_OBJ($3)); @@ -95,6 +103,14 @@ statements: | statement { + /* only accept this in default parse mode */ + if (parser_mode != SDB_PARSE_DEFAULT) { + sdb_fe_yyerror(&yylloc, scanner, + YY_("syntax error, unexpected statement, " + "expecting expression")); + YYABORT; + } + if ($1) { sdb_llist_append(pt, SDB_OBJ($1)); sdb_object_deref(SDB_OBJ($1));