mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-16 18:24:31 +02:00
Refactored parser.
This commit is contained in:
parent
4bd4280737
commit
30f5de3dc4
@ -1,7 +1,6 @@
|
|||||||
#include <iostream>
|
#include "i2-configfile.h"
|
||||||
#include "configcontext.h"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace icinga;
|
||||||
|
|
||||||
ConfigContext::ConfigContext(istream *input)
|
ConfigContext::ConfigContext(istream *input)
|
||||||
{
|
{
|
||||||
|
@ -1,13 +1,35 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* Icinga 2 *
|
||||||
|
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License *
|
||||||
|
* as published by the Free Software Foundation; either version 2 *
|
||||||
|
* of the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the Free Software Foundation *
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIGCONTEXT_H
|
#ifndef CONFIGCONTEXT_H
|
||||||
#define CONFIGCONTEXT_H
|
#define CONFIGCONTEXT_H
|
||||||
|
|
||||||
|
namespace icinga
|
||||||
|
{
|
||||||
|
|
||||||
class ConfigContext
|
class ConfigContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ConfigContext(std::istream *input = &std::cin);
|
ConfigContext(istream *input = &cin);
|
||||||
virtual ~ConfigContext(void);
|
virtual ~ConfigContext(void);
|
||||||
|
|
||||||
std::istream *Input;
|
istream *Input;
|
||||||
void *Scanner;
|
void *Scanner;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -15,6 +37,8 @@ private:
|
|||||||
void DestroyScanner(void);
|
void DestroyScanner(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
int icingaparse(ConfigContext *context);
|
}
|
||||||
|
|
||||||
|
int yyparse(icinga::ConfigContext *context);
|
||||||
|
|
||||||
#endif /* CONFIGCONTEXT_H */
|
#endif /* CONFIGCONTEXT_H */
|
||||||
|
@ -11,11 +11,20 @@
|
|||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="configcontext.cpp" />
|
||||||
<ClCompile Include="configfilecomponent.cpp" />
|
<ClCompile Include="configfilecomponent.cpp" />
|
||||||
|
<ClCompile Include="icinga_lexer.cc" />
|
||||||
|
<ClCompile Include="icinga_parser.cc" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="configcontext.h" />
|
||||||
<ClInclude Include="configfilecomponent.h" />
|
<ClInclude Include="configfilecomponent.h" />
|
||||||
<ClInclude Include="i2-configfile.h" />
|
<ClInclude Include="i2-configfile.h" />
|
||||||
|
<ClInclude Include="icinga_parser.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="icinga_lexer.ll" />
|
||||||
|
<None Include="icinga_parser.yy" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{E58F1DA7-B723-412B-B2B7-7FF58E2A944E}</ProjectGuid>
|
<ProjectGuid>{E58F1DA7-B723-412B-B2B7-7FF58E2A944E}</ProjectGuid>
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <i2-base.h>
|
#include <i2-base.h>
|
||||||
#include <i2-icinga.h>
|
#include <i2-icinga.h>
|
||||||
|
|
||||||
|
#include "configcontext.h"
|
||||||
#include "configfilecomponent.h"
|
#include "configfilecomponent.h"
|
||||||
|
|
||||||
#endif /* I2CONFIGFILECOMPONENT_H */
|
#endif /* I2CONFIGFILECOMPONENT_H */
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
%{
|
%{
|
||||||
#include <iostream>
|
#include "i2-configfile.h"
|
||||||
#include "configcontext.h"
|
|
||||||
#include "icinga_parser.h"
|
using namespace icinga;
|
||||||
|
|
||||||
#define YY_EXTRA_TYPE ConfigContext *
|
#define YY_EXTRA_TYPE ConfigContext *
|
||||||
#define YY_USER_ACTION yylloc->first_line = yylineno;
|
#define YY_USER_ACTION yylloc->first_line = yylineno;
|
||||||
@ -11,13 +11,11 @@ do { \
|
|||||||
yyextra->Input->read(buf, max_size); \
|
yyextra->Input->read(buf, max_size); \
|
||||||
result = yyextra->Input->gcount(); \
|
result = yyextra->Input->gcount(); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define YY_NO_UNISTD_H
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%option reentrant noyywrap yylineno
|
%option reentrant noyywrap yylineno
|
||||||
%option bison-bridge bison-locations
|
%option bison-bridge bison-locations
|
||||||
%option never-interactive
|
%option never-interactive nounistd
|
||||||
|
|
||||||
%x IN_C_COMMENT
|
%x IN_C_COMMENT
|
||||||
|
|
||||||
|
@ -28,8 +28,9 @@
|
|||||||
%token T_INHERITS
|
%token T_INHERITS
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include <iostream>
|
#include "i2-configfile.h"
|
||||||
#include "configcontext.h"
|
|
||||||
|
using namespace icinga;
|
||||||
|
|
||||||
int yylex(YYSTYPE *lvalp, YYLTYPE *llocp, void *scanner);
|
int yylex(YYSTYPE *lvalp, YYLTYPE *llocp, void *scanner);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user