icinga2/dyn/config_lexer.ll

65 lines
1.3 KiB
LLVM
Raw Normal View History

2012-05-31 08:45:02 +02:00
%{
2012-05-31 09:43:46 +02:00
#include "i2-dyn.h"
#include "config_parser.h"
2012-05-31 09:14:44 +02:00
using namespace icinga;
2012-05-31 08:45:02 +02:00
#define YY_EXTRA_TYPE ConfigContext *
#define YY_USER_ACTION yylloc->first_line = yylineno;
2012-05-31 09:43:46 +02:00
#define YY_INPUT(buf, result, max_size) \
do { \
result = yyextra->ReadInput(buf, max_size); \
2012-05-31 08:45:02 +02:00
} while (0)
%}
%option reentrant noyywrap yylineno
%option bison-bridge bison-locations
2012-05-31 09:14:44 +02:00
%option never-interactive nounistd
2012-05-31 08:45:02 +02:00
%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)
{
2012-05-31 09:43:46 +02:00
yylex_init(&m_Scanner);
yyset_extra(this, m_Scanner);
2012-05-31 08:45:02 +02:00
}
void ConfigContext::DestroyScanner(void)
{
2012-05-31 09:43:46 +02:00
yylex_destroy(m_Scanner);
2012-05-31 08:45:02 +02:00
}