mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-25 22:54:57 +02:00
parent
e8e4268a28
commit
9a49e085cd
@ -287,6 +287,7 @@ in return T_IN;
|
|||||||
}
|
}
|
||||||
|
|
||||||
[\r\n]+ { yycolumn -= strlen(yytext) - 1; if (!ignore_newlines) return T_NEWLINE; }
|
[\r\n]+ { yycolumn -= strlen(yytext) - 1; if (!ignore_newlines) return T_NEWLINE; }
|
||||||
|
<<EOF>> { if (!yyextra->m_Eof) { yyextra->m_Eof = true; return T_NEWLINE; } else { yyterminate(); } }
|
||||||
. return yytext[0];
|
. return yytext[0];
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
%{
|
%{
|
||||||
#define YYDEBUG 1
|
#define YYDEBUG 1
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Icinga 2 *
|
* Icinga 2 *
|
||||||
@ -255,7 +255,8 @@ Expression *ConfigCompiler::Compile(void)
|
|||||||
m_Expressions.push(std::vector<Expression *>());
|
m_Expressions.push(std::vector<Expression *>());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
yyparse(this);
|
if (yyparse(this) != 0)
|
||||||
|
BOOST_THROW_EXCEPTION(ConfigError("Syntax error"));
|
||||||
|
|
||||||
DictExpression *expr = new DictExpression(m_Expressions.top());
|
DictExpression *expr = new DictExpression(m_Expressions.top());
|
||||||
m_Expressions.pop();
|
m_Expressions.pop();
|
||||||
@ -278,28 +279,27 @@ Expression *ConfigCompiler::Compile(void)
|
|||||||
%}
|
%}
|
||||||
|
|
||||||
%%
|
%%
|
||||||
statements: /* empty */
|
statements: statement sep
|
||||||
| statements statement
|
| statements statement sep
|
||||||
;
|
;
|
||||||
|
|
||||||
statement: type | library | constant
|
statement: type | library | constant
|
||||||
{ }
|
|
||||||
| newlines
|
|
||||||
{ }
|
{ }
|
||||||
| lterm
|
| lterm
|
||||||
{
|
{
|
||||||
|
printf("lterm!\n");
|
||||||
m_Expressions.top().push_back($1);
|
m_Expressions.top().push_back($1);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
library: T_LIBRARY T_STRING sep
|
library: T_LIBRARY T_STRING
|
||||||
{
|
{
|
||||||
context->HandleLibrary($2);
|
context->HandleLibrary($2);
|
||||||
free($2);
|
free($2);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
constant: T_CONST identifier T_SET rterm sep
|
constant: T_CONST identifier T_SET rterm
|
||||||
{
|
{
|
||||||
VMFrame frame;
|
VMFrame frame;
|
||||||
ScriptVariable::Ptr sv = ScriptVariable::Set($2, $4->Evaluate(frame));
|
ScriptVariable::Ptr sv = ScriptVariable::Set($2, $4->Evaluate(frame));
|
||||||
@ -329,7 +329,7 @@ type: T_TYPE identifier
|
|||||||
m_Type->Register();
|
m_Type->Register();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
type_inherits_specifier typerulelist sep
|
type_inherits_specifier typerulelist
|
||||||
{
|
{
|
||||||
TypeRuleList::Ptr ruleList = *$5;
|
TypeRuleList::Ptr ruleList = *$5;
|
||||||
delete $5;
|
delete $5;
|
||||||
@ -589,7 +589,7 @@ lterm: T_LOCAL indexer combined_set_op rterm
|
|||||||
$$ = new SetExpression(*$1, $2, $3, false, DebugInfoRange(@1, @3));
|
$$ = new SetExpression(*$1, $2, $3, false, DebugInfoRange(@1, @3));
|
||||||
delete $1;
|
delete $1;
|
||||||
}
|
}
|
||||||
| T_INCLUDE rterm sep
|
| T_INCLUDE rterm
|
||||||
{
|
{
|
||||||
VMFrame frame;
|
VMFrame frame;
|
||||||
$$ = context->HandleInclude($2->Evaluate(frame), false, DebugInfoRange(@1, @2));
|
$$ = context->HandleInclude($2->Evaluate(frame), false, DebugInfoRange(@1, @2));
|
||||||
|
@ -41,7 +41,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_Path(path), m_Input(input), m_Zone(zone), m_Eof(false)
|
||||||
{
|
{
|
||||||
InitializeScanner();
|
InitializeScanner();
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,11 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
|
|
||||||
|
typedef union YYSTYPE YYSTYPE;
|
||||||
|
typedef void *yyscan_t;
|
||||||
|
|
||||||
|
int yylex(YYSTYPE *context, icinga::DebugInfo *di, yyscan_t scanner);
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -73,11 +78,14 @@ private:
|
|||||||
String m_Zone;
|
String m_Zone;
|
||||||
|
|
||||||
void *m_Scanner;
|
void *m_Scanner;
|
||||||
|
bool m_Eof;
|
||||||
|
|
||||||
static std::vector<String> m_IncludeSearchDirs;
|
static std::vector<String> m_IncludeSearchDirs;
|
||||||
|
|
||||||
void InitializeScanner(void);
|
void InitializeScanner(void);
|
||||||
void DestroyScanner(void);
|
void DestroyScanner(void);
|
||||||
|
|
||||||
|
friend int ::yylex(YYSTYPE *context, icinga::DebugInfo *di, yyscan_t scanner);
|
||||||
};
|
};
|
||||||
|
|
||||||
class I2_CONFIG_API ConfigFragmentRegistry : public Registry<ConfigFragmentRegistry, String>
|
class I2_CONFIG_API ConfigFragmentRegistry : public Registry<ConfigFragmentRegistry, String>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user