Code

frontend: Let the parser not accept other grammars in default mode.
authorSebastian Harl <sh@tokkee.org>
Thu, 20 Mar 2014 07:36:54 +0000 (08:36 +0100)
committerSebastian Harl <sh@tokkee.org>
Thu, 20 Mar 2014 07:36:54 +0000 (08:36 +0100)
src/frontend/grammar.y

index f262f3e11d9ace504a2fa08dc4b3ef8bb7c9befe..551d1714d7a12cf86b64aea6834b4e4dd782dd89 100644 (file)
@@ -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));