diff --git a/lib/config/config_parser.yy b/lib/config/config_parser.yy index 8072676db..445aa6077 100644 --- a/lib/config/config_parser.yy +++ b/lib/config/config_parser.yy @@ -182,7 +182,8 @@ static void MakeRBinaryOp(Expression** result, Expression *left, Expression *rig %type combined_set_op %type type %type statements -%type statement +%type lterm_items +%type lterm_items_inner %type rterm %type rterm_without_indexer %type rterm_array @@ -195,6 +196,7 @@ static void MakeRBinaryOp(Expression** result, Expression *left, Expression *rig %type use_specifier %type use_specifier_items %type use_specifier_item +%type object_declaration %right T_INCLUDE T_INCLUDE_RECURSIVE T_OBJECT T_TEMPLATE T_APPLY T_IMPORT T_ASSIGN T_IGNORE T_WHERE %right T_FUNCTION T_SIGNAL T_FOR @@ -229,8 +231,6 @@ void yyerror(YYLTYPE *locp, std::vector *, ConfigCompiler *, const int yyparse(std::vector *elist, ConfigCompiler *context); -static std::stack m_Abstract; - static std::stack m_RuleLists; static ConfigType::Ptr m_Type; @@ -245,7 +245,6 @@ static std::stack m_FTerm; Expression *ConfigCompiler::Compile(void) { - m_Abstract = std::stack(); m_RuleLists = std::stack(); m_Type.reset(); m_Apply = std::stack(); @@ -288,28 +287,53 @@ script: statements } ; -statements: statement +statements: newlines lterm_items newlines { - $$ = new std::vector(); - if ($1) - $$->push_back($1); + $$ = $2; } - | statements statement + | newlines lterm_items + { + $$ = $2; + } + | lterm_items newlines + { + $$ = $1; + } + | lterm_items { $$ = $1; - if ($2) - $$->push_back($2); } ; -statement: newlines +lterm_items: /* empty */ { - $$ = NULL; + $$ = new std::vector(); } - | lterm sep + | lterm_items_inner { $$ = $1; } + | lterm_items_inner sep + { + $$ = $1; + } + ; + +lterm_items_inner: lterm + { + $$ = new std::vector(); + $$->push_back($1); + } + | lterm_items_inner sep lterm + { + if ($1) + $$ = $1; + else + $$ = new std::vector(); + + if ($3) + $$->push_back($3); + } ; library: T_LIBRARY T_STRING @@ -439,7 +463,6 @@ type: T_TYPE_DICTIONARY object: { - m_Abstract.push(false); m_ObjectAssign.push(true); m_SeenAssign.push(false); m_Assign.push(NULL); @@ -449,8 +472,7 @@ object: { m_ObjectAssign.pop(); - bool abstract = m_Abstract.top(); - m_Abstract.pop(); + bool abstract = $2; String type = $3; free($3); @@ -486,10 +508,14 @@ object: ; object_declaration: T_OBJECT + { + $$ = false; + } | T_TEMPLATE { - m_Abstract.top() = true; + $$ = true; } + ; identifier_items: identifier_items_inner {