yylloc->FirstLine = yyextra->m_LocationBegin.FirstLine;
yylloc->FirstColumn = yyextra->m_LocationBegin.FirstColumn;
- std::string str = yyextra->m_LexBuffer.str();
- yylval->text = strdup(str.c_str());
+ yylval->text = new String(yyextra->m_LexBuffer.str());
return T_STRING;
}
yylloc->FirstLine = yyextra->m_LocationBegin.FirstLine;
yylloc->FirstColumn = yyextra->m_LocationBegin.FirstColumn;
- std::string str = yyextra->m_LexBuffer.str();
- yylval->text = strdup(str.c_str());
+ yylval->text = new String(yyextra->m_LexBuffer.str());
return T_STRING;
}
\|\| return T_LOGICAL_OR;
\{\{ return T_NULLARY_LAMBDA_BEGIN;
\}\} return T_NULLARY_LAMBDA_END;
-[a-zA-Z_][a-zA-Z0-9\_]* { yylval->text = strdup(yytext); return T_IDENTIFIER; }
-@[a-zA-Z_][a-zA-Z0-9\_]* { yylval->text = strdup(yytext + 1); return T_IDENTIFIER; }
-\<[^ \>]*\> { yytext[yyleng-1] = '\0'; yylval->text = strdup(yytext + 1); return T_STRING_ANGLE; }
+[a-zA-Z_][a-zA-Z0-9\_]* { yylval->text = new String(yytext); return T_IDENTIFIER; }
+@[a-zA-Z_][a-zA-Z0-9\_]* { yylval->text = new String(yytext + 1); return T_IDENTIFIER; }
+\<[^ \>]*\> { yytext[yyleng-1] = '\0'; yylval->text = new String(yytext + 1); return T_STRING_ANGLE; }
[0-9]+(\.[0-9]+)?ms { yylval->num = strtod(yytext, NULL) / 1000; return T_NUMBER; }
[0-9]+(\.[0-9]+)?d { yylval->num = strtod(yytext, NULL) * 60 * 60 * 24; return T_NUMBER; }
[0-9]+(\.[0-9]+)?h { yylval->num = strtod(yytext, NULL) * 60 * 60; return T_NUMBER; }
%lex-param { void *scanner }
%union {
- char *text;
+ String *text;
double num;
bool boolean;
icinga::Expression *expr;
bool abstract = $2;
- String type = $3;
- free($3);
+ String type = *$3;
+ delete $3;
$6->MakeInline();
identifier_items_inner: identifier
{
$$ = new std::vector<String>();
- $$->push_back($1);
- free($1);
+ $$->push_back(*$1);
+ delete $1;
}
| identifier_items_inner ',' identifier
{
else
$$ = new std::vector<String>();
- $$->push_back($3);
- free($3);
+ $$->push_back(*$3);
+ delete $3;
}
;
}
| T_INCLUDE T_STRING
{
- $$ = context->HandleInclude($2, false, @$);
- free($2);
+ $$ = context->HandleInclude(*$2, false, @$);
+ delete $2;
}
| T_INCLUDE T_STRING_ANGLE
{
- $$ = context->HandleInclude($2, true, @$);
- free($2);
+ $$ = context->HandleInclude(*$2, true, @$);
+ delete $2;
}
| T_INCLUDE_RECURSIVE T_STRING
{
- $$ = context->HandleIncludeRecursive($2, "*.conf", @$);
- free($2);
+ $$ = context->HandleIncludeRecursive(*$2, "*.conf", @$);
+ delete $2;
}
| T_INCLUDE_RECURSIVE T_STRING ',' T_STRING
{
- $$ = context->HandleIncludeRecursive($2, $4, @$);
- free($2);
- free($4);
+ $$ = context->HandleIncludeRecursive(*$2, *$4, @$);
+ delete $2;
+ delete $4;
}
| T_INCLUDE_ZONES T_STRING ',' T_STRING
{
- $$ = context->HandleIncludeZones($2, $4, "*.conf", @$);
+ $$ = context->HandleIncludeZones(*$2, *$4, "*.conf", @$);
+ delete $2;
+ delete $4;
}
| T_INCLUDE_ZONES T_STRING ',' T_STRING ',' T_STRING
{
- $$ = context->HandleIncludeZones($2, $4, $6, @$);
+ $$ = context->HandleIncludeZones(*$2, *$4, *$6, @$);
+ delete $2;
+ delete $4;
+ delete $6;
}
| T_IMPORT rterm
{
{
$9->MakeInline();
- $$ = new ForExpression($3, $5, $7, $9, @$);
- free($3);
- free($5);
+ $$ = new ForExpression(*$3, *$5, $7, $9, @$);
+ delete $3;
+ delete $5;
}
| T_FOR '(' identifier T_IN rterm ')' rterm_scope_require_side_effect
{
$7->MakeInline();
- $$ = new ForExpression($3, "", $5, $7, @$);
- free($3);
+ $$ = new ForExpression(*$3, "", $5, $7, @$);
+ delete $3;
}
| T_FUNCTION identifier '(' identifier_items ')' use_specifier rterm_scope
{
FunctionExpression *fexpr = new FunctionExpression(*$4, $6, $7, @$);
delete $4;
- $$ = new SetExpression(MakeIndexer(ScopeThis, $2), OpSetLiteral, fexpr, @$);
- free($2);
+ $$ = new SetExpression(MakeIndexer(ScopeThis, *$2), OpSetLiteral, fexpr, @$);
+ delete $2;
}
| T_CONST T_IDENTIFIER T_SET rterm
{
- $$ = new SetExpression(MakeIndexer(ScopeGlobal, $2), OpSetLiteral, $4);
- free($2);
+ $$ = new SetExpression(MakeIndexer(ScopeGlobal, *$2), OpSetLiteral, $4);
+ delete $2;
}
| T_VAR rterm
{
aexpr->MakeInline();
std::vector<String> args;
- args.push_back($1);
- free($1);
+ args.push_back(*$1);
+ delete $1;
$$ = new FunctionExpression(args, new std::map<String, Expression *>(), $3, @$);
}
rterm_no_side_effect: T_STRING
{
- $$ = MakeLiteral($1);
- free($1);
+ $$ = MakeLiteral(*$1);
+ delete $1;
}
| T_NUMBER
{
}
| rterm '.' T_IDENTIFIER %dprec 2
{
- $$ = new IndexerExpression($1, MakeLiteral($3), @$);
- free($3);
+ $$ = new IndexerExpression($1, MakeLiteral(*$3), @$);
+ delete $3;
}
| rterm '[' rterm ']'
{
}
| T_IDENTIFIER
{
- $$ = new VariableExpression($1, @1);
- free($1);
+ $$ = new VariableExpression(*$1, @1);
+ delete $1;
}
| '!' rterm
{
target_type_specifier: /* empty */
{
- $$ = strdup("");
+ $$ = new String();
}
| T_TO identifier
{
use_specifier_item: identifier
{
- $$ = new std::pair<String, Expression *>($1, new VariableExpression($1, @1));
+ $$ = new std::pair<String, Expression *>(*$1, new VariableExpression(*$1, @1));
+ delete $1;
}
| identifier T_SET rterm
{
- $$ = new std::pair<String, Expression *>($1, $3);
+ $$ = new std::pair<String, Expression *>(*$1, $3);
+ delete $1;
}
;
apply_for_specifier: /* empty */
| T_FOR '(' identifier T_FOLLOWS identifier T_IN rterm ')'
{
- context->m_FKVar.top() = $3;
- free($3);
+ context->m_FKVar.top() = *$3;
+ delete $3;
- context->m_FVVar.top() = $5;
- free($5);
+ context->m_FVVar.top() = *$5;
+ delete $5;
context->m_FTerm.top() = $7;
}
| T_FOR '(' identifier T_IN rterm ')'
{
- context->m_FKVar.top() = $3;
- free($3);
+ context->m_FKVar.top() = *$3;
+ delete $3;
context->m_FVVar.top() = "";
{
context->m_Apply.pop();
- String type = $3;
- free($3);
- String target = $6;
- free($6);
+ String type = *$3;
+ delete $3;
+ String target = *$6;
+ delete $6;
if (!ApplyRule::IsValidSourceType(type))
BOOST_THROW_EXCEPTION(ScriptError("'apply' cannot be used with type '" + type + "'", DebugInfoRange(@2, @3)));