Add path to the DebugInfo struct.

This commit is contained in:
Gunnar Beutner 2012-07-08 21:33:51 +02:00
parent a71e5ca0d7
commit c80d84f61e
5 changed files with 66 additions and 60 deletions

View File

@ -523,6 +523,7 @@ using namespace icinga;
#define YY_EXTRA_TYPE ConfigCompiler *
#define YY_USER_ACTION \
do { \
yylloc->Path = yyextra->GetPath(); \
yylloc->FirstLine = yylineno; \
yylloc->FirstColumn = yycolumn; \
yylloc->LastLine = yylineno; \
@ -536,7 +537,7 @@ do { \
} while (0)
#define YY_NO_UNISTD_H 1
#line 540 "config_lexer.cc"
#line 541 "config_lexer.cc"
#define INITIAL 0
#define IN_C_COMMENT 1
@ -778,9 +779,9 @@ YY_DECL
register int yy_act;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
#line 48 "config_lexer.ll"
#line 49 "config_lexer.ll"
#line 784 "config_lexer.cc"
#line 785 "config_lexer.cc"
yylval = yylval_param;
@ -877,127 +878,127 @@ do_action: /* This label is used only to access EOF actions. */
case 1:
YY_RULE_SETUP
#line 49 "config_lexer.ll"
#line 50 "config_lexer.ll"
return T_ABSTRACT;
YY_BREAK
case 2:
YY_RULE_SETUP
#line 50 "config_lexer.ll"
#line 51 "config_lexer.ll"
return T_LOCAL;
YY_BREAK
case 3:
YY_RULE_SETUP
#line 51 "config_lexer.ll"
#line 52 "config_lexer.ll"
return T_OBJECT;
YY_BREAK
case 4:
YY_RULE_SETUP
#line 52 "config_lexer.ll"
#line 53 "config_lexer.ll"
return T_INCLUDE;
YY_BREAK
case 5:
YY_RULE_SETUP
#line 53 "config_lexer.ll"
#line 54 "config_lexer.ll"
return T_INHERITS;
YY_BREAK
case 6:
YY_RULE_SETUP
#line 54 "config_lexer.ll"
#line 55 "config_lexer.ll"
return T_NULL;
YY_BREAK
case 7:
YY_RULE_SETUP
#line 55 "config_lexer.ll"
#line 56 "config_lexer.ll"
{ yylval->text = strdup(yytext); return T_IDENTIFIER; }
YY_BREAK
case 8:
/* rule 8 can match eol */
YY_RULE_SETUP
#line 56 "config_lexer.ll"
#line 57 "config_lexer.ll"
{ yytext[yyleng-1] = '\0'; yylval->text = strdup(yytext + 1); return T_STRING; }
YY_BREAK
case 9:
YY_RULE_SETUP
#line 57 "config_lexer.ll"
#line 58 "config_lexer.ll"
{ yylval->num = atoi(yytext); return T_NUMBER; }
YY_BREAK
case 10:
YY_RULE_SETUP
#line 58 "config_lexer.ll"
#line 59 "config_lexer.ll"
{ yylval->op = OperatorSet; return T_EQUAL; }
YY_BREAK
case 11:
YY_RULE_SETUP
#line 59 "config_lexer.ll"
#line 60 "config_lexer.ll"
{ yylval->op = OperatorPlus; return T_PLUS_EQUAL; }
YY_BREAK
case 12:
YY_RULE_SETUP
#line 60 "config_lexer.ll"
#line 61 "config_lexer.ll"
{ yylval->op = OperatorMinus; return T_MINUS_EQUAL; }
YY_BREAK
case 13:
YY_RULE_SETUP
#line 61 "config_lexer.ll"
#line 62 "config_lexer.ll"
{ yylval->op = OperatorMultiply; return T_MULTIPLY_EQUAL; }
YY_BREAK
case 14:
YY_RULE_SETUP
#line 62 "config_lexer.ll"
#line 63 "config_lexer.ll"
{ yylval->op = OperatorDivide; return T_DIVIDE_EQUAL; }
YY_BREAK
case 15:
YY_RULE_SETUP
#line 65 "config_lexer.ll"
#line 66 "config_lexer.ll"
BEGIN(IN_C_COMMENT);
YY_BREAK
case 16:
YY_RULE_SETUP
#line 69 "config_lexer.ll"
#line 70 "config_lexer.ll"
BEGIN(INITIAL);
YY_BREAK
case 17:
/* rule 17 can match eol */
YY_RULE_SETUP
#line 70 "config_lexer.ll"
#line 71 "config_lexer.ll"
/* ignore comment */
YY_BREAK
case 18:
YY_RULE_SETUP
#line 71 "config_lexer.ll"
#line 72 "config_lexer.ll"
/* ignore star */
YY_BREAK
case 19:
YY_RULE_SETUP
#line 74 "config_lexer.ll"
#line 75 "config_lexer.ll"
/* ignore C++-style comments */
YY_BREAK
case 20:
YY_RULE_SETUP
#line 75 "config_lexer.ll"
#line 76 "config_lexer.ll"
/* ignore shell-style comments */
YY_BREAK
case 21:
/* rule 21 can match eol */
YY_RULE_SETUP
#line 76 "config_lexer.ll"
#line 77 "config_lexer.ll"
/* ignore whitespace */
YY_BREAK
case 22:
YY_RULE_SETUP
#line 78 "config_lexer.ll"
#line 79 "config_lexer.ll"
return yytext[0];
YY_BREAK
case 23:
YY_RULE_SETUP
#line 79 "config_lexer.ll"
#line 80 "config_lexer.ll"
ECHO;
YY_BREAK
#line 1001 "config_lexer.cc"
#line 1002 "config_lexer.cc"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(IN_C_COMMENT):
yyterminate();
@ -2185,7 +2186,7 @@ void yyfree (void * ptr , yyscan_t yyscanner)
#define YYTABLES_NAME "yytables"
#line 79 "config_lexer.ll"
#line 80 "config_lexer.ll"

View File

@ -26,6 +26,7 @@ using namespace icinga;
#define YY_EXTRA_TYPE ConfigCompiler *
#define YY_USER_ACTION \
do { \
yylloc->Path = yyextra->GetPath(); \
yylloc->FirstLine = yylineno; \
yylloc->FirstColumn = yycolumn; \
yylloc->LastLine = yylineno; \

View File

@ -214,9 +214,10 @@ void yyerror(YYLTYPE *locp, ConfigCompiler *context, const char *err)
{
stringstream message;
message << locp->first_line << ":" << locp->first_column
message << "in " << locp->Path << ": "
<< locp->FirstLine << ":" << locp->FirstColumn
<< "-"
<< locp->last_line << ":" << locp->last_column
<< locp->LastLine << ":" << locp->LastColumn
<< ": " << err << endl;
throw runtime_error(message.str());
@ -240,7 +241,7 @@ void ConfigCompiler::Compile(void)
/* Line 264 of yacc.c */
#line 244 "config_parser.cc"
#line 245 "config_parser.cc"
#ifdef short
# undef short
@ -540,11 +541,11 @@ static const yytype_int8 yyrhs[] =
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
0, 100, 100, 101, 104, 104, 107, 113, 118, 113,
138, 139, 142, 146, 152, 153, 156, 163, 164, 168,
167, 179, 180, 182, 183, 184, 187, 195, 209, 218,
219, 220, 221, 222, 228, 233, 237, 243, 244, 245,
252, 251, 263, 269, 270, 272, 274, 275
0, 101, 101, 102, 105, 105, 108, 114, 119, 114,
139, 140, 143, 147, 153, 154, 157, 164, 165, 169,
168, 180, 181, 183, 184, 185, 188, 196, 210, 219,
220, 221, 222, 223, 229, 234, 238, 244, 245, 246,
253, 252, 264, 270, 271, 273, 275, 276
};
#endif
@ -1528,7 +1529,7 @@ yyreduce:
case 6:
/* Line 1455 of yacc.c */
#line 108 "config_parser.yy"
#line 109 "config_parser.yy"
{
context->HandleInclude((yyvsp[(2) - (2)].text));
}
@ -1537,7 +1538,7 @@ yyreduce:
case 7:
/* Line 1455 of yacc.c */
#line 113 "config_parser.yy"
#line 114 "config_parser.yy"
{
m_Abstract = false;
m_Local = false;
@ -1547,7 +1548,7 @@ yyreduce:
case 8:
/* Line 1455 of yacc.c */
#line 118 "config_parser.yy"
#line 119 "config_parser.yy"
{
m_Item = boost::make_shared<ConfigItemBuilder>(yylloc);
m_Item->SetType((yyvsp[(4) - (5)].text));
@ -1558,7 +1559,7 @@ yyreduce:
case 9:
/* Line 1455 of yacc.c */
#line 124 "config_parser.yy"
#line 125 "config_parser.yy"
{
Object::Ptr exprl_object = *(yyvsp[(8) - (8)].variant);
delete (yyvsp[(8) - (8)].variant);
@ -1576,7 +1577,7 @@ yyreduce:
case 12:
/* Line 1455 of yacc.c */
#line 143 "config_parser.yy"
#line 144 "config_parser.yy"
{
m_Abstract = true;
}
@ -1585,7 +1586,7 @@ yyreduce:
case 13:
/* Line 1455 of yacc.c */
#line 147 "config_parser.yy"
#line 148 "config_parser.yy"
{
m_Local = true;
}
@ -1594,7 +1595,7 @@ yyreduce:
case 16:
/* Line 1455 of yacc.c */
#line 157 "config_parser.yy"
#line 158 "config_parser.yy"
{
m_Item->AddParent((yyvsp[(1) - (1)].text));
free((yyvsp[(1) - (1)].text));
@ -1604,7 +1605,7 @@ yyreduce:
case 19:
/* Line 1455 of yacc.c */
#line 168 "config_parser.yy"
#line 169 "config_parser.yy"
{
m_ExpressionLists.push(boost::make_shared<ExpressionList>());
}
@ -1613,7 +1614,7 @@ yyreduce:
case 20:
/* Line 1455 of yacc.c */
#line 173 "config_parser.yy"
#line 174 "config_parser.yy"
{
(yyval.variant) = new Variant(m_ExpressionLists.top());
m_ExpressionLists.pop();
@ -1623,7 +1624,7 @@ yyreduce:
case 26:
/* Line 1455 of yacc.c */
#line 188 "config_parser.yy"
#line 189 "config_parser.yy"
{
Expression expr((yyvsp[(1) - (3)].text), (yyvsp[(2) - (3)].op), *(yyvsp[(3) - (3)].variant), yylloc);
free((yyvsp[(1) - (3)].text));
@ -1636,7 +1637,7 @@ yyreduce:
case 27:
/* Line 1455 of yacc.c */
#line 196 "config_parser.yy"
#line 197 "config_parser.yy"
{
Expression subexpr((yyvsp[(3) - (6)].text), (yyvsp[(5) - (6)].op), *(yyvsp[(6) - (6)].variant), yylloc);
free((yyvsp[(3) - (6)].text));
@ -1655,7 +1656,7 @@ yyreduce:
case 28:
/* Line 1455 of yacc.c */
#line 210 "config_parser.yy"
#line 211 "config_parser.yy"
{
Expression expr((yyvsp[(1) - (1)].text), OperatorSet, (yyvsp[(1) - (1)].text), yylloc);
free((yyvsp[(1) - (1)].text));
@ -1667,7 +1668,7 @@ yyreduce:
case 33:
/* Line 1455 of yacc.c */
#line 223 "config_parser.yy"
#line 224 "config_parser.yy"
{
(yyval.op) = (yyvsp[(1) - (1)].op);
}
@ -1676,7 +1677,7 @@ yyreduce:
case 34:
/* Line 1455 of yacc.c */
#line 229 "config_parser.yy"
#line 230 "config_parser.yy"
{
(yyval.variant) = new Variant((yyvsp[(1) - (1)].text));
free((yyvsp[(1) - (1)].text));
@ -1686,7 +1687,7 @@ yyreduce:
case 35:
/* Line 1455 of yacc.c */
#line 234 "config_parser.yy"
#line 235 "config_parser.yy"
{
(yyval.variant) = new Variant((yyvsp[(1) - (1)].num));
}
@ -1695,7 +1696,7 @@ yyreduce:
case 36:
/* Line 1455 of yacc.c */
#line 238 "config_parser.yy"
#line 239 "config_parser.yy"
{
(yyval.variant) = new Variant();
}
@ -1704,7 +1705,7 @@ yyreduce:
case 39:
/* Line 1455 of yacc.c */
#line 246 "config_parser.yy"
#line 247 "config_parser.yy"
{
(yyval.variant) = (yyvsp[(1) - (1)].variant);
}
@ -1713,7 +1714,7 @@ yyreduce:
case 40:
/* Line 1455 of yacc.c */
#line 252 "config_parser.yy"
#line 253 "config_parser.yy"
{
m_Array = boost::make_shared<Dictionary>();
}
@ -1722,7 +1723,7 @@ yyreduce:
case 41:
/* Line 1455 of yacc.c */
#line 257 "config_parser.yy"
#line 258 "config_parser.yy"
{
(yyval.variant) = new Variant(m_Array);
m_Array.reset();
@ -1732,7 +1733,7 @@ yyreduce:
case 42:
/* Line 1455 of yacc.c */
#line 264 "config_parser.yy"
#line 265 "config_parser.yy"
{
m_Array->AddUnnamedProperty(*(yyvsp[(1) - (1)].variant));
delete (yyvsp[(1) - (1)].variant);
@ -1742,7 +1743,7 @@ yyreduce:
/* Line 1455 of yacc.c */
#line 1746 "config_parser.cc"
#line 1747 "config_parser.cc"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@ -1961,6 +1962,6 @@ yyreturn:
/* Line 1675 of yacc.c */
#line 277 "config_parser.yy"
#line 278 "config_parser.yy"

View File

@ -71,9 +71,10 @@ void yyerror(YYLTYPE *locp, ConfigCompiler *context, const char *err)
{
stringstream message;
message << locp->first_line << ":" << locp->first_column
message << "in " << locp->Path << ": "
<< locp->FirstLine << ":" << locp->FirstColumn
<< "-"
<< locp->last_line << ":" << locp->last_column
<< locp->LastLine << ":" << locp->LastColumn
<< ": " << err << endl;
throw runtime_error(message.str());

View File

@ -25,6 +25,8 @@ namespace icinga
struct DebugInfo
{
string Path;
union
{
int FirstLine;