Made right-recursive config rules left-recursive.

This commit is contained in:
Gunnar Beutner 2012-06-29 10:39:36 +02:00
parent 2272e410c2
commit 3c821c75ef
3 changed files with 122 additions and 115 deletions

View File

@ -466,16 +466,16 @@ union yyalloc
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 2
/* YYLAST -- Last index in YYTABLE. */
#define YYLAST 47
#define YYLAST 48
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 29
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 23
#define YYNNTS 25
/* YYNRULES -- Number of rules. */
#define YYNRULES 44
#define YYNRULES 48
/* YYNRULES -- Number of states. */
#define YYNSTATES 61
#define YYNSTATES 63
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
#define YYUNDEFTOK 2
@ -524,9 +524,9 @@ static const yytype_uint8 yyprhs[] =
{
0, 0, 3, 4, 7, 9, 11, 14, 15, 16,
25, 26, 29, 31, 33, 35, 37, 41, 43, 44,
47, 48, 53, 54, 56, 60, 64, 71, 73, 75,
77, 79, 81, 83, 85, 87, 89, 91, 93, 95,
96, 101, 103, 104, 106
47, 48, 53, 55, 58, 59, 61, 65, 69, 76,
78, 80, 82, 84, 86, 88, 90, 92, 94, 96,
98, 100, 101, 106, 108, 110, 113, 114, 116
};
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
@ -537,12 +537,13 @@ static const yytype_int8 yyrhs[] =
3, 35, 40, 41, -1, -1, 36, 37, -1, 12,
-1, 13, -1, 14, -1, 39, -1, 38, 22, 39,
-1, 3, -1, -1, 17, 38, -1, -1, 23, 42,
43, 24, -1, -1, 44, -1, 44, 22, 43, -1,
6, 45, 47, -1, 6, 25, 3, 26, 45, 47,
-1, 3, -1, 7, -1, 8, -1, 9, -1, 10,
-1, 11, -1, 3, -1, 4, -1, 5, -1, 46,
-1, 48, -1, 41, -1, -1, 27, 49, 51, 28,
-1, 46, -1, -1, 50, -1, 50, 22, 51, -1
43, 24, -1, 44, -1, 44, 22, -1, -1, 45,
-1, 44, 22, 45, -1, 6, 46, 48, -1, 6,
25, 3, 26, 46, 48, -1, 3, -1, 7, -1,
8, -1, 9, -1, 10, -1, 11, -1, 3, -1,
4, -1, 5, -1, 47, -1, 49, -1, 41, -1,
-1, 27, 50, 52, 28, -1, 47, -1, 53, -1,
53, 22, -1, -1, 51, -1, 53, 22, 51, -1
};
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
@ -550,9 +551,9 @@ static const yytype_uint16 yyrline[] =
{
0, 106, 106, 107, 110, 110, 113, 117, 122, 117,
155, 156, 159, 163, 167, 173, 174, 177, 184, 185,
189, 188, 200, 201, 202, 205, 213, 227, 236, 237,
238, 239, 240, 246, 251, 255, 261, 262, 263, 270,
269, 281, 287, 289, 290
189, 188, 200, 201, 203, 204, 205, 208, 216, 230,
239, 240, 241, 242, 243, 249, 254, 258, 264, 265,
266, 273, 272, 284, 290, 291, 293, 295, 296
};
#endif
@ -569,8 +570,8 @@ static const char *const yytname[] =
"statements", "statement", "include", "object", "$@1", "$@2",
"attributes", "attribute", "inherits_list", "inherits_item",
"inherits_specifier", "expressionlist", "$@3", "expressions",
"expression", "operator", "simplevalue", "value", "tuple", "$@4",
"tupleitem", "tupleitems", 0
"expressions_inner", "expression", "operator", "simplevalue", "value",
"tuple", "$@4", "tupleitem", "tupleitems", "tupleitems_inner", 0
};
#endif
@ -590,9 +591,9 @@ static const yytype_uint8 yyr1[] =
{
0, 29, 30, 30, 31, 31, 32, 34, 35, 33,
36, 36, 37, 37, 37, 38, 38, 39, 40, 40,
42, 41, 43, 43, 43, 44, 44, 44, 45, 45,
45, 45, 45, 46, 46, 46, 47, 47, 47, 49,
48, 50, 51, 51, 51
42, 41, 43, 43, 44, 44, 44, 45, 45, 45,
46, 46, 46, 46, 46, 47, 47, 47, 48, 48,
48, 50, 49, 51, 52, 52, 53, 53, 53
};
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
@ -600,9 +601,9 @@ static const yytype_uint8 yyr2[] =
{
0, 2, 0, 2, 1, 1, 2, 0, 0, 8,
0, 2, 1, 1, 1, 1, 3, 1, 0, 2,
0, 4, 0, 1, 3, 3, 6, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
4, 1, 0, 1, 3
0, 4, 1, 2, 0, 1, 3, 3, 6, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 0, 4, 1, 1, 2, 0, 1, 3
};
/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
@ -612,41 +613,41 @@ static const yytype_uint8 yydefact[] =
{
2, 7, 1, 0, 3, 5, 4, 10, 6, 0,
12, 13, 14, 0, 11, 0, 8, 18, 0, 0,
17, 19, 15, 20, 9, 0, 22, 16, 27, 0,
0, 23, 28, 29, 30, 31, 32, 0, 0, 21,
22, 0, 33, 34, 35, 39, 38, 36, 25, 37,
24, 0, 42, 0, 41, 43, 0, 26, 42, 40,
44
17, 19, 15, 20, 9, 0, 24, 16, 29, 0,
0, 22, 25, 30, 31, 32, 33, 34, 0, 0,
21, 23, 0, 35, 36, 37, 41, 40, 38, 27,
39, 26, 0, 46, 0, 43, 47, 0, 44, 28,
42, 45, 48
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int8 yydefgoto[] =
{
-1, 1, 4, 5, 6, 7, 17, 9, 14, 21,
22, 19, 46, 26, 30, 31, 38, 47, 48, 49,
52, 55, 56
22, 19, 47, 26, 30, 31, 32, 39, 48, 49,
50, 53, 56, 57, 58
};
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
#define YYPACT_NINF -45
#define YYPACT_NINF -46
static const yytype_int8 yypact[] =
{
-45, 9, -45, 19, -45, -45, -45, -45, -45, -2,
-45, -45, -45, 25, -45, 27, -45, 15, 30, 11,
-45, 13, -45, -45, -45, 30, 20, -45, -45, -4,
12, 16, -45, -45, -45, -45, -45, 34, -3, -45,
20, 14, -45, -45, -45, -45, -45, -45, -45, -45,
-45, 8, 24, -3, -45, 17, 18, -45, 24, -45,
-45
-46, 9, -46, 16, -46, -46, -46, -46, -46, 14,
-46, -46, -46, 11, -46, 19, -46, 6, 30, 13,
-46, 15, -46, -46, -46, 30, 12, -46, -46, -4,
10, 17, -46, -46, -46, -46, -46, -46, 32, -3,
-46, 12, 18, -46, -46, -46, -46, -46, -46, -46,
-46, -46, 3, 27, -3, -46, -46, 20, 21, -46,
-46, 27, -46
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] =
{
-45, -45, -45, -45, -45, -45, -45, -45, -45, -45,
22, -45, 23, -45, 1, -45, -8, -44, -9, -45,
-45, -45, -13
-46, -46, -46, -46, -46, -46, -46, -46, -46, -46,
22, -46, 23, -46, -46, -46, -1, -14, -45, -13,
-46, -46, -16, -46, -46
};
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
@ -655,26 +656,26 @@ static const yytype_int8 yypgoto[] =
#define YYTABLE_NINF -1
static const yytype_uint8 yytable[] =
{
42, 43, 44, 32, 33, 34, 35, 36, 54, 2,
10, 11, 12, 13, 54, 32, 33, 34, 35, 36,
23, 37, 8, 28, 45, 3, 29, 42, 43, 44,
16, 15, 18, 20, 23, 25, 39, 41, 40, 58,
51, 50, 24, 53, 57, 60, 59, 27
43, 44, 45, 33, 34, 35, 36, 37, 55, 2,
33, 34, 35, 36, 37, 28, 55, 15, 29, 8,
23, 38, 16, 18, 46, 3, 10, 11, 12, 13,
43, 44, 45, 20, 40, 42, 23, 25, 54, 41,
51, 59, 24, 61, 52, 62, 0, 27, 60
};
#define yypact_value_is_default(yystate) \
((yystate) == (-45))
((yystate) == (-46))
#define yytable_value_is_error(yytable_value) \
YYID (0)
static const yytype_uint8 yycheck[] =
static const yytype_int8 yycheck[] =
{
3, 4, 5, 7, 8, 9, 10, 11, 52, 0,
12, 13, 14, 15, 58, 7, 8, 9, 10, 11,
23, 25, 3, 3, 27, 16, 6, 3, 4, 5,
3, 6, 17, 3, 23, 22, 24, 3, 22, 22,
26, 40, 19, 51, 53, 58, 28, 25
3, 4, 5, 7, 8, 9, 10, 11, 53, 0,
7, 8, 9, 10, 11, 3, 61, 6, 6, 3,
23, 25, 3, 17, 27, 16, 12, 13, 14, 15,
3, 4, 5, 3, 24, 3, 23, 22, 52, 22,
41, 54, 19, 22, 26, 61, -1, 25, 28
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
@ -684,10 +685,10 @@ static const yytype_uint8 yystos[] =
0, 30, 0, 16, 31, 32, 33, 34, 3, 36,
12, 13, 14, 15, 37, 6, 3, 35, 17, 40,
3, 38, 39, 23, 41, 22, 42, 39, 3, 6,
43, 44, 7, 8, 9, 10, 11, 25, 45, 24,
22, 3, 3, 4, 5, 27, 41, 46, 47, 48,
43, 26, 49, 45, 46, 50, 51, 47, 22, 28,
51
43, 44, 45, 7, 8, 9, 10, 11, 25, 46,
24, 22, 3, 3, 4, 5, 27, 41, 47, 48,
49, 45, 26, 50, 46, 47, 51, 52, 53, 48,
28, 22, 51
};
#define yyerrok (yyerrstatus = 0)
@ -1678,10 +1679,10 @@ yyreduce:
}
break;
case 25:
case 27:
/* Line 1806 of yacc.c */
#line 206 "config_parser.yy"
#line 209 "config_parser.yy"
{
Expression expr((yyvsp[(1) - (3)].text), (yyvsp[(2) - (3)].op), *(yyvsp[(3) - (3)].variant), yylloc);
free((yyvsp[(1) - (3)].text));
@ -1691,10 +1692,10 @@ yyreduce:
}
break;
case 26:
case 28:
/* Line 1806 of yacc.c */
#line 214 "config_parser.yy"
#line 217 "config_parser.yy"
{
Expression subexpr((yyvsp[(3) - (6)].text), (yyvsp[(5) - (6)].op), *(yyvsp[(6) - (6)].variant), yylloc);
free((yyvsp[(3) - (6)].text));
@ -1710,10 +1711,10 @@ yyreduce:
}
break;
case 27:
case 29:
/* Line 1806 of yacc.c */
#line 228 "config_parser.yy"
#line 231 "config_parser.yy"
{
Expression expr((yyvsp[(1) - (1)].text), OperatorSet, (yyvsp[(1) - (1)].text), yylloc);
free((yyvsp[(1) - (1)].text));
@ -1722,75 +1723,75 @@ yyreduce:
}
break;
case 32:
/* Line 1806 of yacc.c */
#line 241 "config_parser.yy"
{
(yyval.op) = (yyvsp[(1) - (1)].op);
}
break;
case 33:
/* Line 1806 of yacc.c */
#line 247 "config_parser.yy"
{
(yyval.variant) = new Variant((yyvsp[(1) - (1)].text));
free((yyvsp[(1) - (1)].text));
}
break;
case 34:
/* Line 1806 of yacc.c */
#line 252 "config_parser.yy"
#line 244 "config_parser.yy"
{
(yyval.variant) = new Variant((yyvsp[(1) - (1)].num));
(yyval.op) = (yyvsp[(1) - (1)].op);
}
break;
case 35:
/* Line 1806 of yacc.c */
#line 256 "config_parser.yy"
#line 250 "config_parser.yy"
{
(yyval.variant) = new Variant((yyvsp[(1) - (1)].text));
free((yyvsp[(1) - (1)].text));
}
break;
case 36:
/* Line 1806 of yacc.c */
#line 255 "config_parser.yy"
{
(yyval.variant) = new Variant((yyvsp[(1) - (1)].num));
}
break;
case 37:
/* Line 1806 of yacc.c */
#line 259 "config_parser.yy"
{
(yyval.variant) = new Variant();
}
break;
case 38:
/* Line 1806 of yacc.c */
#line 264 "config_parser.yy"
{
(yyval.variant) = (yyvsp[(1) - (1)].variant);
}
break;
case 39:
/* Line 1806 of yacc.c */
#line 270 "config_parser.yy"
{
m_Array = boost::make_shared<Dictionary>();
}
break;
case 40:
/* Line 1806 of yacc.c */
#line 275 "config_parser.yy"
#line 267 "config_parser.yy"
{
(yyval.variant) = new Variant(m_Array);
m_Array.reset();
(yyval.variant) = (yyvsp[(1) - (1)].variant);
}
break;
case 41:
/* Line 1806 of yacc.c */
#line 282 "config_parser.yy"
#line 273 "config_parser.yy"
{
m_Array = boost::make_shared<Dictionary>();
}
break;
case 42:
/* Line 1806 of yacc.c */
#line 278 "config_parser.yy"
{
(yyval.variant) = new Variant(m_Array);
m_Array.reset();
}
break;
case 43:
/* Line 1806 of yacc.c */
#line 285 "config_parser.yy"
{
m_Array->AddUnnamedProperty(*(yyvsp[(1) - (1)].variant));
delete (yyvsp[(1) - (1)].variant);
@ -1800,7 +1801,7 @@ yyreduce:
/* Line 1806 of yacc.c */
#line 1804 "config_parser.cc"
#line 1805 "config_parser.cc"
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
@ -2038,6 +2039,6 @@ yyreturn:
/* Line 2067 of yacc.c */
#line 292 "config_parser.yy"
#line 298 "config_parser.yy"

View File

@ -197,9 +197,12 @@ expressionlist: '{'
}
;
expressions: /* empty */
expressions: expressions_inner
| expressions_inner ','
expressions_inner: /* empty */
| expression
| expression ',' expressions
| expressions_inner ',' expression
;
expression: T_IDENTIFIER operator value
@ -284,9 +287,12 @@ tupleitem: simplevalue
delete $1;
}
tupleitems:
tupleitems: tupleitems_inner
| tupleitems_inner ','
tupleitems_inner:
/* empty */
| tupleitem
| tupleitem ',' tupleitems
| tupleitems_inner ',' tupleitem
;
%%

View File

@ -10,7 +10,7 @@ public:
typedef shared_ptr<NagiosCheckTask> Ptr;
typedef weak_ptr<NagiosCheckTask> WeakPtr;
static const int MaxChecksPerThread = 64;
static const int MaxChecksPerThread = 128;
NagiosCheckTask(const Service& service);