mirror of
https://github.com/Icinga/icinga2.git
synced 2025-04-08 17:05:25 +02:00
parent
11d778d881
commit
514f664980
@ -252,9 +252,9 @@ in return T_IN;
|
|||||||
\> return T_GREATER_THAN;
|
\> return T_GREATER_THAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
\( { yyextra->m_IgnoreNewlines++; return '('; }
|
\( { yyextra->m_IgnoreNewlines.push(true); return '('; }
|
||||||
\) { yyextra->m_IgnoreNewlines--; return ')'; }
|
\) { yyextra->m_IgnoreNewlines.pop(); return ')'; }
|
||||||
[\r\n]+ { yycolumn -= strlen(yytext) - 1; if (!yyextra->m_IgnoreNewlines) { return T_NEWLINE; } }
|
[\r\n]+ { yycolumn -= strlen(yytext) - 1; if (!yyextra->m_IgnoreNewlines.top()) { return T_NEWLINE; } }
|
||||||
<<EOF>> { if (!yyextra->m_Eof) { yyextra->m_Eof = true; return T_NEWLINE; } else { yyterminate(); } }
|
<<EOF>> { if (!yyextra->m_Eof) { yyextra->m_Eof = true; return T_NEWLINE; } else { yyterminate(); } }
|
||||||
. return yytext[0];
|
. return yytext[0];
|
||||||
|
|
||||||
|
@ -258,9 +258,13 @@ Expression *ConfigCompiler::Compile(void)
|
|||||||
|
|
||||||
//yydebug = 1;
|
//yydebug = 1;
|
||||||
|
|
||||||
|
m_IgnoreNewlines.push(false);
|
||||||
|
|
||||||
if (yyparse(&llist, this) != 0)
|
if (yyparse(&llist, this) != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
m_IgnoreNewlines.pop();
|
||||||
|
|
||||||
std::vector<Expression *> dlist;
|
std::vector<Expression *> dlist;
|
||||||
typedef std::pair<Expression *, EItemInfo> EListItem;
|
typedef std::pair<Expression *, EItemInfo> EListItem;
|
||||||
int num = 0;
|
int num = 0;
|
||||||
@ -733,11 +737,13 @@ rterm_array: '['
|
|||||||
|
|
||||||
rterm_scope_require_side_effect: '{'
|
rterm_scope_require_side_effect: '{'
|
||||||
{
|
{
|
||||||
|
context->m_IgnoreNewlines.push(false);
|
||||||
context->m_OpenBraces++;
|
context->m_OpenBraces++;
|
||||||
}
|
}
|
||||||
statements '}'
|
statements '}'
|
||||||
{
|
{
|
||||||
context->m_OpenBraces--;
|
context->m_OpenBraces--;
|
||||||
|
context->m_IgnoreNewlines.pop();
|
||||||
std::vector<Expression *> dlist;
|
std::vector<Expression *> dlist;
|
||||||
typedef std::pair<Expression *, EItemInfo> EListItem;
|
typedef std::pair<Expression *, EItemInfo> EListItem;
|
||||||
int num = 0;
|
int num = 0;
|
||||||
@ -754,11 +760,13 @@ rterm_scope_require_side_effect: '{'
|
|||||||
|
|
||||||
rterm_scope: '{'
|
rterm_scope: '{'
|
||||||
{
|
{
|
||||||
|
context->m_IgnoreNewlines.push(false);
|
||||||
context->m_OpenBraces++;
|
context->m_OpenBraces++;
|
||||||
}
|
}
|
||||||
statements '}'
|
statements '}'
|
||||||
{
|
{
|
||||||
context->m_OpenBraces--;
|
context->m_OpenBraces--;
|
||||||
|
context->m_IgnoreNewlines.pop();
|
||||||
std::vector<Expression *> dlist;
|
std::vector<Expression *> dlist;
|
||||||
typedef std::pair<Expression *, EItemInfo> EListItem;
|
typedef std::pair<Expression *, EItemInfo> EListItem;
|
||||||
int num = 0;
|
int num = 0;
|
||||||
|
@ -39,7 +39,7 @@ std::vector<String> ConfigCompiler::m_IncludeSearchDirs;
|
|||||||
* @param zone The zone.
|
* @param zone The zone.
|
||||||
*/
|
*/
|
||||||
ConfigCompiler::ConfigCompiler(const String& path, std::istream *input, const String& zone)
|
ConfigCompiler::ConfigCompiler(const String& path, std::istream *input, const String& zone)
|
||||||
: m_Path(path), m_Input(input), m_Zone(zone), m_Eof(false), m_OpenBraces(0), m_IgnoreNewlines(0)
|
: m_Path(path), m_Input(input), m_Zone(zone), m_Eof(false), m_OpenBraces(0)
|
||||||
{
|
{
|
||||||
InitializeScanner();
|
InitializeScanner();
|
||||||
}
|
}
|
||||||
|
@ -120,13 +120,13 @@ public:
|
|||||||
bool m_Eof;
|
bool m_Eof;
|
||||||
int m_OpenBraces;
|
int m_OpenBraces;
|
||||||
|
|
||||||
int m_IgnoreNewlines;
|
|
||||||
std::ostringstream m_LexBuffer;
|
std::ostringstream m_LexBuffer;
|
||||||
CompilerDebugInfo m_LocationBegin;
|
CompilerDebugInfo m_LocationBegin;
|
||||||
|
|
||||||
std::stack<TypeRuleList::Ptr> m_RuleLists;
|
std::stack<TypeRuleList::Ptr> m_RuleLists;
|
||||||
ConfigType::Ptr m_Type;
|
ConfigType::Ptr m_Type;
|
||||||
|
|
||||||
|
std::stack<bool> m_IgnoreNewlines;
|
||||||
std::stack<bool> m_Apply;
|
std::stack<bool> m_Apply;
|
||||||
std::stack<bool> m_ObjectAssign;
|
std::stack<bool> m_ObjectAssign;
|
||||||
std::stack<bool> m_SeenAssign;
|
std::stack<bool> m_SeenAssign;
|
||||||
|
@ -203,6 +203,10 @@ BOOST_AUTO_TEST_CASE(simple)
|
|||||||
expr = ConfigCompiler::CompileText("<test>", "\"\\'test\"");
|
expr = ConfigCompiler::CompileText("<test>", "\"\\'test\"");
|
||||||
BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError);
|
BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError);
|
||||||
delete expr;
|
delete expr;
|
||||||
|
|
||||||
|
expr = ConfigCompiler::CompileText("<test>", "({ a = 3\nb = 3 })");
|
||||||
|
BOOST_CHECK(expr->Evaluate(frame).GetValue().IsObjectType<Dictionary>());
|
||||||
|
delete expr;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(advanced)
|
BOOST_AUTO_TEST_CASE(advanced)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user