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

View File

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