From 07421751ad88d305c49188d777dce1fe52f11b40 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Thu, 14 Mar 2013 12:17:46 +0100 Subject: [PATCH] Implement config support for arrays. --- itl/host.conf | 9 +- itl/service-common.conf | 80 +-- itl/service.conf | 2 +- lib/config/config_lexer.cc | 373 ++++++----- lib/config/config_lexer.ll | 1 + lib/config/config_parser.cc | 997 +++++++++++++++------------- lib/config/config_parser.h | 84 +-- lib/config/config_parser.yy | 42 +- lib/config/typerule.cpp | 6 +- lib/config/typerule.h | 5 +- lib/icinga/host.cpp | 69 +- lib/icinga/host.h | 12 +- lib/icinga/hostgroup.cpp | 13 +- lib/icinga/icinga-type.conf | 127 +--- lib/icinga/macroprocessor.cpp | 17 +- lib/icinga/service-check.cpp | 7 +- lib/icinga/service-notification.cpp | 31 +- lib/icinga/service.cpp | 21 +- lib/icinga/service.h | 16 +- lib/icinga/servicegroup.cpp | 12 +- lib/icinga/user.cpp | 2 +- lib/icinga/user.h | 4 +- lib/icinga/usergroup.cpp | 12 +- 23 files changed, 989 insertions(+), 953 deletions(-) diff --git a/itl/host.conf b/itl/host.conf index 128687b3e..370bd3dd4 100644 --- a/itl/host.conf +++ b/itl/host.conf @@ -21,9 +21,12 @@ object HostGroup "all-hosts" { display_name = "All Hosts" } -abstract object Host "itl-host" { - hostgroups = { "all-hosts" }, +template Host "itl-host" { + hostgroups = [ "all-hosts" ], - services = { "ping4" }, + services["ping4"] = { + templates = [ "ping4" ] + }, + hostcheck = "ping4" } diff --git a/itl/service-common.conf b/itl/service-common.conf index 625955194..3403ffbc0 100644 --- a/itl/service-common.conf +++ b/itl/service-common.conf @@ -18,7 +18,7 @@ ******************************************************************************/ template Service "ping4" inherits "plugin-service" { - check_command = { + check_command = [ "$plugindir$/check_ping", "-4", "-H", "$address$", @@ -26,7 +26,7 @@ template Service "ping4" inherits "plugin-service" { "-c", "$crta$,$cpl$%", "-p", "$packets$", "-t", "$timeout$" - }, + ], macros = { wrta = 100, @@ -41,7 +41,7 @@ template Service "ping4" inherits "plugin-service" { } template Service "ping6" inherits "plugin-service" { - check_command = { + check_command = [ "$plugindir$/check_ping", "-6", "-H", "$address6$", @@ -49,7 +49,7 @@ template Service "ping6" inherits "plugin-service" { "-c", "$crta$,$cpl$%", "-p", "$packets$", "-t", "$timeout$" - }, + ], macros = { wrta = 100, @@ -64,12 +64,12 @@ template Service "ping6" inherits "plugin-service" { } template Service "dummy" inherits "plugin-service" { - check_command = { + check_command = [ "$plugindir$/check_dummy", "$state$", "$text$" - }, - + ], + macros = { state = 0, text = "Check was successful." @@ -77,62 +77,62 @@ template Service "dummy" inherits "plugin-service" { } template Service "tcp" inherits "plugin-service" { - check_command = { + check_command = [ "$plugindir$/check_tcp", "-H", "$address$", "-p", "$port$" - } + ] } template Service "udp" inherits "plugin-service" { - check_command = { + check_command = [ "$plugindir$/check_udp", "-H", "$address$", "-p", "$port$" - } + ] } template Service "http_vhost" inherits "plugin-service" { - check_command = { + check_command = [ "$plugindir$/check_http", "-H", "$vhost$" - }, + ], } template Service "http_ip" inherits "plugin-service" { - check_command = { + check_command = [ "$plugindir$/check_http", "-I", "$address$" - } + ] } template Service "https_vhost" inherits "plugin-service" { - check_command = { + check_command = [ "$plugindir$/check_http", "-H", "$vhost", "-S" - }, + ], } template Service "https_ip" inherits "plugin-service" { - check_command = { + check_command = [ "$plugindir$/check_http", "-I", "$address$", "-S" - }, + ], } template Service "smtp" inherits "plugin-service" { - check_command = { + check_command = [ "$plugindir$/check_smtp", "-H", "$address$" - } + ] } template Service "ssmtp" inherits "plugin-service" { - check_command = { + check_command = [ "$plugindir$/check_ssmtp", "-H", "$address$", "-p", "$port$" - }, + ], macros += { port = 465 @@ -140,25 +140,25 @@ template Service "ssmtp" inherits "plugin-service" { } template Service "ntp_time" inherits "plugin-service" { - check_command = { + check_command = [ "$plugindir$/check_ntp_time", "-H", "$address$" - } + ] } template Service "ssh" inherits "plugin-service" { - check_command = { + check_command = [ "$plugindir$/check_ssh", "$address$" - } + ] } template Service "disk" inherits "plugin-service" { - check_command = { + check_command = [ "$plugindir$/check_disk", "-w", "$wfree$", "-c", "$cfree$" - }, + ], macros += { wfree = "20%", @@ -167,24 +167,24 @@ template Service "disk" inherits "plugin-service" { } template Service "users" inherits "plugin-service" { - check_command = { + check_command = [ "$plugindir$/check_users", "-w", "$wgreater$", "-c", "$cgreater$" - }, + ], macros += { - wgreater = 20, - cgreater = 50, - } + wgreater = 20, + cgreater = 50, + } } template Service "processes" inherits "plugin-service" { - check_command = { + check_command = [ "$plugindir$/check_procs", "-w", "$wgreater$", "-c", "$cgreater$" - }, + ], macros += { wgreater = 250, @@ -194,11 +194,11 @@ template Service "processes" inherits "plugin-service" { template Service "load" inherits "plugin-service" { - check_command = { + check_command = [ "$plugindir$/check_load", "-w", "$wload1$,$wload5$,$wload15$", "-c", "$cload1$,$cload5$,$cload15$" - }, + ], macros = { wload1 = 5.0, @@ -212,12 +212,12 @@ template Service "load" inherits "plugin-service" { } template Service "snmp" inherits "plugin-service" { - check_command = { + check_command = [ "$plugindir$/check_snmp", "-H", "$address$", "-o", "$oid$", "-C", "$community$" - }, + ], macros = { community = "public" diff --git a/itl/service.conf b/itl/service.conf index 1546271ec..675381d80 100644 --- a/itl/service.conf +++ b/itl/service.conf @@ -22,7 +22,7 @@ object ServiceGroup "all-services" { } template Service "itl-service" { - servicegroups = { "all-services" } + servicegroups = [ "all-services" ] } template Service "null-service" inherits "itl-service" { diff --git a/lib/config/config_lexer.cc b/lib/config/config_lexer.cc index eab6bbbaa..de89a6e0a 100644 --- a/lib/config/config_lexer.cc +++ b/lib/config/config_lexer.cc @@ -370,8 +370,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 55 -#define YY_END_OF_BUFFER 56 +#define YY_NUM_RULES 56 +#define YY_END_OF_BUFFER 57 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -379,29 +379,29 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[193] = +static yyconst flex_int16_t yy_accept[197] = { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 56, 54, - 21, 21, 1, 54, 54, 42, 54, 54, 54, 48, - 54, 49, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 54, 18, 19, 12, 3, 2, 55, - 15, 15, 21, 0, 0, 0, 0, 0, 42, 52, - 50, 48, 51, 16, 20, 53, 0, 45, 46, 47, - 0, 43, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 0, 18, 17, 12, - 11, 4, 5, 9, 10, 6, 8, 7, 0, 0, - 0, 0, 0, 0, 20, 48, 44, 42, 27, 42, + 0, 0, 0, 0, 0, 0, 0, 0, 57, 55, + 21, 21, 1, 55, 55, 43, 55, 55, 55, 49, + 55, 50, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 55, 18, 19, 12, 3, 2, 56, + 15, 15, 21, 0, 0, 0, 0, 0, 43, 53, + 51, 49, 52, 16, 20, 54, 0, 46, 47, 48, + 0, 44, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 0, 18, 17, + 12, 11, 4, 5, 9, 10, 6, 8, 7, 0, + 0, 0, 0, 0, 0, 20, 49, 45, 43, 28, - 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 13, 4, 5, 14, 0, 0, 0, 0, - 0, 42, 42, 42, 42, 42, 38, 42, 42, 42, - 42, 42, 42, 40, 22, 4, 0, 0, 0, 0, - 0, 42, 42, 41, 42, 32, 42, 42, 42, 42, - 42, 42, 0, 0, 0, 0, 0, 42, 42, 42, - 24, 33, 42, 26, 25, 42, 0, 0, 0, 0, - 0, 42, 42, 42, 39, 42, 35, 36, 0, 29, - 0, 31, 42, 37, 34, 0, 0, 42, 30, 28, - 23, 0 + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 13, 4, 5, 14, 0, 0, + 0, 0, 0, 43, 43, 43, 43, 43, 43, 39, + 43, 43, 43, 43, 43, 43, 41, 22, 4, 0, + 0, 0, 0, 0, 43, 24, 43, 42, 43, 33, + 43, 43, 43, 43, 43, 43, 0, 0, 0, 0, + 0, 43, 43, 43, 25, 34, 43, 27, 26, 43, + 0, 0, 0, 0, 0, 43, 43, 43, 40, 43, + 36, 37, 0, 30, 0, 32, 43, 38, 35, 0, + 0, 43, 31, 29, 23, 0 } ; @@ -446,109 +446,110 @@ static yyconst flex_int32_t yy_meta[44] = 5, 1, 1 } ; -static yyconst flex_int16_t yy_base[202] = +static yyconst flex_int16_t yy_base[206] = { 0, - 0, 0, 342, 341, 41, 43, 304, 303, 345, 350, - 46, 48, 350, 24, 33, 328, 327, 43, 50, 55, - 325, 350, 325, 42, 48, 55, 56, 54, 61, 62, - 64, 63, 73, 298, 0, 328, 0, 350, 350, 103, - 350, 295, 88, 305, 308, 297, 310, 313, 316, 350, - 350, 86, 350, 350, 0, 350, 81, 350, 294, 350, - 313, 350, 65, 79, 88, 89, 91, 90, 95, 92, - 106, 111, 113, 114, 116, 117, 287, 0, 350, 0, - 350, 124, 131, 350, 350, 350, 350, 350, 285, 305, - 305, 287, 289, 293, 0, 134, 350, 118, 306, 122, + 0, 0, 350, 349, 41, 43, 312, 311, 353, 358, + 46, 48, 358, 24, 33, 336, 335, 43, 50, 55, + 333, 358, 333, 42, 48, 55, 56, 54, 61, 63, + 65, 67, 74, 306, 0, 336, 0, 358, 358, 104, + 358, 303, 91, 313, 316, 305, 318, 321, 324, 358, + 358, 91, 358, 358, 0, 358, 83, 358, 302, 358, + 321, 358, 75, 83, 90, 86, 81, 93, 91, 103, + 98, 105, 115, 107, 114, 116, 122, 295, 0, 358, + 0, 358, 134, 136, 358, 358, 358, 358, 358, 293, + 313, 313, 295, 297, 301, 0, 138, 358, 121, 314, - 132, 134, 137, 124, 143, 146, 136, 147, 150, 151, - 152, 156, 350, 169, 171, 350, 291, 284, 283, 279, - 289, 157, 159, 170, 163, 172, 300, 173, 174, 175, - 184, 176, 179, 299, 298, 193, 274, 292, 283, 282, - 286, 191, 182, 292, 185, 291, 194, 196, 198, 200, - 201, 203, 280, 258, 272, 254, 243, 204, 205, 206, - 246, 245, 208, 244, 243, 209, 234, 216, 217, 230, - 215, 212, 213, 215, 235, 216, 350, 350, 211, 350, - 215, 230, 219, 229, 227, 218, 205, 223, 350, 350, - 87, 350, 264, 269, 274, 276, 281, 286, 291, 296, + 137, 123, 136, 138, 144, 128, 147, 150, 151, 154, + 155, 156, 161, 162, 358, 167, 169, 358, 299, 292, + 291, 287, 297, 160, 171, 172, 175, 177, 176, 308, + 178, 179, 181, 187, 182, 188, 307, 306, 198, 282, + 300, 291, 290, 294, 199, 300, 189, 299, 192, 298, + 200, 201, 205, 207, 208, 210, 287, 265, 279, 261, + 250, 211, 212, 213, 253, 252, 215, 251, 250, 216, + 241, 223, 224, 237, 222, 219, 221, 222, 242, 224, + 358, 358, 218, 358, 222, 237, 226, 236, 234, 225, + 211, 230, 358, 358, 64, 358, 271, 276, 281, 283, - 301 + 288, 293, 298, 303, 308 } ; -static yyconst flex_int16_t yy_def[202] = +static yyconst flex_int16_t yy_def[206] = { 0, - 192, 1, 193, 193, 194, 194, 195, 195, 192, 192, - 192, 192, 192, 192, 192, 196, 192, 192, 192, 192, - 197, 192, 196, 196, 196, 196, 196, 196, 196, 196, - 196, 196, 196, 192, 198, 192, 199, 192, 192, 200, - 192, 192, 192, 192, 192, 192, 192, 192, 196, 192, - 192, 192, 192, 192, 201, 192, 192, 192, 192, 192, - 197, 192, 196, 196, 196, 196, 196, 196, 196, 196, - 196, 196, 196, 196, 196, 196, 192, 198, 192, 199, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 201, 192, 192, 196, 196, 196, + 196, 1, 197, 197, 198, 198, 199, 199, 196, 196, + 196, 196, 196, 196, 196, 200, 196, 196, 196, 196, + 201, 196, 200, 200, 200, 200, 200, 200, 200, 200, + 200, 200, 200, 196, 202, 196, 203, 196, 196, 204, + 196, 196, 196, 196, 196, 196, 196, 196, 200, 196, + 196, 196, 196, 196, 205, 196, 196, 196, 196, 196, + 201, 196, 200, 200, 200, 200, 200, 200, 200, 200, + 200, 200, 200, 200, 200, 200, 200, 196, 202, 196, + 203, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 205, 196, 196, 200, 200, - 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, - 196, 196, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 196, 196, 196, 196, 196, 196, 196, 196, 196, - 196, 196, 196, 196, 196, 192, 192, 192, 192, 192, - 192, 196, 196, 196, 196, 196, 196, 196, 196, 196, - 196, 196, 192, 192, 192, 192, 192, 196, 196, 196, - 196, 196, 196, 196, 196, 196, 192, 192, 192, 192, - 192, 196, 196, 196, 196, 196, 192, 192, 192, 192, - 192, 196, 196, 196, 196, 192, 192, 196, 192, 192, - 196, 0, 192, 192, 192, 192, 192, 192, 192, 192, + 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, + 200, 200, 200, 200, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 200, 200, 200, 200, 200, 200, 200, + 200, 200, 200, 200, 200, 200, 200, 200, 196, 196, + 196, 196, 196, 196, 200, 200, 200, 200, 200, 200, + 200, 200, 200, 200, 200, 200, 196, 196, 196, 196, + 196, 200, 200, 200, 200, 200, 200, 200, 200, 200, + 196, 196, 196, 196, 196, 200, 200, 200, 200, 200, + 196, 196, 196, 196, 196, 200, 200, 200, 200, 196, + 196, 200, 196, 196, 200, 0, 196, 196, 196, 196, - 192 + 196, 196, 196, 196, 196 } ; -static yyconst flex_int16_t yy_nxt[394] = +static yyconst flex_int16_t yy_nxt[402] = { 0, 10, 11, 12, 13, 14, 15, 16, 17, 18, 10, 19, 20, 20, 10, 21, 22, 10, 23, 10, 24, 23, 23, 25, 23, 26, 23, 23, 27, 23, 28, 23, 29, 30, 31, 23, 23, 32, 33, 23, 23, 23, 34, 10, 38, 39, 38, 39, 43, 43, 43, - 43, 44, 46, 45, 52, 52, 54, 192, 53, 40, - 55, 40, 63, 192, 57, 56, 52, 52, 47, 192, - 192, 192, 48, 64, 66, 65, 192, 192, 192, 192, - 192, 58, 70, 71, 72, 59, 68, 67, 192, 43, - 43, 60, 96, 96, 192, 57, 74, 52, 52, 69, + 43, 44, 46, 45, 52, 52, 54, 196, 53, 40, + 55, 40, 63, 196, 57, 56, 52, 52, 47, 196, + 196, 196, 48, 64, 67, 66, 196, 65, 196, 196, + 196, 58, 196, 71, 72, 59, 69, 68, 73, 196, + 196, 60, 43, 43, 97, 97, 196, 75, 196, 70, - 73, 98, 192, 192, 192, 192, 192, 192, 75, 100, - 192, 103, 58, 76, 82, 83, 59, 102, 101, 99, - 106, 192, 60, 84, 104, 105, 192, 85, 192, 192, - 108, 192, 192, 192, 86, 114, 115, 192, 87, 192, - 88, 107, 115, 115, 110, 96, 96, 192, 109, 192, - 112, 192, 192, 127, 111, 122, 126, 125, 192, 123, - 58, 192, 192, 128, 59, 192, 192, 192, 124, 129, - 60, 192, 192, 130, 192, 134, 131, 132, 192, 135, - 136, 115, 115, 115, 133, 192, 143, 192, 192, 192, - 192, 192, 142, 144, 192, 148, 147, 192, 145, 192, + 57, 196, 52, 52, 74, 196, 196, 102, 196, 76, + 103, 99, 105, 196, 77, 83, 84, 58, 196, 104, + 196, 59, 196, 100, 85, 101, 108, 60, 86, 196, + 196, 196, 106, 107, 110, 87, 196, 196, 196, 88, + 109, 89, 111, 196, 112, 116, 117, 117, 117, 97, + 97, 196, 196, 196, 113, 114, 125, 130, 124, 196, + 126, 128, 196, 129, 58, 196, 196, 131, 59, 196, + 196, 196, 127, 132, 60, 196, 196, 196, 139, 117, + 117, 117, 135, 134, 137, 138, 196, 196, 133, 136, + 196, 196, 196, 196, 196, 145, 196, 196, 148, 147, - 192, 146, 149, 150, 115, 115, 192, 151, 152, 192, - 158, 192, 160, 192, 159, 192, 192, 163, 192, 192, - 192, 192, 166, 192, 192, 172, 165, 192, 192, 161, - 192, 192, 183, 162, 192, 164, 173, 175, 192, 185, - 190, 189, 192, 174, 192, 192, 176, 187, 186, 182, - 192, 184, 181, 180, 188, 179, 178, 177, 192, 192, - 192, 192, 171, 191, 35, 35, 35, 35, 35, 37, - 37, 37, 37, 37, 41, 41, 41, 41, 41, 49, - 49, 61, 61, 61, 61, 61, 78, 78, 78, 170, - 78, 80, 169, 168, 80, 80, 81, 81, 81, 81, + 152, 151, 196, 196, 196, 150, 154, 196, 153, 117, + 117, 146, 149, 155, 196, 196, 196, 156, 162, 164, + 196, 163, 196, 196, 167, 196, 196, 196, 196, 170, + 196, 196, 176, 169, 196, 165, 196, 196, 166, 196, + 187, 196, 168, 177, 179, 196, 194, 189, 193, 196, + 178, 196, 196, 180, 191, 190, 186, 196, 188, 185, + 184, 192, 183, 182, 181, 196, 196, 196, 196, 175, + 195, 35, 35, 35, 35, 35, 37, 37, 37, 37, + 37, 41, 41, 41, 41, 41, 49, 49, 61, 61, + 61, 61, 61, 79, 79, 79, 174, 79, 81, 173, - 81, 95, 167, 95, 95, 95, 192, 192, 157, 156, - 155, 154, 153, 192, 192, 192, 141, 140, 139, 138, - 137, 192, 121, 120, 119, 118, 117, 116, 113, 62, - 97, 192, 94, 93, 92, 91, 90, 89, 79, 77, - 192, 62, 51, 50, 192, 42, 42, 36, 36, 9, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192 + 172, 81, 81, 82, 82, 82, 82, 82, 96, 171, + 96, 96, 96, 196, 196, 196, 161, 160, 159, 158, + 157, 196, 196, 196, 144, 143, 142, 141, 140, 196, + 123, 122, 121, 120, 119, 118, 115, 62, 98, 196, + 95, 94, 93, 92, 91, 90, 80, 78, 196, 62, + 51, 50, 196, 42, 42, 36, 36, 9, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196 } ; -static yyconst flex_int16_t yy_chk[394] = +static yyconst flex_int16_t yy_chk[402] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -557,51 +558,52 @@ static yyconst flex_int16_t yy_chk[394] = 1, 1, 1, 5, 5, 6, 6, 11, 11, 12, 12, 14, 15, 14, 18, 18, 19, 24, 18, 5, 19, 6, 24, 25, 20, 19, 20, 20, 15, 28, - 26, 27, 15, 24, 26, 25, 29, 30, 32, 31, - 63, 20, 30, 31, 32, 20, 28, 27, 33, 43, - 43, 20, 57, 57, 64, 52, 33, 52, 52, 29, + 26, 27, 15, 24, 26, 25, 29, 24, 30, 195, + 31, 20, 32, 30, 31, 20, 28, 27, 32, 33, + 63, 20, 43, 43, 57, 57, 67, 33, 64, 29, - 32, 63, 191, 65, 66, 68, 67, 70, 33, 65, - 69, 68, 52, 33, 40, 40, 52, 67, 66, 64, - 70, 71, 52, 40, 69, 69, 72, 40, 73, 74, - 72, 75, 76, 98, 40, 82, 82, 100, 40, 104, - 40, 71, 83, 83, 74, 96, 96, 101, 73, 102, - 76, 107, 103, 104, 75, 98, 103, 102, 105, 100, - 96, 106, 108, 105, 96, 109, 110, 111, 101, 106, - 96, 112, 122, 107, 123, 111, 108, 109, 125, 112, - 114, 114, 115, 115, 110, 124, 123, 126, 128, 129, - 130, 132, 122, 124, 133, 129, 128, 143, 125, 131, + 52, 66, 52, 52, 32, 65, 69, 66, 68, 33, + 67, 63, 69, 71, 33, 40, 40, 52, 70, 68, + 72, 52, 74, 64, 40, 65, 71, 52, 40, 75, + 73, 76, 70, 70, 73, 40, 99, 77, 102, 40, + 72, 40, 74, 106, 75, 83, 83, 84, 84, 97, + 97, 103, 101, 104, 76, 77, 101, 106, 99, 105, + 102, 104, 107, 105, 97, 108, 109, 107, 97, 110, + 111, 112, 103, 108, 97, 124, 113, 114, 116, 116, + 117, 117, 111, 110, 113, 114, 125, 126, 109, 112, + 127, 129, 128, 131, 132, 124, 133, 135, 127, 126, - 145, 126, 130, 131, 136, 136, 142, 132, 133, 147, - 142, 148, 145, 149, 143, 150, 151, 149, 152, 158, - 159, 160, 152, 163, 166, 158, 151, 172, 173, 147, - 174, 176, 173, 148, 183, 150, 159, 163, 188, 176, - 187, 186, 185, 160, 184, 182, 166, 181, 179, 172, - 175, 174, 171, 170, 183, 169, 168, 167, 165, 164, - 162, 161, 157, 188, 193, 193, 193, 193, 193, 194, - 194, 194, 194, 194, 195, 195, 195, 195, 195, 196, - 196, 197, 197, 197, 197, 197, 198, 198, 198, 156, - 198, 199, 155, 154, 199, 199, 200, 200, 200, 200, + 132, 131, 134, 136, 147, 129, 134, 149, 133, 139, + 139, 125, 128, 135, 145, 151, 152, 136, 145, 149, + 153, 147, 154, 155, 153, 156, 162, 163, 164, 156, + 167, 170, 162, 155, 176, 151, 177, 178, 152, 180, + 177, 187, 154, 163, 167, 192, 191, 180, 190, 189, + 164, 188, 186, 170, 185, 183, 176, 179, 178, 175, + 174, 187, 173, 172, 171, 169, 168, 166, 165, 161, + 192, 197, 197, 197, 197, 197, 198, 198, 198, 198, + 198, 199, 199, 199, 199, 199, 200, 200, 201, 201, + 201, 201, 201, 202, 202, 202, 160, 202, 203, 159, - 200, 201, 153, 201, 201, 201, 146, 144, 141, 140, - 139, 138, 137, 135, 134, 127, 121, 120, 119, 118, - 117, 99, 94, 93, 92, 91, 90, 89, 77, 61, - 59, 49, 48, 47, 46, 45, 44, 42, 36, 34, - 23, 21, 17, 16, 9, 8, 7, 4, 3, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192 + 158, 203, 203, 204, 204, 204, 204, 204, 205, 157, + 205, 205, 205, 150, 148, 146, 144, 143, 142, 141, + 140, 138, 137, 130, 123, 122, 121, 120, 119, 100, + 95, 94, 93, 92, 91, 90, 78, 61, 59, 49, + 48, 47, 46, 45, 44, 42, 36, 34, 23, 21, + 17, 16, 9, 8, 7, 4, 3, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196 } ; /* Table of booleans, true if rule could match eol. */ -static yyconst flex_int32_t yy_rule_can_match_eol[56] = +static yyconst flex_int32_t yy_rule_can_match_eol[57] = { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; + 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. @@ -695,7 +697,7 @@ static void lb_append_char(lex_buf *lb, char new_char) -#line 699 "config_lexer.cc" +#line 701 "config_lexer.cc" #define INITIAL 0 #define C_COMMENT 1 @@ -952,7 +954,7 @@ YY_DECL lex_buf string_buf; -#line 956 "config_lexer.cc" +#line 958 "config_lexer.cc" yylval = yylval_param; @@ -1009,13 +1011,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 193 ) + if ( yy_current_state >= 197 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_current_state != 192 ); + while ( yy_current_state != 196 ); yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; @@ -1222,123 +1224,123 @@ YY_RULE_SETUP case 24: YY_RULE_SETUP #line 182 "config_lexer.ll" -{ yylval->type = TypeNumber; return T_TYPE_NUMBER; } +{ yylval->type = TypeArray; return T_TYPE_ARRAY; } YY_BREAK case 25: YY_RULE_SETUP #line 183 "config_lexer.ll" -{ yylval->type = TypeString; return T_TYPE_STRING; } +{ yylval->type = TypeNumber; return T_TYPE_NUMBER; } YY_BREAK case 26: YY_RULE_SETUP #line 184 "config_lexer.ll" -{ yylval->type = TypeScalar; return T_TYPE_SCALAR; } +{ yylval->type = TypeString; return T_TYPE_STRING; } YY_BREAK case 27: YY_RULE_SETUP #line 185 "config_lexer.ll" -{ yylval->type = TypeAny; return T_TYPE_ANY; } +{ yylval->type = TypeScalar; return T_TYPE_SCALAR; } YY_BREAK case 28: YY_RULE_SETUP #line 186 "config_lexer.ll" -{ return T_VALIDATOR; } +{ yylval->type = TypeAny; return T_TYPE_ANY; } YY_BREAK case 29: YY_RULE_SETUP #line 187 "config_lexer.ll" -{ return T_REQUIRE; } +{ return T_VALIDATOR; } YY_BREAK case 30: YY_RULE_SETUP #line 188 "config_lexer.ll" -{ return T_ATTRIBUTE; } +{ return T_REQUIRE; } YY_BREAK case 31: YY_RULE_SETUP #line 189 "config_lexer.ll" -return T_ABSTRACT; +{ return T_ATTRIBUTE; } YY_BREAK case 32: YY_RULE_SETUP #line 190 "config_lexer.ll" -return T_LOCAL; +return T_ABSTRACT; YY_BREAK case 33: YY_RULE_SETUP #line 191 "config_lexer.ll" -return T_OBJECT; +return T_LOCAL; YY_BREAK case 34: YY_RULE_SETUP #line 192 "config_lexer.ll" -return T_TEMPLATE; +return T_OBJECT; YY_BREAK case 35: YY_RULE_SETUP #line 193 "config_lexer.ll" -return T_INCLUDE; +return T_TEMPLATE; YY_BREAK case 36: YY_RULE_SETUP #line 194 "config_lexer.ll" -return T_LIBRARY; +return T_INCLUDE; YY_BREAK case 37: YY_RULE_SETUP #line 195 "config_lexer.ll" -return T_INHERITS; +return T_LIBRARY; YY_BREAK case 38: YY_RULE_SETUP #line 196 "config_lexer.ll" -return T_NULL; +return T_INHERITS; YY_BREAK case 39: YY_RULE_SETUP #line 197 "config_lexer.ll" -return T_PARTIAL; +return T_NULL; YY_BREAK case 40: YY_RULE_SETUP #line 198 "config_lexer.ll" -{ yylval->num = 1; return T_NUMBER; } +return T_PARTIAL; YY_BREAK case 41: YY_RULE_SETUP #line 199 "config_lexer.ll" -{ yylval->num = 0; return T_NUMBER; } +{ yylval->num = 1; return T_NUMBER; } YY_BREAK case 42: YY_RULE_SETUP #line 200 "config_lexer.ll" -{ yylval->text = strdup(yytext); return T_IDENTIFIER; } +{ yylval->num = 0; return T_NUMBER; } YY_BREAK case 43: -/* rule 43 can match eol */ YY_RULE_SETUP #line 201 "config_lexer.ll" -{ yytext[yyleng-1] = '\0'; yylval->text = strdup(yytext + 1); return T_STRING_ANGLE; } +{ yylval->text = strdup(yytext); return T_IDENTIFIER; } YY_BREAK case 44: +/* rule 44 can match eol */ YY_RULE_SETUP #line 202 "config_lexer.ll" -{ yylval->num = strtod(yytext, NULL) / 1000; return T_NUMBER; } +{ yytext[yyleng-1] = '\0'; yylval->text = strdup(yytext + 1); return T_STRING_ANGLE; } YY_BREAK case 45: YY_RULE_SETUP #line 203 "config_lexer.ll" -{ yylval->num = strtod(yytext, NULL) * 60 * 60; return T_NUMBER; } +{ yylval->num = strtod(yytext, NULL) / 1000; return T_NUMBER; } YY_BREAK case 46: YY_RULE_SETUP #line 204 "config_lexer.ll" -{ yylval->num = strtod(yytext, NULL) * 60; return T_NUMBER; } +{ yylval->num = strtod(yytext, NULL) * 60 * 60; return T_NUMBER; } YY_BREAK case 47: YY_RULE_SETUP #line 205 "config_lexer.ll" -{ yylval->num = strtod(yytext, NULL); return T_NUMBER; } +{ yylval->num = strtod(yytext, NULL) * 60; return T_NUMBER; } YY_BREAK case 48: YY_RULE_SETUP @@ -1348,40 +1350,45 @@ YY_RULE_SETUP case 49: YY_RULE_SETUP #line 207 "config_lexer.ll" -{ yylval->op = OperatorSet; return T_EQUAL; } +{ yylval->num = strtod(yytext, NULL); return T_NUMBER; } YY_BREAK case 50: YY_RULE_SETUP #line 208 "config_lexer.ll" -{ yylval->op = OperatorPlus; return T_PLUS_EQUAL; } +{ yylval->op = OperatorSet; return T_EQUAL; } YY_BREAK case 51: YY_RULE_SETUP #line 209 "config_lexer.ll" -{ yylval->op = OperatorMinus; return T_MINUS_EQUAL; } +{ yylval->op = OperatorPlus; return T_PLUS_EQUAL; } YY_BREAK case 52: YY_RULE_SETUP #line 210 "config_lexer.ll" -{ yylval->op = OperatorMultiply; return T_MULTIPLY_EQUAL; } +{ yylval->op = OperatorMinus; return T_MINUS_EQUAL; } YY_BREAK case 53: YY_RULE_SETUP #line 211 "config_lexer.ll" +{ yylval->op = OperatorMultiply; return T_MULTIPLY_EQUAL; } + YY_BREAK +case 54: +YY_RULE_SETUP +#line 212 "config_lexer.ll" { yylval->op = OperatorDivide; return T_DIVIDE_EQUAL; } YY_BREAK -case 54: -YY_RULE_SETUP -#line 214 "config_lexer.ll" -return yytext[0]; - YY_BREAK case 55: YY_RULE_SETUP -#line 216 "config_lexer.ll" +#line 215 "config_lexer.ll" +return yytext[0]; + YY_BREAK +case 56: +YY_RULE_SETUP +#line 217 "config_lexer.ll" ECHO; YY_BREAK -#line 1385 "config_lexer.cc" +#line 1392 "config_lexer.cc" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(C_COMMENT): case YY_STATE_EOF(STRING): @@ -1679,7 +1686,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 193 ) + if ( yy_current_state >= 197 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1708,11 +1715,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 193 ) + if ( yy_current_state >= 197 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 192); + yy_is_jam = (yy_current_state == 196); return yy_is_jam ? 0 : yy_current_state; } @@ -2571,7 +2578,7 @@ void yyfree (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 216 "config_lexer.ll" +#line 217 "config_lexer.ll" diff --git a/lib/config/config_lexer.ll b/lib/config/config_lexer.ll index 42666ecf9..7db94e622 100644 --- a/lib/config/config_lexer.ll +++ b/lib/config/config_lexer.ll @@ -179,6 +179,7 @@ static void lb_append_char(lex_buf *lb, char new_char) { type return T_TYPE; dictionary { yylval->type = TypeDictionary; return T_TYPE_DICTIONARY; } +array { yylval->type = TypeArray; return T_TYPE_ARRAY; } number { yylval->type = TypeNumber; return T_TYPE_NUMBER; } string { yylval->type = TypeString; return T_TYPE_STRING; } scalar { yylval->type = TypeScalar; return T_TYPE_SCALAR; } diff --git a/lib/config/config_parser.cc b/lib/config/config_parser.cc index c43670e55..f6e554148 100644 --- a/lib/config/config_parser.cc +++ b/lib/config/config_parser.cc @@ -1,10 +1,8 @@ +/* A Bison parser, made by GNU Bison 2.5. */ -/* A Bison parser, made by GNU Bison 2.4.1. */ - -/* Skeleton implementation for Bison's Yacc-like parsers in C +/* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -46,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.4.1" +#define YYBISON_VERSION "2.5" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -68,8 +66,8 @@ /* Copy the first part of user declarations. */ -/* Line 189 of yacc.c */ -#line 73 "config_parser.cc" +/* Line 268 of yacc.c */ +#line 71 "config_parser.cc" /* Enabling traces. */ #ifndef YYDEBUG @@ -91,7 +89,7 @@ /* "%code requires" blocks. */ -/* Line 209 of yacc.c */ +/* Line 288 of yacc.c */ #line 1 "config_parser.yy" /****************************************************************************** @@ -122,8 +120,8 @@ using namespace icinga; -/* Line 209 of yacc.c */ -#line 127 "config_parser.cc" +/* Line 288 of yacc.c */ +#line 125 "config_parser.cc" /* Tokens. */ #ifndef YYTOKENTYPE @@ -142,22 +140,23 @@ using namespace icinga; T_MULTIPLY_EQUAL = 266, T_DIVIDE_EQUAL = 267, T_TYPE_DICTIONARY = 268, - T_TYPE_NUMBER = 269, - T_TYPE_STRING = 270, - T_TYPE_SCALAR = 271, - T_TYPE_ANY = 272, - T_VALIDATOR = 273, - T_REQUIRE = 274, - T_ATTRIBUTE = 275, - T_TYPE = 276, - T_ABSTRACT = 277, - T_LOCAL = 278, - T_OBJECT = 279, - T_TEMPLATE = 280, - T_INCLUDE = 281, - T_LIBRARY = 282, - T_INHERITS = 283, - T_PARTIAL = 284 + T_TYPE_ARRAY = 269, + T_TYPE_NUMBER = 270, + T_TYPE_STRING = 271, + T_TYPE_SCALAR = 272, + T_TYPE_ANY = 273, + T_VALIDATOR = 274, + T_REQUIRE = 275, + T_ATTRIBUTE = 276, + T_TYPE = 277, + T_ABSTRACT = 278, + T_LOCAL = 279, + T_OBJECT = 280, + T_TEMPLATE = 281, + T_INCLUDE = 282, + T_LIBRARY = 283, + T_INHERITS = 284, + T_PARTIAL = 285 }; #endif /* Tokens. */ @@ -172,22 +171,23 @@ using namespace icinga; #define T_MULTIPLY_EQUAL 266 #define T_DIVIDE_EQUAL 267 #define T_TYPE_DICTIONARY 268 -#define T_TYPE_NUMBER 269 -#define T_TYPE_STRING 270 -#define T_TYPE_SCALAR 271 -#define T_TYPE_ANY 272 -#define T_VALIDATOR 273 -#define T_REQUIRE 274 -#define T_ATTRIBUTE 275 -#define T_TYPE 276 -#define T_ABSTRACT 277 -#define T_LOCAL 278 -#define T_OBJECT 279 -#define T_TEMPLATE 280 -#define T_INCLUDE 281 -#define T_LIBRARY 282 -#define T_INHERITS 283 -#define T_PARTIAL 284 +#define T_TYPE_ARRAY 269 +#define T_TYPE_NUMBER 270 +#define T_TYPE_STRING 271 +#define T_TYPE_SCALAR 272 +#define T_TYPE_ANY 273 +#define T_VALIDATOR 274 +#define T_REQUIRE 275 +#define T_ATTRIBUTE 276 +#define T_TYPE 277 +#define T_ABSTRACT 278 +#define T_LOCAL 279 +#define T_OBJECT 280 +#define T_TEMPLATE 281 +#define T_INCLUDE 282 +#define T_LIBRARY 283 +#define T_INHERITS 284 +#define T_PARTIAL 285 @@ -196,7 +196,7 @@ using namespace icinga; typedef union YYSTYPE { -/* Line 214 of yacc.c */ +/* Line 293 of yacc.c */ #line 38 "config_parser.yy" char *text; @@ -207,7 +207,7 @@ typedef union YYSTYPE -/* Line 214 of yacc.c */ +/* Line 293 of yacc.c */ #line 212 "config_parser.cc" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 @@ -231,8 +231,8 @@ typedef struct YYLTYPE /* Copy the second part of user declarations. */ -/* Line 264 of yacc.c */ -#line 83 "config_parser.yy" +/* Line 343 of yacc.c */ +#line 85 "config_parser.yy" int yylex(YYSTYPE *lvalp, YYLTYPE *llocp, void *scanner); @@ -247,7 +247,7 @@ void yyerror(YYLTYPE *locp, ConfigCompiler *, const char *err) int yyparse(ConfigCompiler *context); static stack m_ExpressionLists; -static Dictionary::Ptr m_Array; +static stack m_Arrays; static ConfigItemBuilder::Ptr m_Item; static bool m_Abstract; static bool m_Local; @@ -270,7 +270,7 @@ void ConfigCompiler::Compile(void) -/* Line 264 of yacc.c */ +/* Line 343 of yacc.c */ #line 275 "config_parser.cc" #ifdef short @@ -321,7 +321,7 @@ typedef short int yytype_int16; #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# if YYENABLE_NLS +# if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) @@ -374,11 +374,11 @@ YYID (yyi) # define alloca _alloca # else # define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 # endif # endif # endif @@ -401,24 +401,24 @@ YYID (yyi) # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif -# if (defined __cplusplus && ! defined _STDLIB_H \ +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc -# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free -# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif @@ -449,23 +449,7 @@ union yyalloc ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + 2 * YYSTACK_GAP_MAXIMUM) -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (YYID (0)) -# endif -# endif +# define YYCOPY_NEEDED 1 /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of @@ -485,23 +469,43 @@ union yyalloc #endif +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif +#endif /* !YYCOPY_NEEDED */ + /* YYFINAL -- State number of the termination state. */ #define YYFINAL 2 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 80 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 39 +#define YYNTOKENS 40 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 32 +#define YYNNTS 36 /* YYNRULES -- Number of rules. */ -#define YYNRULES 68 +#define YYNRULES 76 /* YYNRULES -- Number of states. */ -#define YYNSTATES 92 +#define YYNSTATES 100 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 284 +#define YYMAXUTOK 285 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -513,15 +517,15 @@ static const yytype_uint8 yytranslate[] = 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 32, 30, 36, 31, 2, 33, 2, 2, + 2, 2, 33, 31, 37, 32, 2, 34, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 37, 2, 38, 2, 2, 2, 2, 2, 2, + 2, 38, 2, 39, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 34, 2, 35, 2, 2, 2, 2, + 2, 2, 2, 35, 2, 36, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -537,7 +541,7 @@ static const yytype_uint8 yytranslate[] = 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29 + 25, 26, 27, 28, 29, 30 }; #if YYDEBUG @@ -548,45 +552,49 @@ static const yytype_uint8 yyprhs[] = 0, 0, 3, 4, 7, 9, 11, 13, 15, 18, 21, 24, 26, 28, 29, 36, 37, 39, 40, 45, 47, 50, 51, 53, 57, 60, 63, 67, 72, 73, - 76, 78, 80, 82, 84, 86, 87, 88, 96, 99, - 101, 102, 105, 107, 109, 111, 115, 117, 118, 121, - 122, 127, 129, 132, 133, 135, 139, 143, 150, 152, - 154, 156, 158, 160, 162, 164, 166, 168, 170 + 76, 78, 80, 82, 84, 86, 88, 89, 90, 98, + 101, 103, 104, 107, 109, 111, 113, 117, 119, 120, + 123, 124, 129, 131, 134, 135, 137, 141, 145, 152, + 154, 156, 158, 160, 162, 163, 168, 170, 173, 174, + 176, 180, 182, 184, 186, 188, 190 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { - 40, 0, -1, -1, 40, 41, -1, 54, -1, 45, - -1, 42, -1, 43, -1, 26, 3, -1, 26, 4, - -1, 27, 3, -1, 7, -1, 3, -1, -1, 47, - 21, 44, 46, 53, 48, -1, -1, 29, -1, -1, - 34, 49, 50, 35, -1, 51, -1, 51, 36, -1, - -1, 52, -1, 51, 36, 52, -1, 19, 3, -1, - 18, 3, -1, 20, 45, 3, -1, 20, 45, 3, - 48, -1, -1, 28, 3, -1, 13, -1, 14, -1, - 15, -1, 16, -1, 17, -1, -1, -1, 55, 57, - 44, 3, 56, 62, 63, -1, 58, 24, -1, 25, - -1, -1, 58, 59, -1, 22, -1, 23, -1, 61, - -1, 60, 36, 61, -1, 3, -1, -1, 28, 60, - -1, -1, 34, 64, 65, 35, -1, 66, -1, 66, - 36, -1, -1, 67, -1, 66, 36, 67, -1, 44, - 68, 70, -1, 44, 37, 3, 38, 68, 70, -1, - 70, -1, 8, -1, 9, -1, 10, -1, 11, -1, - 12, -1, 3, -1, 5, -1, 6, -1, 69, -1, - 63, -1 + 41, 0, -1, -1, 41, 42, -1, 55, -1, 46, + -1, 43, -1, 44, -1, 27, 3, -1, 27, 4, + -1, 28, 3, -1, 7, -1, 3, -1, -1, 48, + 22, 45, 47, 54, 49, -1, -1, 30, -1, -1, + 35, 50, 51, 36, -1, 52, -1, 52, 37, -1, + -1, 53, -1, 52, 37, 53, -1, 20, 3, -1, + 19, 3, -1, 21, 46, 3, -1, 21, 46, 3, + 49, -1, -1, 29, 3, -1, 13, -1, 14, -1, + 15, -1, 16, -1, 17, -1, 18, -1, -1, -1, + 56, 58, 45, 3, 57, 63, 64, -1, 59, 25, + -1, 26, -1, -1, 59, 60, -1, 23, -1, 24, + -1, 62, -1, 61, 37, 62, -1, 3, -1, -1, + 29, 61, -1, -1, 35, 65, 66, 36, -1, 67, + -1, 67, 37, -1, -1, 68, -1, 67, 37, 68, + -1, 45, 69, 75, -1, 45, 38, 3, 39, 69, + 75, -1, 8, -1, 9, -1, 10, -1, 11, -1, + 12, -1, -1, 38, 71, 72, 39, -1, 73, -1, + 73, 37, -1, -1, 75, -1, 73, 37, 75, -1, + 3, -1, 5, -1, 6, -1, 70, -1, 74, -1, + 64, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 121, 121, 122, 125, 125, 125, 125, 128, 133, - 139, 145, 146, 154, 153, 183, 186, 193, 192, 204, - 205, 207, 208, 209, 212, 217, 222, 229, 238, 239, - 246, 247, 248, 249, 250, 257, 262, 257, 287, 288, - 293, 294, 297, 301, 307, 308, 311, 318, 319, 323, - 322, 334, 335, 337, 338, 339, 342, 350, 364, 373, - 374, 375, 376, 377, 383, 388, 392, 398, 399 + 0, 123, 123, 124, 127, 127, 127, 127, 130, 135, + 141, 147, 148, 156, 155, 185, 188, 195, 194, 206, + 207, 209, 210, 211, 214, 219, 224, 231, 240, 241, + 248, 249, 250, 251, 252, 253, 260, 265, 260, 290, + 291, 296, 297, 300, 304, 310, 311, 314, 321, 322, + 326, 325, 337, 338, 340, 341, 342, 345, 353, 369, + 370, 371, 372, 373, 380, 379, 391, 392, 394, 395, + 399, 405, 410, 414, 418, 424, 425 }; #endif @@ -598,18 +606,19 @@ static const char *const yytname[] = "$end", "error", "$undefined", "T_STRING", "T_STRING_ANGLE", "T_NUMBER", "T_NULL", "T_IDENTIFIER", "T_EQUAL", "T_PLUS_EQUAL", "T_MINUS_EQUAL", "T_MULTIPLY_EQUAL", "T_DIVIDE_EQUAL", "T_TYPE_DICTIONARY", - "T_TYPE_NUMBER", "T_TYPE_STRING", "T_TYPE_SCALAR", "T_TYPE_ANY", - "T_VALIDATOR", "T_REQUIRE", "T_ATTRIBUTE", "T_TYPE", "T_ABSTRACT", - "T_LOCAL", "T_OBJECT", "T_TEMPLATE", "T_INCLUDE", "T_LIBRARY", - "T_INHERITS", "T_PARTIAL", "'+'", "'-'", "'*'", "'/'", "'{'", "'}'", - "','", "'['", "']'", "$accept", "statements", "statement", "include", - "library", "identifier", "type", "$@1", "partial_specifier", + "T_TYPE_ARRAY", "T_TYPE_NUMBER", "T_TYPE_STRING", "T_TYPE_SCALAR", + "T_TYPE_ANY", "T_VALIDATOR", "T_REQUIRE", "T_ATTRIBUTE", "T_TYPE", + "T_ABSTRACT", "T_LOCAL", "T_OBJECT", "T_TEMPLATE", "T_INCLUDE", + "T_LIBRARY", "T_INHERITS", "T_PARTIAL", "'+'", "'-'", "'*'", "'/'", + "'{'", "'}'", "','", "'['", "']'", "$accept", "statements", "statement", + "include", "library", "identifier", "type", "$@1", "partial_specifier", "typerulelist", "$@2", "typerules", "typerules_inner", "typerule", "type_inherits_specifier", "object", "$@3", "$@4", "object_declaration", "attributes", "attribute", "object_inherits_list", "object_inherits_item", "object_inherits_specifier", "expressionlist", "$@5", "expressions", "expressions_inner", "expression", "operator", - "simplevalue", "value", 0 + "array", "$@6", "array_items", "array_items_inner", "simplevalue", + "value", 0 }; #endif @@ -621,20 +630,21 @@ static const yytype_uint16 yytoknum[] = 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 43, 45, 42, 47, 123, 125, 44, 91, 93 + 285, 43, 45, 42, 47, 123, 125, 44, 91, 93 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 39, 40, 40, 41, 41, 41, 41, 42, 42, - 43, 44, 44, 46, 45, 47, 47, 49, 48, 50, - 50, 51, 51, 51, 52, 52, 52, 52, 53, 53, - 45, 45, 45, 45, 45, 55, 56, 54, 57, 57, - 58, 58, 59, 59, 60, 60, 61, 62, 62, 64, - 63, 65, 65, 66, 66, 66, 67, 67, 67, 68, - 68, 68, 68, 68, 69, 69, 69, 70, 70 + 0, 40, 41, 41, 42, 42, 42, 42, 43, 43, + 44, 45, 45, 47, 46, 48, 48, 50, 49, 51, + 51, 52, 52, 52, 53, 53, 53, 53, 54, 54, + 46, 46, 46, 46, 46, 46, 56, 57, 55, 58, + 58, 59, 59, 60, 60, 61, 61, 62, 63, 63, + 65, 64, 66, 66, 67, 67, 67, 68, 68, 69, + 69, 69, 69, 69, 71, 70, 72, 72, 73, 73, + 73, 74, 74, 74, 74, 75, 75 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -643,109 +653,115 @@ static const yytype_uint8 yyr2[] = 0, 2, 0, 2, 1, 1, 1, 1, 2, 2, 2, 1, 1, 0, 6, 0, 1, 0, 4, 1, 2, 0, 1, 3, 2, 2, 3, 4, 0, 2, - 1, 1, 1, 1, 1, 0, 0, 7, 2, 1, - 0, 2, 1, 1, 1, 3, 1, 0, 2, 0, - 4, 1, 2, 0, 1, 3, 3, 6, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1 + 1, 1, 1, 1, 1, 1, 0, 0, 7, 2, + 1, 0, 2, 1, 1, 1, 3, 1, 0, 2, + 0, 4, 1, 2, 0, 1, 3, 3, 6, 1, + 1, 1, 1, 1, 0, 4, 1, 2, 0, 1, + 3, 1, 1, 1, 1, 1, 1 }; -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero +/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const yytype_uint8 yydefact[] = { - 2, 35, 1, 30, 31, 32, 33, 34, 0, 0, - 16, 3, 6, 7, 5, 0, 4, 40, 8, 9, - 10, 0, 39, 0, 0, 12, 11, 13, 0, 42, - 43, 38, 41, 28, 36, 0, 0, 47, 29, 17, - 14, 0, 0, 21, 46, 48, 44, 49, 37, 0, - 0, 15, 0, 19, 22, 0, 53, 25, 24, 0, - 18, 20, 45, 12, 65, 66, 0, 68, 0, 51, - 54, 67, 58, 26, 23, 59, 60, 61, 62, 63, - 0, 0, 50, 52, 27, 0, 64, 56, 55, 0, - 0, 57 + 2, 36, 1, 30, 31, 32, 33, 34, 35, 0, + 0, 16, 3, 6, 7, 5, 0, 4, 41, 8, + 9, 10, 0, 40, 0, 0, 12, 11, 13, 0, + 43, 44, 39, 42, 28, 37, 0, 0, 48, 29, + 17, 14, 0, 0, 21, 47, 49, 45, 50, 38, + 0, 0, 15, 0, 19, 22, 0, 54, 25, 24, + 0, 18, 20, 46, 0, 0, 52, 55, 26, 23, + 59, 60, 61, 62, 63, 0, 0, 51, 53, 27, + 0, 71, 72, 73, 64, 76, 74, 75, 57, 56, + 0, 68, 0, 0, 66, 69, 58, 65, 67, 70 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { - -1, 1, 11, 12, 13, 66, 14, 33, 15, 40, - 43, 52, 53, 54, 36, 16, 17, 37, 23, 24, - 32, 45, 46, 42, 67, 56, 68, 69, 70, 81, - 71, 72 + -1, 1, 12, 13, 14, 64, 15, 34, 16, 41, + 44, 53, 54, 55, 37, 17, 18, 38, 24, 25, + 33, 46, 47, 43, 85, 57, 65, 66, 67, 76, + 86, 91, 93, 94, 87, 88 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -62 +#define YYPACT_NINF -72 static const yytype_int8 yypact[] = { - -62, 1, -62, -62, -62, -62, -62, -62, 48, 32, - -62, -62, -62, -62, -62, -15, -62, 22, -62, -62, - -62, 16, -62, 16, 10, -62, -62, -62, 52, -62, - -62, -62, -62, -7, -62, 53, 23, 31, -62, -62, - -62, 55, 26, 30, -62, 25, -62, -62, -62, 59, - 60, -4, 33, 28, -62, 55, -3, -62, -62, 62, - -62, 30, -62, 18, -62, -62, 29, -62, 35, 36, - -62, -62, -62, 23, -62, -62, -62, -62, -62, -62, - 64, 2, -62, -3, -62, 37, -62, -62, -62, 34, - 2, -62 + -72, 1, -72, -72, -72, -72, -72, -72, -72, 47, + 19, -72, -72, -72, -72, -72, 8, -72, 7, -72, + -72, -72, 6, -72, 6, -13, -72, -72, -72, 45, + -72, -72, -72, -72, 26, -72, 49, 21, 28, -72, + -72, -72, 51, 24, 5, -72, 27, -72, -72, -72, + 55, 57, 23, 29, 30, -72, 51, 6, -72, -72, + 58, -72, 5, -72, -4, 32, 33, -72, 21, -72, + -72, -72, -72, -72, -72, 59, -3, -72, 6, -72, + 35, -72, -72, -72, -72, -72, -72, -72, -72, -72, + 34, -3, -3, 36, 39, -72, -72, -72, -3, -72 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -62, -62, -62, -62, -62, 3, 20, -62, -62, 0, - -62, -62, -62, 8, -62, -62, -62, -62, -62, -62, - -62, -62, 19, -62, 38, -62, -62, -62, -6, -13, - -62, -61 + -72, -72, -72, -72, -72, 25, 11, -72, -72, -2, + -72, -72, -72, 9, -72, -72, -72, -72, -72, -72, + -72, -72, 13, -72, 37, -72, -72, -72, -6, -17, + -72, -72, -72, -72, -72, -71 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -65 + number is the opposite. If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -16 static const yytype_int8 yytable[] = { - 63, 2, 64, 65, 26, 86, 21, 64, 65, 3, - 4, 5, 6, 7, 3, 4, 5, 6, 7, 25, - 87, 35, -15, 26, 27, 10, 28, 8, 9, 91, - 10, 47, 29, 30, 31, 20, 47, 75, 76, 77, - 78, 79, 75, 76, 77, 78, 79, 22, 49, 50, - 51, 18, 19, -64, -64, 34, 38, 39, 44, 41, - 47, 55, 57, 58, 61, 73, 80, 85, 60, 74, - 82, 59, 83, 84, 62, 89, 90, 88, 0, 0, - 48 + 81, 2, 82, 83, 70, 71, 72, 73, 74, 26, + 30, 31, 32, 27, 3, 4, 5, 6, 7, 8, + 95, 96, 21, -15, 50, 51, 52, 99, 9, 10, + 22, 11, 48, 23, 75, 84, 3, 4, 5, 6, + 7, 8, 70, 71, 72, 73, 74, 28, 35, 29, + 19, 20, 39, 11, 45, 36, 40, 42, 58, 48, + 59, 68, 80, 60, 56, 61, 79, 62, 77, 63, + 78, 69, 89, 92, 90, 97, 98, 0, 0, 0, + 49 }; +#define yypact_value_is_default(yystate) \ + ((yystate) == (-72)) + +#define yytable_value_is_error(yytable_value) \ + YYID (0) + static const yytype_int8 yycheck[] = { - 3, 0, 5, 6, 7, 3, 21, 5, 6, 13, - 14, 15, 16, 17, 13, 14, 15, 16, 17, 3, - 81, 28, 21, 7, 21, 29, 23, 26, 27, 90, - 29, 34, 22, 23, 24, 3, 34, 8, 9, 10, - 11, 12, 8, 9, 10, 11, 12, 25, 18, 19, - 20, 3, 4, 35, 36, 3, 3, 34, 3, 28, - 34, 36, 3, 3, 36, 3, 37, 3, 35, 61, - 35, 51, 36, 73, 55, 38, 89, 83, -1, -1, - 42 + 3, 0, 5, 6, 8, 9, 10, 11, 12, 3, + 23, 24, 25, 7, 13, 14, 15, 16, 17, 18, + 91, 92, 3, 22, 19, 20, 21, 98, 27, 28, + 22, 30, 35, 26, 38, 38, 13, 14, 15, 16, + 17, 18, 8, 9, 10, 11, 12, 22, 3, 24, + 3, 4, 3, 30, 3, 29, 35, 29, 3, 35, + 3, 3, 3, 52, 37, 36, 68, 37, 36, 56, + 37, 62, 78, 90, 39, 39, 37, -1, -1, -1, + 43 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 40, 0, 13, 14, 15, 16, 17, 26, 27, - 29, 41, 42, 43, 45, 47, 54, 55, 3, 4, - 3, 21, 25, 57, 58, 3, 7, 44, 44, 22, - 23, 24, 59, 46, 3, 28, 53, 56, 3, 34, - 48, 28, 62, 49, 3, 60, 61, 34, 63, 18, - 19, 20, 50, 51, 52, 36, 64, 3, 3, 45, - 35, 36, 61, 3, 5, 6, 44, 63, 65, 66, - 67, 69, 70, 3, 52, 8, 9, 10, 11, 12, - 37, 68, 35, 36, 48, 3, 3, 70, 67, 38, - 68, 70 + 0, 41, 0, 13, 14, 15, 16, 17, 18, 27, + 28, 30, 42, 43, 44, 46, 48, 55, 56, 3, + 4, 3, 22, 26, 58, 59, 3, 7, 45, 45, + 23, 24, 25, 60, 47, 3, 29, 54, 57, 3, + 35, 49, 29, 63, 50, 3, 61, 62, 35, 64, + 19, 20, 21, 51, 52, 53, 37, 65, 3, 3, + 46, 36, 37, 62, 45, 66, 67, 68, 3, 53, + 8, 9, 10, 11, 12, 38, 69, 36, 37, 49, + 3, 3, 5, 6, 38, 64, 70, 74, 75, 68, + 39, 71, 69, 72, 73, 75, 75, 39, 37, 75 }; #define yyerrok (yyerrstatus = 0) @@ -760,9 +776,18 @@ static const yytype_uint8 yystos[] = /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ + Once GCC version 2 has supplanted version 1, this can go. However, + YYFAIL appears to be in use. Nevertheless, it is formally deprecated + in Bison 2.4.2's NEWS entry, where a plan to phase it out is + discussed. */ #define YYFAIL goto yyerrlab +#if defined YYFAIL + /* This is here to suppress warnings from the GCC cpp's + -Wunused-macros. Normally we don't worry about that warning, but + some users do, and we want to make it easy for users to remove + YYFAIL uses, which will produce warnings from Bison 2.5. */ +#endif #define YYRECOVERING() (!!yyerrstatus) @@ -772,7 +797,6 @@ do \ { \ yychar = (Token); \ yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK (1); \ goto yybackup; \ } \ @@ -819,7 +843,7 @@ while (YYID (0)) we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# if YYLTYPE_IS_TRIVIAL +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ @@ -1028,7 +1052,6 @@ int yydebug; # define YYMAXDEPTH 10000 #endif - #if YYERROR_VERBOSE @@ -1131,115 +1154,142 @@ yytnamerr (char *yyres, const char *yystr) } # endif -/* Copy into YYRESULT an error message about the unexpected token - YYCHAR while in state YYSTATE. Return the number of bytes copied, - including the terminating null byte. If YYRESULT is null, do not - copy anything; just return the number of bytes that would be - copied. As a special case, return 0 if an ordinary "syntax error" - message will do. Return YYSIZE_MAXIMUM if overflow occurs during - size calculation. */ -static YYSIZE_T -yysyntax_error (char *yyresult, int yystate, int yychar) +/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message + about the unexpected token YYTOKEN for the state stack whose top is + YYSSP. + + Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is + not large enough to hold the message. In that case, also set + *YYMSG_ALLOC to the required number of bytes. Return 2 if the + required number of bytes is too large to store. */ +static int +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, + yytype_int16 *yyssp, int yytoken) { - int yyn = yypact[yystate]; + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = 0; + /* Arguments of yyformat. */ + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + /* Number of reported tokens (one for the "unexpected", one per + "expected"). */ + int yycount = 0; - if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) - return 0; - else + /* There are many possibilities here to consider: + - Assume YYFAIL is not used. It's too flawed to consider. See + + for details. YYERROR is fine as it does not invoke this + function. + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yychar) is if + this state is a consistent state with a default action. Thus, + detecting the absence of a lookahead is sufficient to determine + that there is no unexpected or expected token to report. In that + case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is a + consistent state with a default action. There might have been a + previous inconsistent state, consistent state with a non-default + action, or user semantic action that manipulated yychar. + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state merging + (from LALR or IELR) and default reductions corrupt the expected + token list. However, the list is correct for canonical LR with + one exception: it will still contain any token that will not be + accepted due to an error action in a later state. + */ + if (yytoken != YYEMPTY) { - int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; + int yyn = yypact[*yyssp]; + yyarg[yycount++] = yytname[yytoken]; + if (!yypact_value_is_default (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yyx; -# if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -# endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; - - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; - } - - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - - if (yysize_overflow) - return YYSIZE_MAXIMUM; - - if (yyresult) - { - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - char *yyp = yyresult; - int yyi = 0; - while ((*yyp = *yyf) != '\0') - { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } - } - } - return yysize; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR + && !yytable_value_is_error (yytable[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + } } + + switch (yycount) + { +# define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +# undef YYCASE_ + } + + yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + + if (*yymsg_alloc < yysize) + { + *yymsg_alloc = 2 * yysize; + if (! (yysize <= *yymsg_alloc + && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) + *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; + return 1; + } + + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + { + char *yyp = *yymsg; + int yyi = 0; + while ((*yyp = *yyformat) != '\0') + if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyformat += 2; + } + else + { + yyp++; + yyformat++; + } + } + return 0; } #endif /* YYERROR_VERBOSE */ - /*-----------------------------------------------. | Release the memory associated to this symbol. | @@ -1276,6 +1326,7 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp, context) } } + /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus @@ -1292,12 +1343,9 @@ int yyparse (); #endif /* ! YYPARSE_PARAM */ - - - -/*-------------------------. -| yyparse or yypush_parse. | -`-------------------------*/ +/*----------. +| yyparse. | +`----------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ @@ -1361,7 +1409,7 @@ YYLTYPE yylloc; YYLTYPE *yylsp; /* The locations where the error started and ended. */ - YYLTYPE yyerror_range[2]; + YYLTYPE yyerror_range[3]; YYSIZE_T yystacksize; @@ -1408,7 +1456,7 @@ YYLTYPE yylloc; yyvsp = yyvs; yylsp = yyls; -#if YYLTYPE_IS_TRIVIAL +#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = 1; yylloc.first_column = yylloc.last_column = 1; @@ -1510,7 +1558,7 @@ yybackup: /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) + if (yypact_value_is_default (yyn)) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ @@ -1541,8 +1589,8 @@ yybackup: yyn = yytable[yyn]; if (yyn <= 0) { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; + if (yytable_value_is_error (yyn)) + goto yyerrlab; yyn = -yyn; goto yyreduce; } @@ -1598,8 +1646,8 @@ yyreduce: { case 8: -/* Line 1455 of yacc.c */ -#line 129 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 131 "config_parser.yy" { context->HandleInclude((yyvsp[(2) - (2)].text), false, yylloc); free((yyvsp[(2) - (2)].text)); @@ -1608,8 +1656,8 @@ yyreduce: case 9: -/* Line 1455 of yacc.c */ -#line 134 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 136 "config_parser.yy" { context->HandleInclude((yyvsp[(2) - (2)].text), true, yylloc); free((yyvsp[(2) - (2)].text)); @@ -1618,8 +1666,8 @@ yyreduce: case 10: -/* Line 1455 of yacc.c */ -#line 140 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 142 "config_parser.yy" { context->HandleLibrary((yyvsp[(2) - (2)].text)); free((yyvsp[(2) - (2)].text)); @@ -1628,8 +1676,8 @@ yyreduce: case 12: -/* Line 1455 of yacc.c */ -#line 147 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 149 "config_parser.yy" { (yyval.text) = (yyvsp[(1) - (1)].text); free((yyvsp[(1) - (1)].text)); @@ -1638,8 +1686,8 @@ yyreduce: case 13: -/* Line 1455 of yacc.c */ -#line 154 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 156 "config_parser.yy" { String name = String((yyvsp[(3) - (3)].text)); free((yyvsp[(3) - (3)].text)); @@ -1658,8 +1706,8 @@ yyreduce: case 14: -/* Line 1455 of yacc.c */ -#line 169 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 171 "config_parser.yy" { TypeRuleList::Ptr ruleList = *(yyvsp[(6) - (6)].variant); m_Type->GetRuleList()->AddRules(ruleList); @@ -1675,8 +1723,8 @@ yyreduce: case 15: -/* Line 1455 of yacc.c */ -#line 183 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 185 "config_parser.yy" { (yyval.num) = 0; } @@ -1684,8 +1732,8 @@ yyreduce: case 16: -/* Line 1455 of yacc.c */ -#line 187 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 189 "config_parser.yy" { (yyval.num) = 1; } @@ -1693,8 +1741,8 @@ yyreduce: case 17: -/* Line 1455 of yacc.c */ -#line 193 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 195 "config_parser.yy" { m_RuleLists.push(boost::make_shared()); } @@ -1702,8 +1750,8 @@ yyreduce: case 18: -/* Line 1455 of yacc.c */ -#line 198 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 200 "config_parser.yy" { (yyval.variant) = new Value(m_RuleLists.top()); m_RuleLists.pop(); @@ -1712,8 +1760,8 @@ yyreduce: case 24: -/* Line 1455 of yacc.c */ -#line 213 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 215 "config_parser.yy" { m_RuleLists.top()->AddRequire((yyvsp[(2) - (2)].text)); free((yyvsp[(2) - (2)].text)); @@ -1722,8 +1770,8 @@ yyreduce: case 25: -/* Line 1455 of yacc.c */ -#line 218 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 220 "config_parser.yy" { m_RuleLists.top()->SetValidator((yyvsp[(2) - (2)].text)); free((yyvsp[(2) - (2)].text)); @@ -1732,8 +1780,8 @@ yyreduce: case 26: -/* Line 1455 of yacc.c */ -#line 223 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 225 "config_parser.yy" { TypeRule rule((yyvsp[(2) - (3)].type), (yyvsp[(3) - (3)].text), TypeRuleList::Ptr(), yylloc); free((yyvsp[(3) - (3)].text)); @@ -1744,8 +1792,8 @@ yyreduce: case 27: -/* Line 1455 of yacc.c */ -#line 230 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 232 "config_parser.yy" { TypeRule rule((yyvsp[(2) - (4)].type), (yyvsp[(3) - (4)].text), *(yyvsp[(4) - (4)].variant), yylloc); free((yyvsp[(3) - (4)].text)); @@ -1756,37 +1804,37 @@ yyreduce: case 29: -/* Line 1455 of yacc.c */ -#line 240 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 242 "config_parser.yy" { m_Type->SetParent((yyvsp[(2) - (2)].text)); free((yyvsp[(2) - (2)].text)); } break; - case 34: + case 35: -/* Line 1455 of yacc.c */ -#line 251 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 254 "config_parser.yy" { (yyval.type) = (yyvsp[(1) - (1)].type); } break; - case 35: + case 36: -/* Line 1455 of yacc.c */ -#line 257 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 260 "config_parser.yy" { m_Abstract = false; m_Local = false; } break; - case 36: + case 37: -/* Line 1455 of yacc.c */ -#line 262 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 265 "config_parser.yy" { m_Item = boost::make_shared(yylloc); @@ -1800,10 +1848,10 @@ yyreduce: } break; - case 37: + case 38: -/* Line 1455 of yacc.c */ -#line 274 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 277 "config_parser.yy" { ExpressionList::Ptr exprl = *(yyvsp[(7) - (7)].variant); delete (yyvsp[(7) - (7)].variant); @@ -1817,19 +1865,10 @@ yyreduce: } break; - case 39: + case 40: -/* Line 1455 of yacc.c */ -#line 289 "config_parser.yy" - { - m_Abstract = true; - } - break; - - case 42: - -/* Line 1455 of yacc.c */ -#line 298 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 292 "config_parser.yy" { m_Abstract = true; } @@ -1837,46 +1876,55 @@ yyreduce: case 43: -/* Line 1455 of yacc.c */ -#line 302 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 301 "config_parser.yy" + { + m_Abstract = true; + } + break; + + case 44: + +/* Line 1806 of yacc.c */ +#line 305 "config_parser.yy" { m_Local = true; } break; - case 46: + case 47: -/* Line 1455 of yacc.c */ -#line 312 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 315 "config_parser.yy" { m_Item->AddParent((yyvsp[(1) - (1)].text)); free((yyvsp[(1) - (1)].text)); } break; - case 49: + case 50: -/* Line 1455 of yacc.c */ -#line 323 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 326 "config_parser.yy" { m_ExpressionLists.push(boost::make_shared()); } break; - case 50: + case 51: -/* Line 1455 of yacc.c */ -#line 328 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 331 "config_parser.yy" { (yyval.variant) = new Value(m_ExpressionLists.top()); m_ExpressionLists.pop(); } break; - case 56: + case 57: -/* Line 1455 of yacc.c */ -#line 343 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 346 "config_parser.yy" { Expression expr((yyvsp[(1) - (3)].text), (yyvsp[(2) - (3)].op), *(yyvsp[(3) - (3)].variant), yylloc); free((yyvsp[(1) - (3)].text)); @@ -1886,10 +1934,10 @@ yyreduce: } break; - case 57: + case 58: -/* Line 1455 of yacc.c */ -#line 351 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 354 "config_parser.yy" { Expression subexpr((yyvsp[(3) - (6)].text), (yyvsp[(5) - (6)].op), *(yyvsp[(6) - (6)].variant), yylloc); free((yyvsp[(3) - (6)].text)); @@ -1905,22 +1953,10 @@ yyreduce: } break; - case 58: - -/* Line 1455 of yacc.c */ -#line 365 "config_parser.yy" - { - Expression expr(String(), OperatorSet, *(yyvsp[(1) - (1)].variant), yylloc); - delete (yyvsp[(1) - (1)].variant); - - m_ExpressionLists.top()->AddExpression(expr); - } - break; - case 63: -/* Line 1455 of yacc.c */ -#line 378 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 374 "config_parser.yy" { (yyval.op) = (yyvsp[(1) - (1)].op); } @@ -1928,36 +1964,82 @@ yyreduce: case 64: -/* Line 1455 of yacc.c */ -#line 384 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 380 "config_parser.yy" + { + m_Arrays.push(boost::make_shared()); + } + break; + + case 65: + +/* Line 1806 of yacc.c */ +#line 385 "config_parser.yy" + { + (yyval.variant) = new Value(m_Arrays.top()); + m_Arrays.pop(); + } + break; + + case 69: + +/* Line 1806 of yacc.c */ +#line 396 "config_parser.yy" + { + m_Arrays.top()->Add(*(yyvsp[(1) - (1)].variant)); + } + break; + + case 70: + +/* Line 1806 of yacc.c */ +#line 400 "config_parser.yy" + { + m_Arrays.top()->Add(*(yyvsp[(3) - (3)].variant)); + } + break; + + case 71: + +/* Line 1806 of yacc.c */ +#line 406 "config_parser.yy" { (yyval.variant) = new Value((yyvsp[(1) - (1)].text)); free((yyvsp[(1) - (1)].text)); } break; - case 65: + case 72: -/* Line 1455 of yacc.c */ -#line 389 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 411 "config_parser.yy" { (yyval.variant) = new Value((yyvsp[(1) - (1)].num)); } break; - case 66: + case 73: -/* Line 1455 of yacc.c */ -#line 393 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 415 "config_parser.yy" { (yyval.variant) = new Value(); } break; - case 68: + case 74: -/* Line 1455 of yacc.c */ -#line 400 "config_parser.yy" +/* Line 1806 of yacc.c */ +#line 419 "config_parser.yy" + { + (yyval.variant) = (yyvsp[(1) - (1)].variant); + } + break; + + case 76: + +/* Line 1806 of yacc.c */ +#line 426 "config_parser.yy" { (yyval.variant) = (yyvsp[(1) - (1)].variant); } @@ -1965,10 +2047,21 @@ yyreduce: -/* Line 1455 of yacc.c */ -#line 1970 "config_parser.cc" +/* Line 1806 of yacc.c */ +#line 2052 "config_parser.cc" default: break; } + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); @@ -1997,6 +2090,10 @@ yyreduce: | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); + /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { @@ -2004,41 +2101,40 @@ yyerrlab: #if ! YYERROR_VERBOSE yyerror (&yylloc, context, YY_("syntax error")); #else +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ + yyssp, yytoken) { - YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); - if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) - { - YYSIZE_T yyalloc = 2 * yysize; - if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) - yyalloc = YYSTACK_ALLOC_MAXIMUM; - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yyalloc); - if (yymsg) - yymsg_alloc = yyalloc; - else - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - } - } - - if (0 < yysize && yysize <= yymsg_alloc) - { - (void) yysyntax_error (yymsg, yystate, yychar); - yyerror (&yylloc, context, yymsg); - } - else - { - yyerror (&yylloc, context, YY_("syntax error")); - if (yysize != 0) - goto yyexhaustedlab; - } + char const *yymsgp = YY_("syntax error"); + int yysyntax_error_status; + yysyntax_error_status = YYSYNTAX_ERROR; + if (yysyntax_error_status == 0) + yymsgp = yymsg; + else if (yysyntax_error_status == 1) + { + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + if (!yymsg) + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + yysyntax_error_status = 2; + } + else + { + yysyntax_error_status = YYSYNTAX_ERROR; + yymsgp = yymsg; + } + } + yyerror (&yylloc, context, yymsgp); + if (yysyntax_error_status == 2) + goto yyexhaustedlab; } +# undef YYSYNTAX_ERROR #endif } - yyerror_range[0] = yylloc; + yyerror_range[1] = yylloc; if (yyerrstatus == 3) { @@ -2075,7 +2171,7 @@ yyerrorlab: if (/*CONSTCOND*/ 0) goto yyerrorlab; - yyerror_range[0] = yylsp[1-yylen]; + yyerror_range[1] = yylsp[1-yylen]; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); @@ -2094,7 +2190,7 @@ yyerrlab1: for (;;) { yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) + if (!yypact_value_is_default (yyn)) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) @@ -2109,7 +2205,7 @@ yyerrlab1: if (yyssp == yyss) YYABORT; - yyerror_range[0] = *yylsp; + yyerror_range[1] = *yylsp; yydestruct ("Error: popping", yystos[yystate], yyvsp, yylsp, context); YYPOPSTACK (1); @@ -2119,10 +2215,10 @@ yyerrlab1: *++yyvsp = yylval; - yyerror_range[1] = yylloc; + yyerror_range[2] = yylloc; /* Using YYLLOC is tempting, but would change the location of the lookahead. YYLOC is available though. */ - YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); + YYLLOC_DEFAULT (yyloc, yyerror_range, 2); *++yylsp = yyloc; /* Shift the error token. */ @@ -2158,8 +2254,13 @@ yyexhaustedlab: yyreturn: if (yychar != YYEMPTY) - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval, &yylloc, context); + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, &yylloc, context); + } /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); @@ -2184,7 +2285,7 @@ yyreturn: -/* Line 1675 of yacc.c */ -#line 404 "config_parser.yy" +/* Line 2067 of yacc.c */ +#line 430 "config_parser.yy" diff --git a/lib/config/config_parser.h b/lib/config/config_parser.h index 924d92416..fe5f6569a 100644 --- a/lib/config/config_parser.h +++ b/lib/config/config_parser.h @@ -1,10 +1,8 @@ +/* A Bison parser, made by GNU Bison 2.5. */ -/* A Bison parser, made by GNU Bison 2.4.1. */ - -/* Skeleton interface for Bison's Yacc-like parsers in C +/* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,7 +32,7 @@ /* "%code requires" blocks. */ -/* Line 1676 of yacc.c */ +/* Line 2068 of yacc.c */ #line 1 "config_parser.yy" /****************************************************************************** @@ -65,8 +63,8 @@ using namespace icinga; -/* Line 1676 of yacc.c */ -#line 70 "config_parser.h" +/* Line 2068 of yacc.c */ +#line 68 "config_parser.h" /* Tokens. */ #ifndef YYTOKENTYPE @@ -85,22 +83,23 @@ using namespace icinga; T_MULTIPLY_EQUAL = 266, T_DIVIDE_EQUAL = 267, T_TYPE_DICTIONARY = 268, - T_TYPE_NUMBER = 269, - T_TYPE_STRING = 270, - T_TYPE_SCALAR = 271, - T_TYPE_ANY = 272, - T_VALIDATOR = 273, - T_REQUIRE = 274, - T_ATTRIBUTE = 275, - T_TYPE = 276, - T_ABSTRACT = 277, - T_LOCAL = 278, - T_OBJECT = 279, - T_TEMPLATE = 280, - T_INCLUDE = 281, - T_LIBRARY = 282, - T_INHERITS = 283, - T_PARTIAL = 284 + T_TYPE_ARRAY = 269, + T_TYPE_NUMBER = 270, + T_TYPE_STRING = 271, + T_TYPE_SCALAR = 272, + T_TYPE_ANY = 273, + T_VALIDATOR = 274, + T_REQUIRE = 275, + T_ATTRIBUTE = 276, + T_TYPE = 277, + T_ABSTRACT = 278, + T_LOCAL = 279, + T_OBJECT = 280, + T_TEMPLATE = 281, + T_INCLUDE = 282, + T_LIBRARY = 283, + T_INHERITS = 284, + T_PARTIAL = 285 }; #endif /* Tokens. */ @@ -115,22 +114,23 @@ using namespace icinga; #define T_MULTIPLY_EQUAL 266 #define T_DIVIDE_EQUAL 267 #define T_TYPE_DICTIONARY 268 -#define T_TYPE_NUMBER 269 -#define T_TYPE_STRING 270 -#define T_TYPE_SCALAR 271 -#define T_TYPE_ANY 272 -#define T_VALIDATOR 273 -#define T_REQUIRE 274 -#define T_ATTRIBUTE 275 -#define T_TYPE 276 -#define T_ABSTRACT 277 -#define T_LOCAL 278 -#define T_OBJECT 279 -#define T_TEMPLATE 280 -#define T_INCLUDE 281 -#define T_LIBRARY 282 -#define T_INHERITS 283 -#define T_PARTIAL 284 +#define T_TYPE_ARRAY 269 +#define T_TYPE_NUMBER 270 +#define T_TYPE_STRING 271 +#define T_TYPE_SCALAR 272 +#define T_TYPE_ANY 273 +#define T_VALIDATOR 274 +#define T_REQUIRE 275 +#define T_ATTRIBUTE 276 +#define T_TYPE 277 +#define T_ABSTRACT 278 +#define T_LOCAL 279 +#define T_OBJECT 280 +#define T_TEMPLATE 281 +#define T_INCLUDE 282 +#define T_LIBRARY 283 +#define T_INHERITS 284 +#define T_PARTIAL 285 @@ -139,7 +139,7 @@ using namespace icinga; typedef union YYSTYPE { -/* Line 1676 of yacc.c */ +/* Line 2068 of yacc.c */ #line 38 "config_parser.yy" char *text; @@ -150,7 +150,7 @@ typedef union YYSTYPE -/* Line 1676 of yacc.c */ +/* Line 2068 of yacc.c */ #line 155 "config_parser.h" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 diff --git a/lib/config/config_parser.yy b/lib/config/config_parser.yy index 05b69c93b..77ca9b10d 100644 --- a/lib/config/config_parser.yy +++ b/lib/config/config_parser.yy @@ -54,6 +54,7 @@ using namespace icinga; %token T_MULTIPLY_EQUAL %token T_DIVIDE_EQUAL %token T_TYPE_DICTIONARY +%token T_TYPE_ARRAY %token T_TYPE_NUMBER %token T_TYPE_STRING %token T_TYPE_SCALAR @@ -71,6 +72,7 @@ using namespace icinga; %token T_INHERITS %token T_PARTIAL %type identifier +%type array %type simplevalue %type value %type expressionlist @@ -94,7 +96,7 @@ void yyerror(YYLTYPE *locp, ConfigCompiler *, const char *err) int yyparse(ConfigCompiler *context); static stack m_ExpressionLists; -static Dictionary::Ptr m_Array; +static stack m_Arrays; static ConfigItemBuilder::Ptr m_Item; static bool m_Abstract; static bool m_Local; @@ -244,6 +246,7 @@ type_inherits_specifier: /* empty */ ; type: T_TYPE_DICTIONARY + | T_TYPE_ARRAY | T_TYPE_NUMBER | T_TYPE_STRING | T_TYPE_SCALAR @@ -361,13 +364,6 @@ expression: identifier operator value m_ExpressionLists.top()->AddExpression(expr); } - | value - { - Expression expr(String(), OperatorSet, *$1, yylloc); - delete $1; - - m_ExpressionLists.top()->AddExpression(expr); - } ; operator: T_EQUAL @@ -380,6 +376,32 @@ operator: T_EQUAL } ; +array: '[' + { + m_Arrays.push(boost::make_shared()); + } + array_items + ']' + { + $$ = new Value(m_Arrays.top()); + m_Arrays.pop(); + } + ; + +array_items: array_items_inner + | array_items_inner ',' + +array_items_inner: /* empty */ + | value + { + m_Arrays.top()->Add(*$1); + } + | array_items_inner ',' value + { + m_Arrays.top()->Add(*$3); + } + ; + simplevalue: T_STRING { $$ = new Value($1); @@ -393,6 +415,10 @@ simplevalue: T_STRING { $$ = new Value(); } + | array + { + $$ = $1; + } ; value: simplevalue diff --git a/lib/config/typerule.cpp b/lib/config/typerule.cpp index 03262c951..2eab05bf1 100644 --- a/lib/config/typerule.cpp +++ b/lib/config/typerule.cpp @@ -56,14 +56,16 @@ bool TypeRule::MatchValue(const Value& value) const } catch (...) { return false; } - + return true; case TypeDictionary: return value.IsObjectType(); + case TypeArray: + return value.IsObjectType(); + default: return false; } } - diff --git a/lib/config/typerule.h b/lib/config/typerule.h index 384bae68d..6f593f8cf 100644 --- a/lib/config/typerule.h +++ b/lib/config/typerule.h @@ -34,7 +34,8 @@ enum TypeSpecifier TypeScalar, TypeNumber, TypeString, - TypeDictionary + TypeDictionary, + TypeArray }; /** @@ -49,7 +50,7 @@ public: const TypeRuleList::Ptr& subRules, const DebugInfo& debuginfo); TypeRuleList::Ptr GetSubRules(void) const; - + bool MatchName(const String& name) const; bool MatchValue(const Value& value) const; diff --git a/lib/icinga/host.cpp b/lib/icinga/host.cpp index c02136a62..5d1144ee6 100644 --- a/lib/icinga/host.cpp +++ b/lib/icinga/host.cpp @@ -82,7 +82,7 @@ Host::Ptr Host::GetByName(const String& name) return dynamic_pointer_cast(configObject); } -Dictionary::Ptr Host::GetGroups(void) const +Array::Ptr Host::GetGroups(void) const { return m_HostGroups;; } @@ -92,12 +92,12 @@ Dictionary::Ptr Host::GetMacros(void) const return m_Macros; } -Dictionary::Ptr Host::GetHostDependencies(void) const +Array::Ptr Host::GetHostDependencies(void) const { return m_HostDependencies;; } -Dictionary::Ptr Host::GetServiceDependencies(void) const +Array::Ptr Host::GetServiceDependencies(void) const { return m_ServiceDependencies; } @@ -242,29 +242,23 @@ void Host::UpdateSlaveServices(void) CopyServiceAttributes(this, builder); - if (svcdesc.IsScalar()) { - builder->AddParent(svcdesc); - } else if (svcdesc.IsObjectType()) { - Dictionary::Ptr service = svcdesc; - - Dictionary::Ptr templates = service->Get("templates"); - - if (templates) { - ObjectLock olock(templates); - - String tmpl; - BOOST_FOREACH(tie(tuples::ignore, tmpl), templates) { - builder->AddParent(tmpl); - } - } else { - builder->AddParent(svcname); - } - - CopyServiceAttributes(service, builder); - } else { + if (!svcdesc.IsObjectType()) BOOST_THROW_EXCEPTION(invalid_argument("Service description must be either a string or a dictionary.")); + + Dictionary::Ptr service = svcdesc; + + Array::Ptr templates = service->Get("templates"); + + if (templates) { + ObjectLock olock(templates); + + BOOST_FOREACH(const Value& tmpl, templates) { + builder->AddParent(tmpl); + } } + CopyServiceAttributes(service, builder); + ConfigItem::Ptr serviceItem = builder->Compile(); DynamicObject::Ptr dobj = serviceItem->Commit(); @@ -392,20 +386,19 @@ void Host::ValidateServiceDictionary(const ScriptTask::Ptr& task, const vector templates; - if (value.IsScalar()) { - templates.push_back(value); - } else if (value.IsObjectType()) { - Dictionary::Ptr serviceDesc = value; + if (!value.IsObjectType()) + BOOST_THROW_EXCEPTION(invalid_argument("Service description must be a dictionary.")); - Dictionary::Ptr templatesDict = serviceDesc->Get("templates"); - ObjectLock tlock(templatesDict); + Dictionary::Ptr serviceDesc = value; - Value tmpl; - BOOST_FOREACH(tie(tuples::ignore, tmpl), templatesDict) { + Array::Ptr templatesArray = serviceDesc->Get("templates"); + + if (templatesArray) { + ObjectLock tlock(templatesArray); + + BOOST_FOREACH(const Value& tmpl, templatesArray) { templates.push_back(tmpl); } - } else { - continue; } BOOST_FOREACH(const String& name, templates) { @@ -464,13 +457,12 @@ set Host::GetParentHosts(void) const { set parents; - Dictionary::Ptr dependencies = GetHostDependencies(); + Array::Ptr dependencies = GetHostDependencies(); if (dependencies) { ObjectLock olock(dependencies); - Value value; - BOOST_FOREACH(tie(tuples::ignore, value), dependencies) { + BOOST_FOREACH(const Value& value, dependencies) { if (value == GetName()) continue; @@ -500,13 +492,12 @@ set Host::GetParentServices(void) const { set parents; - Dictionary::Ptr dependencies = GetServiceDependencies(); + Array::Ptr dependencies = GetServiceDependencies(); if (dependencies) { ObjectLock olock(dependencies); - Value value; - BOOST_FOREACH(tie(tuples::ignore, value), dependencies) { + BOOST_FOREACH(const Value& value, dependencies) { parents.insert(GetServiceByShortName(value)); } } diff --git a/lib/icinga/host.h b/lib/icinga/host.h index f50d1b10c..1f27487cd 100644 --- a/lib/icinga/host.h +++ b/lib/icinga/host.h @@ -65,11 +65,11 @@ public: static Host::Ptr GetByName(const String& name); String GetDisplayName(void) const; - Dictionary::Ptr GetGroups(void) const; + Array::Ptr GetGroups(void) const; Dictionary::Ptr GetMacros(void) const; - Dictionary::Ptr GetHostDependencies(void) const; - Dictionary::Ptr GetServiceDependencies(void) const; + Array::Ptr GetHostDependencies(void) const; + Array::Ptr GetServiceDependencies(void) const; String GetHostCheck(void) const; Dictionary::Ptr CalculateDynamicMacros(void) const; @@ -102,10 +102,10 @@ protected: private: Attribute m_DisplayName; - Attribute m_HostGroups; + Attribute m_HostGroups; Attribute m_Macros; - Attribute m_HostDependencies; - Attribute m_ServiceDependencies; + Attribute m_HostDependencies; + Attribute m_ServiceDependencies; Attribute m_HostCheck; Dictionary::Ptr m_SlaveServices; diff --git a/lib/icinga/hostgroup.cpp b/lib/icinga/hostgroup.cpp index 07efe9f2b..07c06e8b8 100644 --- a/lib/icinga/hostgroup.cpp +++ b/lib/icinga/hostgroup.cpp @@ -155,14 +155,13 @@ void HostGroup::RefreshMembersCache(void) BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("Host")) { const Host::Ptr& host = static_pointer_cast(object); - Dictionary::Ptr dict; - dict = host->GetGroups(); + Array::Ptr groups; + groups = host->GetGroups(); - if (dict) { - ObjectLock mlock(dict); - Value hostgroup; - BOOST_FOREACH(tie(tuples::ignore, hostgroup), dict) { - newMembersCache[hostgroup].push_back(host); + if (groups) { + ObjectLock mlock(groups); + BOOST_FOREACH(const Value& group, groups) { + newMembersCache[group].push_back(host); } } } diff --git a/lib/icinga/icinga-type.conf b/lib/icinga/icinga-type.conf index 7aaeac355..b71009d67 100644 --- a/lib/icinga/icinga-type.conf +++ b/lib/icinga/icinga-type.conf @@ -20,30 +20,14 @@ type Host { %attribute string "display_name", %attribute string "hostcheck", - %attribute dictionary "hostgroups" { - %attribute string "*" - }, - %attribute dictionary "hostdependencies" { - %attribute string "*" - }, - %attribute dictionary "servicedependencies" { - %attribute string "*", - %attribute dictionary "*" { - %require "host", - %attribute string "host", - - %require "service", - %attribute string "service" - } - }, + %attribute array "hostgroups", + %attribute array "hostdependencies", + %attribute array "servicedependencies", %attribute dictionary "services" { %validator "ValidateServiceDictionary", - %attribute string "*", %attribute dictionary "*" { - %attribute dictionary "templates" { - %attribute string "*" - }, + %attribute array "templates", %attribute string "short_name", @@ -55,46 +39,23 @@ type Host { %attribute number "check_interval", %attribute number "retry_interval", - %attribute dictionary "servicegroups" { - %attribute string "*" - }, - %attribute dictionary "checkers" { - %attribute string "*" - }, - %attribute dictionary "hostdependencies" { - %attribute string "*" - }, - %attribute dictionary "servicedependencies" { - %attribute string "*", - %attribute dictionary "*" { - %require "host", - %attribute string "host", - - %require "service", - %attribute string "service" - } - } + %attribute array "servicegroups", + %attribute array "checkers", + %attribute array "hostdependencies", + %attribute array "servicedependencies" } }, %attribute dictionary "notifications" { - %attribute string "*", %attribute dictionary "*" { - %attribute dictionary "templates" { - %attribute string "*" - }, + %attribute array "templates", %attribute dictionary "macros" { %attribute string "*" }, - %attribute dictionary "users" { - %attribute string "*" - }, - - %attribute dictionary "groups" { - %attribute string "*" - } + %attribute array "users", + %attribute array "groups" } }, @@ -107,12 +68,8 @@ type Host { %attribute dictionary "macros" { %attribute string "*" }, - %attribute dictionary "servicegroups" { - %attribute string "*" - }, - %attribute dictionary "checkers" { - %attribute string "*" - } + %attribute array "servicegroups", + %attribute array "checkers" } type HostGroup { @@ -141,33 +98,16 @@ type Service { %attribute dictionary "macros" { %attribute string "*" }, - %attribute dictionary "check_command" { - %attribute string "_*" - }, + %attribute array "check_command", %attribute string "check_command", %attribute number "max_check_attempts", %attribute string "check_period", %attribute number "check_interval", %attribute number "retry_interval", - %attribute dictionary "hostdependencies" { - %attribute string "*" - }, - %attribute dictionary "servicedependencies" { - %attribute string "*", - %attribute dictionary "*" { - %require "host", - %attribute string "host", - - %require "service", - %attribute string "service" - } - }, - %attribute dictionary "servicegroups" { - %attribute string "*" - }, - %attribute dictionary "checkers" { - %attribute string "*" - }, + %attribute array "hostdependencies", + %attribute array "servicedependencies", + %attribute array "servicegroups", + %attribute array "checkers", %require "methods", %attribute dictionary "methods" { @@ -176,23 +116,15 @@ type Service { }, %attribute dictionary "notifications" { - %attribute string "*", %attribute dictionary "*" { - %attribute dictionary "templates" { - %attribute string "*" - }, + %attribute array "templates", %attribute dictionary "macros" { %attribute string "*" }, - %attribute dictionary "users" { - %attribute string "*" - }, - - %attribute dictionary "groups" { - %attribute string "*" - } + %attribute array "users", + %attribute array "groups" } }, @@ -220,17 +152,10 @@ type Notification { %attribute string "*" }, - %attribute dictionary "users" { - %attribute string "*" - }, + %attribute array "users", + %attribute array "groups", - %attribute dictionary "groups" { - %attribute string "*" - }, - - %attribute dictionary "notification_command" { - %attribute string "_*" - }, + %attribute array "notification_command", %attribute string "notification_command" } @@ -241,9 +166,7 @@ type User { %attribute string "*" }, - %attribute dictionary "groups" { - %attribute string "*" - } + %attribute array "groups" } type UserGroup { diff --git a/lib/icinga/macroprocessor.cpp b/lib/icinga/macroprocessor.cpp index 7d469661f..902c062a4 100644 --- a/lib/icinga/macroprocessor.cpp +++ b/lib/icinga/macroprocessor.cpp @@ -32,20 +32,19 @@ Value MacroProcessor::ResolveMacros(const Value& cmd, const Dictionary::Ptr& mac if (cmd.IsScalar()) { result = InternalResolveMacros(cmd, macros); - } else if (cmd.IsObjectType()) { - Dictionary::Ptr resultDict = boost::make_shared(); - Dictionary::Ptr dict = cmd; + } else if (cmd.IsObjectType()) { + Array::Ptr resultArr = boost::make_shared(); + Array::Ptr arr = cmd; - ObjectLock olock(dict); + ObjectLock olock(arr); - Value arg; - BOOST_FOREACH(tie(tuples::ignore, arg), dict) { - resultDict->Add(InternalResolveMacros(arg, macros)); + BOOST_FOREACH(const Value& arg, arr) { + resultArr->Add(InternalResolveMacros(arg, macros)); } - result = resultDict; + result = resultArr; } else { - BOOST_THROW_EXCEPTION(invalid_argument("Command is not a string or dictionary.")); + BOOST_THROW_EXCEPTION(invalid_argument("Command is not a string or array.")); } return result; diff --git a/lib/icinga/service-check.cpp b/lib/icinga/service-check.cpp index f4315a140..fcd8bccb4 100644 --- a/lib/icinga/service-check.cpp +++ b/lib/icinga/service-check.cpp @@ -80,7 +80,7 @@ double Service::GetRetryInterval(void) const /** * @threadsafety Always. */ -Dictionary::Ptr Service::GetCheckers(void) const +Array::Ptr Service::GetCheckers(void) const { return m_Checkers; } @@ -560,15 +560,14 @@ String Service::StateTypeToString(StateType type) */ bool Service::IsAllowedChecker(const String& checker) const { - Dictionary::Ptr checkers = GetCheckers(); + Array::Ptr checkers = GetCheckers(); if (!checkers) return true; ObjectLock olock(checkers); - Value pattern; - BOOST_FOREACH(tie(tuples::ignore, pattern), checkers) { + BOOST_FOREACH(const Value& pattern, checkers) { if (Utility::Match(pattern, checker)) return true; } diff --git a/lib/icinga/service-notification.cpp b/lib/icinga/service-notification.cpp index 8a107092e..2c3e29108 100644 --- a/lib/icinga/service-notification.cpp +++ b/lib/icinga/service-notification.cpp @@ -221,9 +221,6 @@ void Service::UpdateSlaveNotifications(void) String nfcname; Value nfcdesc; BOOST_FOREACH(tie(nfcname, nfcdesc), notificationDescs) { - if (nfcdesc.IsScalar()) - nfcname = nfcdesc; - stringstream namebuf; namebuf << GetName() << "-" << nfcname; String name = namebuf.str(); @@ -236,29 +233,23 @@ void Service::UpdateSlaveNotifications(void) CopyNotificationAttributes(this, builder); - if (nfcdesc.IsScalar()) { - builder->AddParent(nfcdesc); - } else if (nfcdesc.IsObjectType()) { - Dictionary::Ptr notification = nfcdesc; + if (!nfcdesc.IsObjectType()) + BOOST_THROW_EXCEPTION(invalid_argument("Notification description must be a dictionary.")); - Dictionary::Ptr templates = notification->Get("templates"); + Dictionary::Ptr notification = nfcdesc; - if (templates) { - ObjectLock tlock(templates); + Array::Ptr templates = notification->Get("templates"); - String tmpl; - BOOST_FOREACH(tie(tuples::ignore, tmpl), templates) { - builder->AddParent(tmpl); - } - } else { - builder->AddParent(nfcname); + if (templates) { + ObjectLock tlock(templates); + + BOOST_FOREACH(const Value& tmpl, templates) { + builder->AddParent(tmpl); } - - CopyNotificationAttributes(notification, builder); - } else { - BOOST_THROW_EXCEPTION(invalid_argument("Notification description must be either a string or a dictionary.")); } + CopyNotificationAttributes(notification, builder); + ConfigItem::Ptr notificationItem = builder->Compile(); notificationItem->Commit(); diff --git a/lib/icinga/service.cpp b/lib/icinga/service.cpp index 37a14d79d..cd37f0f91 100644 --- a/lib/icinga/service.cpp +++ b/lib/icinga/service.cpp @@ -148,7 +148,7 @@ Dictionary::Ptr Service::GetMacros(void) const /** * @threadsafety Always. */ -Dictionary::Ptr Service::GetHostDependencies(void) const +Array::Ptr Service::GetHostDependencies(void) const { return m_HostDependencies; } @@ -156,7 +156,7 @@ Dictionary::Ptr Service::GetHostDependencies(void) const /** * @threadsafety Always. */ -Dictionary::Ptr Service::GetServiceDependencies(void) const +Array::Ptr Service::GetServiceDependencies(void) const { return m_ServiceDependencies; } @@ -164,7 +164,7 @@ Dictionary::Ptr Service::GetServiceDependencies(void) const /** * @threadsafety Always. */ -Dictionary::Ptr Service::GetGroups(void) const +Array::Ptr Service::GetGroups(void) const { return m_ServiceGroups; } @@ -381,14 +381,13 @@ set Service::GetParentHosts(void) const if (host) parents.insert(host); - Dictionary::Ptr dependencies = GetHostDependencies(); + Array::Ptr dependencies = GetHostDependencies(); if (dependencies) { ObjectLock olock(dependencies); - String key; - BOOST_FOREACH(tie(key, tuples::ignore), dependencies) { - Host::Ptr host = Host::GetByName(key); + BOOST_FOREACH(const Value& dependency, dependencies) { + Host::Ptr host = Host::GetByName(dependency); if (!host) continue; @@ -408,13 +407,11 @@ set Service::GetParentServices(void) const set parents; Host::Ptr host = GetHost(); - Dictionary::Ptr dependencies = GetServiceDependencies(); + Array::Ptr dependencies = GetServiceDependencies(); if (host && dependencies) { - String key; - Value value; - BOOST_FOREACH(tie(key, value), dependencies) { - Service::Ptr service = host->GetServiceByShortName(value); + BOOST_FOREACH(const Value& dependency, dependencies) { + Service::Ptr service = host->GetServiceByShortName(dependency); if (!service) continue; diff --git a/lib/icinga/service.h b/lib/icinga/service.h index 1666d9dfd..aa211da3b 100644 --- a/lib/icinga/service.h +++ b/lib/icinga/service.h @@ -89,9 +89,9 @@ public: String GetDisplayName(void) const; Host::Ptr GetHost(void) const; Dictionary::Ptr GetMacros(void) const; - Dictionary::Ptr GetHostDependencies(void) const; - Dictionary::Ptr GetServiceDependencies(void) const; - Dictionary::Ptr GetGroups(void) const; + Array::Ptr GetHostDependencies(void) const; + Array::Ptr GetServiceDependencies(void) const; + Array::Ptr GetGroups(void) const; String GetHostName(void) const; String GetShortName(void) const; @@ -107,7 +107,7 @@ public: void SetAcknowledgement(AcknowledgementType acknowledgement); /* Checks */ - Dictionary::Ptr GetCheckers(void) const; + Array::Ptr GetCheckers(void) const; Value GetCheckCommand(void) const; long GetMaxCheckAttempts(void) const; TimePeriod::Ptr GetCheckPeriod(void) const; @@ -254,9 +254,9 @@ private: Attribute m_DisplayName; Attribute m_Macros; - Attribute m_HostDependencies; - Attribute m_ServiceDependencies; - Attribute m_ServiceGroups; + Attribute m_HostDependencies; + Attribute m_ServiceDependencies; + Attribute m_ServiceGroups; Attribute m_ShortName; Attribute m_Acknowledgement; Attribute m_AcknowledgementExpiry; @@ -269,7 +269,7 @@ private: Attribute m_CheckInterval; Attribute m_RetryInterval; Attribute m_NextCheck; - Attribute m_Checkers; + Attribute m_Checkers; Attribute m_CurrentChecker; Attribute m_CheckAttempt; Attribute m_State; diff --git a/lib/icinga/servicegroup.cpp b/lib/icinga/servicegroup.cpp index dfb9bf9c5..bff6ae77a 100644 --- a/lib/icinga/servicegroup.cpp +++ b/lib/icinga/servicegroup.cpp @@ -155,14 +155,12 @@ void ServiceGroup::RefreshMembersCache(void) BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("Service")) { const Service::Ptr& service = static_pointer_cast(object); - Dictionary::Ptr dict; - dict = service->GetGroups(); + Array::Ptr groups = service->GetGroups(); - if (dict) { - ObjectLock mlock(dict); - Value servicegroup; - BOOST_FOREACH(tie(tuples::ignore, servicegroup), dict) { - newMembersCache[servicegroup].push_back(service); + if (groups) { + ObjectLock mlock(groups); + BOOST_FOREACH(const Value& group, groups) { + newMembersCache[group].push_back(service); } } } diff --git a/lib/icinga/user.cpp b/lib/icinga/user.cpp index f85f1c382..a77fd6ef4 100644 --- a/lib/icinga/user.cpp +++ b/lib/icinga/user.cpp @@ -71,7 +71,7 @@ String User::GetDisplayName(void) const /** * @threadsafety Always. */ -Dictionary::Ptr User::GetGroups(void) const +Array::Ptr User::GetGroups(void) const { return m_Groups; } diff --git a/lib/icinga/user.h b/lib/icinga/user.h index 87b2533bc..8bb2273b6 100644 --- a/lib/icinga/user.h +++ b/lib/icinga/user.h @@ -40,7 +40,7 @@ public: static User::Ptr GetByName(const String& name); String GetDisplayName(void) const; - Dictionary::Ptr GetGroups(void) const; + Array::Ptr GetGroups(void) const; Dictionary::Ptr GetMacros(void) const; Dictionary::Ptr CalculateDynamicMacros(void) const; @@ -51,7 +51,7 @@ protected: private: Attribute m_DisplayName; Attribute m_Macros; - Attribute m_Groups; + Attribute m_Groups; }; } diff --git a/lib/icinga/usergroup.cpp b/lib/icinga/usergroup.cpp index 99ff78661..d7a5def95 100644 --- a/lib/icinga/usergroup.cpp +++ b/lib/icinga/usergroup.cpp @@ -137,14 +137,12 @@ void UserGroup::RefreshMembersCache(void) BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("User")) { const User::Ptr& user = static_pointer_cast(object); - Dictionary::Ptr dict; - dict = user->GetGroups(); + Array::Ptr groups = user->GetGroups(); - if (dict) { - ObjectLock mlock(dict); - Value UserGroup; - BOOST_FOREACH(tie(tuples::ignore, UserGroup), dict) { - newMembersCache[UserGroup].push_back(user); + if (groups) { + ObjectLock mlock(groups); + BOOST_FOREACH(const Value& group, groups) { + newMembersCache[group].push_back(user); } } }