Fix parser problem with missing new-lines

refs #7822
This commit is contained in:
Gunnar Beutner 2014-11-25 08:59:55 +01:00
parent c5839b91aa
commit 9281f82ba3

View File

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