pkglib_LTLIBRARIES = \
configfile.la
+BUILD_SOURCES = icinga_parser.h
+
+AM_YFLAGS = -d
+
configfile_la_SOURCES = \
+ configcontext.cpp \
+ configcontext.h \
configfilecomponent.cpp \
configfilecomponent.h \
+ icinga_lexer.ll \
+ icinga_parser.yy \
i2-configfile.h
configfile_la_CPPFLAGS = \
--- /dev/null
+#include <iostream>
+#include "configcontext.h"
+
+using namespace std;
+
+ConfigContext::ConfigContext(istream *input)
+{
+ Input = input;
+ InitializeScanner();
+}
+
+ConfigContext::~ConfigContext(void)
+{
+ DestroyScanner();
+}
+
--- /dev/null
+#ifndef CONFIGCONTEXT_H
+#define CONFIGCONTEXT_H
+
+class ConfigContext
+{
+public:
+ ConfigContext(std::istream *input = &std::cin);
+ virtual ~ConfigContext(void);
+
+ std::istream *Input;
+ void *Scanner;
+
+private:
+ void InitializeScanner(void);
+ void DestroyScanner(void);
+};
+
+int icingaparse(ConfigContext *context);
+
+#endif /* CONFIGCONTEXT_H */
--- /dev/null
+%{
+#include <iostream>
+#include "configcontext.h"
+#include "icinga.tab.h"
+
+#define YY_EXTRA_TYPE ConfigContext *
+#define YY_USER_ACTION yylloc->first_line = yylineno;
+
+#define YY_INPUT(buf, result, max_size) \
+do { \
+ yyextra->Input->read(buf, max_size); \
+ result = yyextra->Input->gcount(); \
+} while (0)
+%}
+
+%option reentrant noyywrap yylineno
+%option prefix="icinga"
+%option bison-bridge bison-locations
+
+%x IN_C_COMMENT
+
+%%
+abstract return T_ABSTRACT;
+local return T_LOCAL;
+object return T_OBJECT;
+include return T_INCLUDE;
+inherits return T_INHERITS;
+[a-zA-Z][a-zA-Z0-9]* return T_IDENTIFIER;
+\"[^\"]+\" { yytext[yyleng-1] = '\0'; yylval->text = strdup(yytext + 1); return T_STRING; }
+[0-9]+ { yylval->num = atoi(yytext); return T_NUMBER; }
+\{ return T_OPEN_BRACE;
+\} return T_CLOSE_BRACE;
+\[ return T_OPEN_BRACKET;
+\] return T_CLOSE_BRACKET;
+, return T_COMMA;
+= return T_EQUAL;
+
+<INITIAL>{
+"/*" BEGIN(IN_C_COMMENT);
+}
+
+<IN_C_COMMENT>{
+"*/" BEGIN(INITIAL);
+[^*]+ /* ignore comment */
+"*" /* ignore star */
+}
+
+\/\/[^\n]+ /* ignore C++-style comments */
+#[^\n]+ /* ignore shell-style comments */
+[ \t\n]+ /* ignore whitespace */
+%%
+
+
+void ConfigContext::InitializeScanner(void)
+{
+ yylex_init(&Scanner);
+ yyset_extra(this, Scanner);
+}
+
+void ConfigContext::DestroyScanner(void)
+{
+ yylex_destroy(Scanner);
+}
+
--- /dev/null
+%pure-parser
+%name-prefix="icinga"
+
+%locations
+%defines
+%error-verbose
+
+%parse-param { ConfigContext *context }
+%lex-param { void *scanner }
+
+%union {
+ char *text;
+ int num;
+}
+
+%token <text> T_STRING
+%token <num> T_NUMBER
+%token T_IDENTIFIER
+%token T_OPEN_BRACE
+%token T_CLOSE_BRACE
+%token T_OPEN_BRACKET
+%token T_CLOSE_BRACKET
+%token T_EQUAL
+%token T_COMMA
+%token T_ABSTRACT
+%token T_LOCAL
+%token T_OBJECT
+%token T_INCLUDE
+%token T_INHERITS
+
+%{
+#include <iostream>
+#include "configcontext.h"
+
+int icingalex(YYSTYPE *lvalp, YYLTYPE *llocp, void *scanner);
+
+void icingaerror(YYLTYPE *locp, ConfigContext *context, const char *err)
+{
+ std::cout << locp->first_line << ":" << locp->first_column
+ << "-"
+ << locp->last_line << ":" << locp->last_column
+ << ": " << err << std::endl;
+}
+
+#define scanner context->Scanner
+
+%}
+
+%%
+statements: /* empty */
+ | statements statement
+ ;
+
+statement: object | include
+ ;
+
+include: T_INCLUDE T_STRING
+ ;
+
+object: attributes_list object_declaration
+ | object_declaration
+ ;
+
+object_declaration: T_OBJECT T_IDENTIFIER T_STRING inherits_specifier dictionary
+ ;
+
+attributes_list: attributes_list attribute
+ | attribute
+ ;
+
+attribute: T_ABSTRACT
+ | T_LOCAL
+ ;
+
+inherits_list: T_STRING
+ | inherits_list T_COMMA T_STRING
+ ;
+
+inherits_specifier: /* empty */
+ | T_INHERITS inherits_list
+ ;
+
+dictionary: T_OPEN_BRACE nvpairs T_CLOSE_BRACE
+ ;
+
+nvpairs: /* empty */
+ | nvpair
+ | nvpairs T_COMMA nvpair
+ ;
+
+nvpair: T_IDENTIFIER T_EQUAL value
+ ;
+
+value: T_STRING | T_NUMBER | array | dictionary
+ ;
+
+array: T_OPEN_BRACKET arrayitems T_CLOSE_BRACKET
+ ;
+
+arrayitems:
+ /* empty */
+ | value
+ | arrayitems T_COMMA value
+ ;
+%%
DX_INIT_DOXYGEN([icinga], [Doxyfile], [doc])
AC_PROG_INSTALL
+AM_PROG_LEX
+AC_PROG_YACC
AC_PROG_LIBTOOL
AX_CXX_COMPILE_STDCXX_0X
AX_CXX_GCC_ABI_DEMANGLE