From f3d0738e93894edec3275d634852061cc41c634c Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 25 Jun 2013 09:21:25 +0200 Subject: [PATCH] Implement script variables. --- lib/base/Makefile.am | 2 + lib/base/scriptvariable.cpp | 34 ++ lib/base/scriptvariable.h | 47 +++ lib/config/config_lexer.cc | 345 +++++++++--------- lib/config/config_lexer.ll | 1 + lib/config/config_parser.cc | 698 +++++++++++++++++++++--------------- lib/config/config_parser.h | 85 ++--- lib/config/config_parser.yy | 63 +++- 8 files changed, 783 insertions(+), 492 deletions(-) create mode 100644 lib/base/scriptvariable.cpp create mode 100644 lib/base/scriptvariable.h diff --git a/lib/base/Makefile.am b/lib/base/Makefile.am index c7284f9c2..c14525a83 100644 --- a/lib/base/Makefile.am +++ b/lib/base/Makefile.am @@ -60,6 +60,8 @@ libbase_la_SOURCES = \ scriptinterpreter.h \ scriptlanguage.cpp \ scriptlanguage.h \ + scriptvariable.cpp \ + scriptvariable.h \ singleton.h \ socket.cpp \ socket.h \ diff --git a/lib/base/scriptvariable.cpp b/lib/base/scriptvariable.cpp new file mode 100644 index 000000000..149ad60a5 --- /dev/null +++ b/lib/base/scriptvariable.cpp @@ -0,0 +1,34 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) * + * * + * 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 the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#include "base/scriptvariable.h" + +using namespace icinga; + +Registry ScriptVariable::m_Registry; + +Value ScriptVariable::Get(const String& name) +{ + return m_Registry.GetItem(name); +} + +void ScriptVariable::Set(const String& name, const Value& value) +{ + m_Registry.Register(name, value); +} diff --git a/lib/base/scriptvariable.h b/lib/base/scriptvariable.h new file mode 100644 index 000000000..8c17b6dfb --- /dev/null +++ b/lib/base/scriptvariable.h @@ -0,0 +1,47 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) * + * * + * 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 the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#ifndef SCRIPTVARIABLE_H +#define SCRIPTVARIABLE_H + +#include "base/i2-base.h" +#include "base/registry.h" +#include "base/value.h" + +namespace icinga +{ + +/** + * Global registry for script variables. + * + * @ingroup base + */ +class I2_BASE_API ScriptVariable +{ +public: + static Value Get(const String& name); + static void Set(const String& name, const Value& value); + +private: + static Registry m_Registry; +}; + +} + +#endif /* SCRIPTVARIABLE_H */ diff --git a/lib/config/config_lexer.cc b/lib/config/config_lexer.cc index d8921b2bb..6fa32e021 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 57 -#define YY_END_OF_BUFFER 58 +#define YY_NUM_RULES 58 +#define YY_END_OF_BUFFER 59 /* 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[194] = +static yyconst flex_int16_t yy_accept[196] = { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 58, 56, - 21, 21, 1, 56, 44, 56, 56, 56, 50, 56, - 51, 44, 44, 44, 44, 44, 44, 44, 44, 44, - 44, 44, 56, 18, 19, 12, 3, 2, 57, 15, - 15, 0, 0, 0, 44, 54, 52, 50, 53, 16, - 20, 55, 0, 47, 48, 49, 0, 45, 44, 44, - 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, - 44, 44, 44, 44, 44, 0, 17, 12, 11, 4, - 5, 9, 10, 6, 8, 7, 0, 0, 0, 0, - 20, 50, 46, 44, 28, 44, 44, 44, 44, 44, - - 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, - 44, 44, 13, 4, 5, 14, 0, 0, 0, 44, - 44, 44, 44, 44, 44, 44, 44, 29, 40, 44, - 44, 44, 44, 44, 44, 42, 22, 4, 0, 0, - 0, 44, 24, 44, 43, 44, 44, 44, 34, 44, - 44, 44, 44, 44, 44, 0, 0, 0, 44, 44, - 44, 44, 44, 25, 35, 44, 27, 26, 44, 0, - 0, 0, 44, 44, 37, 44, 38, 41, 44, 0, - 31, 0, 33, 44, 39, 36, 0, 0, 44, 32, - 30, 23, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 59, 57, + 21, 21, 1, 57, 45, 57, 57, 57, 51, 57, + 52, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 57, 18, 19, 12, 3, 2, 58, 15, + 15, 0, 0, 0, 45, 55, 53, 51, 54, 16, + 20, 56, 0, 48, 49, 50, 0, 46, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 0, 17, 12, 11, + 4, 5, 9, 10, 6, 8, 7, 0, 0, 0, + 0, 20, 51, 47, 45, 28, 45, 45, 45, 45, + + 45, 45, 45, 45, 45, 45, 45, 45, 45, 44, + 45, 45, 45, 45, 13, 4, 5, 14, 0, 0, + 0, 45, 45, 45, 45, 45, 45, 45, 45, 29, + 40, 45, 45, 45, 45, 45, 45, 42, 22, 4, + 0, 0, 0, 45, 24, 45, 43, 45, 45, 45, + 34, 45, 45, 45, 45, 45, 45, 0, 0, 0, + 45, 45, 45, 45, 45, 25, 35, 45, 27, 26, + 45, 0, 0, 0, 45, 45, 37, 45, 38, 41, + 45, 0, 31, 0, 33, 45, 39, 36, 0, 0, + 45, 32, 30, 23, 0 } ; @@ -446,162 +446,162 @@ static yyconst flex_int32_t yy_meta[43] = 1, 1 } ; -static yyconst flex_int16_t yy_base[202] = +static yyconst flex_int16_t yy_base[204] = { 0, - 0, 0, 346, 345, 40, 42, 308, 307, 348, 353, - 353, 353, 353, 28, 332, 331, 37, 44, 44, 329, - 353, 329, 42, 49, 46, 51, 54, 53, 63, 56, - 64, 69, 302, 353, 332, 0, 353, 353, 99, 353, - 299, 303, 316, 319, 322, 353, 353, 86, 353, 353, - 0, 353, 76, 353, 300, 353, 319, 353, 78, 75, - 85, 81, 74, 92, 79, 106, 102, 109, 113, 90, - 114, 91, 116, 120, 122, 293, 353, 0, 353, 131, - 133, 353, 353, 353, 353, 353, 291, 295, 297, 301, - 0, 136, 353, 134, 314, 135, 136, 125, 138, 137, - - 141, 144, 142, 149, 154, 160, 153, 155, 162, 164, - 165, 170, 353, 170, 175, 353, 293, 289, 299, 176, - 177, 179, 180, 181, 183, 185, 184, 310, 309, 186, - 187, 195, 197, 190, 199, 308, 307, 212, 294, 293, - 297, 210, 303, 200, 302, 205, 211, 215, 299, 216, - 218, 220, 219, 221, 222, 287, 271, 268, 227, 225, - 229, 228, 230, 271, 270, 232, 269, 268, 234, 244, - 258, 242, 238, 243, 262, 242, 261, 259, 244, 236, - 353, 240, 254, 245, 253, 251, 241, 172, 248, 353, - 353, 93, 353, 288, 292, 296, 47, 300, 304, 308, - - 312 + 0, 0, 350, 349, 40, 42, 312, 311, 352, 357, + 357, 357, 357, 28, 336, 335, 37, 44, 44, 333, + 357, 333, 42, 49, 46, 51, 54, 53, 63, 56, + 64, 69, 306, 357, 336, 0, 357, 357, 99, 357, + 303, 307, 320, 323, 326, 357, 357, 86, 357, 357, + 0, 357, 77, 357, 304, 357, 323, 357, 78, 75, + 85, 81, 79, 92, 106, 84, 102, 109, 112, 110, + 114, 91, 116, 120, 122, 126, 297, 357, 0, 357, + 131, 135, 357, 357, 357, 357, 357, 295, 299, 301, + 305, 0, 137, 357, 129, 318, 137, 138, 140, 139, + + 142, 143, 155, 146, 156, 157, 164, 147, 165, 317, + 166, 149, 168, 173, 357, 178, 186, 357, 296, 292, + 302, 171, 177, 180, 185, 184, 186, 190, 187, 313, + 312, 188, 189, 197, 199, 198, 204, 311, 310, 214, + 297, 296, 300, 208, 306, 200, 305, 213, 215, 205, + 304, 216, 219, 222, 223, 221, 224, 298, 280, 289, + 229, 230, 232, 233, 234, 292, 273, 237, 272, 271, + 238, 247, 261, 246, 239, 244, 266, 242, 265, 264, + 245, 240, 357, 241, 257, 247, 256, 254, 244, 230, + 249, 357, 357, 88, 357, 289, 293, 297, 47, 301, + + 305, 309, 313 } ; -static yyconst flex_int16_t yy_def[202] = +static yyconst flex_int16_t yy_def[204] = { 0, - 193, 1, 194, 194, 195, 195, 196, 196, 193, 193, - 193, 193, 193, 193, 197, 193, 193, 193, 193, 198, - 193, 197, 197, 197, 197, 197, 197, 197, 197, 197, - 197, 197, 193, 193, 193, 199, 193, 193, 200, 193, - 193, 193, 193, 193, 197, 193, 193, 193, 193, 193, - 201, 193, 193, 193, 193, 193, 198, 193, 197, 197, - 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, - 197, 197, 197, 197, 197, 193, 193, 199, 193, 193, - 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, - 201, 193, 193, 197, 197, 197, 197, 197, 197, 197, - - 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, - 197, 197, 193, 193, 193, 193, 193, 193, 193, 197, - 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, - 197, 197, 197, 197, 197, 197, 197, 193, 193, 193, - 193, 197, 197, 197, 197, 197, 197, 197, 197, 197, - 197, 197, 197, 197, 197, 193, 193, 193, 197, 197, - 197, 197, 197, 197, 197, 197, 197, 197, 197, 193, - 193, 193, 197, 197, 197, 197, 197, 197, 197, 193, - 193, 193, 197, 197, 197, 197, 193, 193, 197, 193, - 193, 197, 0, 193, 193, 193, 193, 193, 193, 193, - - 193 + 195, 1, 196, 196, 197, 197, 198, 198, 195, 195, + 195, 195, 195, 195, 199, 195, 195, 195, 195, 200, + 195, 199, 199, 199, 199, 199, 199, 199, 199, 199, + 199, 199, 195, 195, 195, 201, 195, 195, 202, 195, + 195, 195, 195, 195, 199, 195, 195, 195, 195, 195, + 203, 195, 195, 195, 195, 195, 200, 195, 199, 199, + 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, + 199, 199, 199, 199, 199, 199, 195, 195, 201, 195, + 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, + 195, 203, 195, 195, 199, 199, 199, 199, 199, 199, + + 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, + 199, 199, 199, 199, 195, 195, 195, 195, 195, 195, + 195, 199, 199, 199, 199, 199, 199, 199, 199, 199, + 199, 199, 199, 199, 199, 199, 199, 199, 199, 195, + 195, 195, 195, 199, 199, 199, 199, 199, 199, 199, + 199, 199, 199, 199, 199, 199, 199, 195, 195, 195, + 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, + 199, 195, 195, 195, 199, 199, 199, 199, 199, 199, + 199, 195, 195, 195, 199, 199, 199, 199, 195, 195, + 199, 195, 195, 199, 0, 195, 195, 195, 195, 195, + + 195, 195, 195 } ; -static yyconst flex_int16_t yy_nxt[396] = +static yyconst flex_int16_t yy_nxt[400] = { 0, 10, 11, 12, 13, 14, 15, 16, 17, 10, 18, 19, 19, 10, 20, 21, 10, 22, 10, 23, 22, 22, 24, 22, 25, 22, 22, 26, 22, 27, 22, 28, 29, 30, 22, 22, 31, 32, 22, 22, 22, 33, 10, 37, 38, 37, 38, 42, 48, 48, 50, - 45, 49, 53, 51, 48, 48, 193, 39, 52, 39, - 193, 59, 43, 193, 63, 193, 44, 193, 193, 54, - 193, 67, 60, 55, 70, 62, 61, 193, 193, 56, - 65, 64, 69, 193, 71, 66, 92, 92, 193, 193, - 68, 73, 193, 193, 53, 193, 48, 48, 101, 193, - - 72, 97, 98, 74, 193, 193, 193, 193, 75, 80, - 81, 54, 99, 94, 95, 55, 193, 100, 82, 96, - 193, 56, 83, 193, 107, 109, 102, 193, 193, 84, - 193, 103, 108, 85, 193, 86, 193, 104, 105, 193, - 106, 114, 115, 115, 115, 110, 92, 92, 193, 193, - 193, 193, 193, 121, 112, 193, 193, 111, 193, 125, - 123, 54, 127, 193, 128, 55, 124, 193, 193, 193, - 120, 56, 122, 130, 193, 126, 193, 129, 193, 193, - 138, 115, 131, 133, 193, 115, 115, 136, 134, 132, - 193, 193, 137, 193, 193, 193, 135, 193, 193, 193, - - 193, 193, 145, 148, 193, 144, 191, 151, 150, 193, - 142, 193, 149, 193, 193, 153, 143, 147, 146, 193, - 154, 152, 115, 115, 193, 193, 161, 155, 159, 193, - 193, 160, 193, 193, 193, 193, 193, 162, 166, 193, - 169, 193, 193, 193, 193, 168, 193, 173, 193, 163, - 164, 175, 193, 167, 165, 174, 193, 193, 193, 193, - 178, 184, 193, 190, 176, 193, 186, 193, 193, 177, - 179, 188, 187, 193, 183, 193, 193, 185, 182, 189, - 181, 180, 193, 193, 193, 193, 172, 192, 34, 34, - 34, 34, 36, 36, 36, 36, 40, 40, 40, 40, - - 57, 57, 57, 57, 78, 171, 170, 78, 79, 79, - 79, 79, 91, 193, 91, 91, 193, 193, 158, 157, - 156, 193, 193, 193, 193, 141, 140, 139, 193, 119, - 118, 117, 116, 113, 58, 93, 193, 90, 89, 88, - 87, 77, 76, 193, 58, 47, 46, 193, 41, 41, - 35, 35, 9, 193, 193, 193, 193, 193, 193, 193, - 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, - 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, - 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, - 193, 193, 193, 193, 193 + 45, 49, 53, 51, 48, 48, 195, 39, 52, 39, + 195, 59, 43, 195, 63, 195, 44, 195, 195, 54, + 195, 67, 60, 55, 70, 62, 61, 195, 195, 56, + 65, 64, 69, 195, 71, 66, 72, 93, 93, 195, + 68, 74, 195, 195, 53, 195, 48, 48, 195, 195, + + 73, 98, 195, 75, 103, 195, 195, 99, 76, 81, + 82, 54, 100, 95, 96, 55, 195, 101, 83, 97, + 195, 56, 84, 195, 195, 102, 195, 110, 195, 85, + 195, 104, 109, 86, 195, 87, 195, 105, 106, 107, + 195, 116, 117, 195, 108, 117, 117, 93, 93, 112, + 111, 195, 195, 195, 195, 123, 195, 195, 114, 113, + 195, 195, 54, 195, 127, 122, 55, 126, 130, 195, + 195, 195, 56, 129, 124, 125, 132, 128, 195, 195, + 195, 137, 195, 134, 131, 195, 133, 195, 140, 117, + 138, 195, 136, 135, 195, 139, 117, 117, 195, 195, + + 195, 195, 195, 195, 195, 144, 146, 147, 150, 153, + 152, 195, 195, 195, 195, 151, 145, 155, 195, 195, + 149, 148, 195, 154, 117, 117, 161, 195, 156, 195, + 195, 162, 157, 195, 163, 195, 195, 195, 195, 165, + 168, 164, 171, 195, 195, 170, 195, 195, 195, 175, + 166, 195, 195, 195, 177, 167, 195, 169, 195, 195, + 176, 195, 186, 195, 193, 180, 192, 188, 195, 178, + 195, 195, 190, 179, 181, 185, 189, 187, 195, 195, + 195, 191, 184, 183, 182, 195, 195, 195, 194, 34, + 34, 34, 34, 36, 36, 36, 36, 40, 40, 40, + + 40, 57, 57, 57, 57, 79, 195, 174, 79, 80, + 80, 80, 80, 92, 173, 92, 92, 172, 195, 195, + 195, 160, 159, 158, 195, 195, 195, 195, 143, 142, + 141, 195, 195, 121, 120, 119, 118, 115, 58, 94, + 195, 91, 90, 89, 88, 78, 77, 195, 58, 47, + 46, 195, 41, 41, 35, 35, 9, 195, 195, 195, + 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, + 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, + 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, + 195, 195, 195, 195, 195, 195, 195, 195, 195 } ; -static yyconst flex_int16_t yy_chk[396] = +static yyconst flex_int16_t yy_chk[400] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 6, 6, 14, 17, 17, 18, - 197, 17, 19, 18, 19, 19, 23, 5, 18, 6, + 199, 17, 19, 18, 19, 19, 23, 5, 18, 6, 25, 23, 14, 24, 25, 26, 14, 28, 27, 19, 30, 28, 23, 19, 30, 24, 23, 29, 31, 19, - 27, 26, 29, 32, 31, 27, 53, 53, 63, 60, - 28, 32, 59, 65, 48, 62, 48, 48, 65, 61, + 27, 26, 29, 32, 31, 27, 31, 53, 53, 60, + 28, 32, 59, 63, 48, 62, 48, 48, 66, 61, - 31, 62, 63, 32, 70, 72, 64, 192, 32, 39, + 31, 62, 194, 32, 66, 72, 64, 63, 32, 39, 39, 48, 64, 59, 60, 48, 67, 64, 39, 61, - 66, 48, 39, 68, 70, 72, 66, 69, 71, 39, - 73, 67, 71, 39, 74, 39, 75, 68, 68, 98, - 69, 80, 80, 81, 81, 73, 92, 92, 94, 96, - 97, 100, 99, 96, 75, 101, 103, 74, 102, 100, - 98, 92, 102, 104, 103, 92, 99, 107, 105, 108, - 94, 92, 97, 105, 106, 101, 109, 104, 110, 111, - 114, 114, 106, 108, 112, 115, 115, 111, 109, 107, - 120, 121, 112, 122, 123, 124, 110, 125, 127, 126, - - 130, 131, 123, 126, 134, 122, 188, 131, 130, 132, - 120, 133, 127, 135, 144, 133, 121, 125, 124, 146, - 134, 132, 138, 138, 142, 147, 146, 135, 142, 148, - 150, 144, 151, 153, 152, 154, 155, 147, 152, 160, - 155, 159, 162, 161, 163, 154, 166, 159, 169, 148, - 150, 161, 173, 153, 151, 160, 176, 174, 179, 184, - 166, 174, 189, 187, 162, 186, 179, 185, 183, 163, - 169, 182, 180, 178, 173, 177, 175, 176, 172, 184, - 171, 170, 168, 167, 165, 164, 158, 189, 194, 194, - 194, 194, 195, 195, 195, 195, 196, 196, 196, 196, - - 198, 198, 198, 198, 199, 157, 156, 199, 200, 200, - 200, 200, 201, 149, 201, 201, 145, 143, 141, 140, - 139, 137, 136, 129, 128, 119, 118, 117, 95, 90, - 89, 88, 87, 76, 57, 55, 45, 44, 43, 42, - 41, 35, 33, 22, 20, 16, 15, 9, 8, 7, - 4, 3, 193, 193, 193, 193, 193, 193, 193, 193, - 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, - 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, - 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, - 193, 193, 193, 193, 193 + 65, 48, 39, 68, 70, 65, 69, 72, 71, 39, + 73, 67, 71, 39, 74, 39, 75, 68, 68, 69, + 76, 81, 81, 95, 70, 82, 82, 93, 93, 74, + 73, 97, 98, 100, 99, 97, 101, 102, 76, 75, + 104, 108, 93, 112, 101, 95, 93, 100, 104, 103, + 105, 106, 93, 103, 98, 99, 106, 102, 107, 109, + 111, 112, 113, 108, 105, 122, 107, 114, 116, 116, + 113, 123, 111, 109, 124, 114, 117, 117, 126, 125, + + 127, 129, 132, 133, 128, 122, 124, 125, 128, 133, + 132, 134, 136, 135, 146, 129, 123, 135, 137, 150, + 127, 126, 144, 134, 140, 140, 144, 148, 136, 149, + 152, 146, 137, 153, 148, 156, 154, 155, 157, 150, + 154, 149, 157, 161, 162, 156, 163, 164, 165, 161, + 152, 168, 171, 175, 163, 153, 178, 155, 176, 181, + 162, 186, 176, 191, 190, 168, 189, 181, 188, 164, + 187, 185, 184, 165, 171, 175, 182, 178, 180, 179, + 177, 186, 174, 173, 172, 170, 169, 167, 191, 196, + 196, 196, 196, 197, 197, 197, 197, 198, 198, 198, + + 198, 200, 200, 200, 200, 201, 166, 160, 201, 202, + 202, 202, 202, 203, 159, 203, 203, 158, 151, 147, + 145, 143, 142, 141, 139, 138, 131, 130, 121, 120, + 119, 110, 96, 91, 90, 89, 88, 77, 57, 55, + 45, 44, 43, 42, 41, 35, 33, 22, 20, 16, + 15, 9, 8, 7, 4, 3, 195, 195, 195, 195, + 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, + 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, + 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, + 195, 195, 195, 195, 195, 195, 195, 195, 195 } ; /* Table of booleans, true if rule could match eol. */ -static yyconst flex_int32_t yy_rule_can_match_eol[58] = +static yyconst flex_int32_t yy_rule_can_match_eol[59] = { 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, 0, 0, 1, 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, }; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. @@ -1019,13 +1019,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 >= 194 ) + if ( yy_current_state >= 196 ) 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 != 193 ); + while ( yy_current_state != 195 ); yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; @@ -1332,33 +1332,33 @@ YY_RULE_SETUP case 44: YY_RULE_SETUP #line 212 "config_lexer.ll" -{ yylval->text = strdup(yytext); return T_IDENTIFIER; } +return T_SET; YY_BREAK case 45: -/* rule 45 can match eol */ YY_RULE_SETUP #line 213 "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 46: +/* rule 46 can match eol */ YY_RULE_SETUP #line 214 "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 47: YY_RULE_SETUP #line 215 "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 48: YY_RULE_SETUP #line 216 "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 49: YY_RULE_SETUP #line 217 "config_lexer.ll" -{ yylval->num = strtod(yytext, NULL); return T_NUMBER; } +{ yylval->num = strtod(yytext, NULL) * 60; return T_NUMBER; } YY_BREAK case 50: YY_RULE_SETUP @@ -1368,40 +1368,45 @@ YY_RULE_SETUP case 51: YY_RULE_SETUP #line 219 "config_lexer.ll" -{ yylval->op = OperatorSet; return T_EQUAL; } +{ yylval->num = strtod(yytext, NULL); return T_NUMBER; } YY_BREAK case 52: YY_RULE_SETUP #line 220 "config_lexer.ll" -{ yylval->op = OperatorPlus; return T_PLUS_EQUAL; } +{ yylval->op = OperatorSet; return T_EQUAL; } YY_BREAK case 53: YY_RULE_SETUP #line 221 "config_lexer.ll" -{ yylval->op = OperatorMinus; return T_MINUS_EQUAL; } +{ yylval->op = OperatorPlus; return T_PLUS_EQUAL; } YY_BREAK case 54: YY_RULE_SETUP #line 222 "config_lexer.ll" -{ yylval->op = OperatorMultiply; return T_MULTIPLY_EQUAL; } +{ yylval->op = OperatorMinus; return T_MINUS_EQUAL; } YY_BREAK case 55: YY_RULE_SETUP #line 223 "config_lexer.ll" +{ yylval->op = OperatorMultiply; return T_MULTIPLY_EQUAL; } + YY_BREAK +case 56: +YY_RULE_SETUP +#line 224 "config_lexer.ll" { yylval->op = OperatorDivide; return T_DIVIDE_EQUAL; } YY_BREAK -case 56: +case 57: YY_RULE_SETUP -#line 226 "config_lexer.ll" +#line 227 "config_lexer.ll" return yytext[0]; YY_BREAK -case 57: +case 58: YY_RULE_SETUP -#line 228 "config_lexer.ll" +#line 229 "config_lexer.ll" ECHO; YY_BREAK -#line 1405 "../../../lib/config/config_lexer.cc" +#line 1410 "../../../lib/config/config_lexer.cc" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(C_COMMENT): case YY_STATE_EOF(STRING): @@ -1699,7 +1704,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 >= 194 ) + if ( yy_current_state >= 196 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1728,11 +1733,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 >= 194 ) + if ( yy_current_state >= 196 ) 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 == 193); + yy_is_jam = (yy_current_state == 195); return yy_is_jam ? 0 : yy_current_state; } @@ -2591,7 +2596,7 @@ void yyfree (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 228 "config_lexer.ll" +#line 229 "config_lexer.ll" diff --git a/lib/config/config_lexer.ll b/lib/config/config_lexer.ll index 299e63b11..d9ac1340c 100644 --- a/lib/config/config_lexer.ll +++ b/lib/config/config_lexer.ll @@ -209,6 +209,7 @@ null return T_NULL; partial return T_PARTIAL; true { yylval->num = 1; return T_NUMBER; } false { yylval->num = 0; return T_NUMBER; } +set return T_SET; [a-zA-Z_\*][:a-zA-Z0-9\-_\*]* { yylval->text = strdup(yytext); return T_IDENTIFIER; } \<[^\>]*\> { yytext[yyleng-1] = '\0'; yylval->text = strdup(yytext + 1); return T_STRING_ANGLE; } -?[0-9]+(\.[0-9]+)?ms { yylval->num = strtod(yytext, NULL) / 1000; return T_NUMBER; } diff --git a/lib/config/config_parser.cc b/lib/config/config_parser.cc index 1f8dbf7f2..afd63dfcc 100644 --- a/lib/config/config_parser.cc +++ b/lib/config/config_parser.cc @@ -122,6 +122,7 @@ #include "base/value.h" #include "base/utility.h" #include "base/array.h" +#include "base/scriptvariable.h" #include #include #include @@ -136,7 +137,7 @@ using namespace icinga; /* Line 288 of yacc.c */ -#line 140 "../../../lib/config/config_parser.cc" +#line 141 "../../../lib/config/config_parser.cc" /* Tokens. */ #ifndef YYTOKENTYPE @@ -154,25 +155,26 @@ using namespace icinga; T_MINUS_EQUAL = 265, T_MULTIPLY_EQUAL = 266, T_DIVIDE_EQUAL = 267, - T_TYPE_DICTIONARY = 268, - T_TYPE_ARRAY = 269, - T_TYPE_NUMBER = 270, - T_TYPE_STRING = 271, - T_TYPE_SCALAR = 272, - T_TYPE_ANY = 273, - T_TYPE_NAME = 274, - T_VALIDATOR = 275, - T_REQUIRE = 276, - T_ATTRIBUTE = 277, - T_TYPE = 278, - T_ABSTRACT = 279, - T_LOCAL = 280, - T_OBJECT = 281, - T_TEMPLATE = 282, - T_INCLUDE = 283, - T_LIBRARY = 284, - T_INHERITS = 285, - T_PARTIAL = 286 + T_SET = 268, + T_TYPE_DICTIONARY = 269, + T_TYPE_ARRAY = 270, + T_TYPE_NUMBER = 271, + T_TYPE_STRING = 272, + T_TYPE_SCALAR = 273, + T_TYPE_ANY = 274, + T_TYPE_NAME = 275, + T_VALIDATOR = 276, + T_REQUIRE = 277, + T_ATTRIBUTE = 278, + T_TYPE = 279, + T_ABSTRACT = 280, + T_LOCAL = 281, + T_OBJECT = 282, + T_TEMPLATE = 283, + T_INCLUDE = 284, + T_LIBRARY = 285, + T_INHERITS = 286, + T_PARTIAL = 287 }; #endif /* Tokens. */ @@ -186,25 +188,26 @@ using namespace icinga; #define T_MINUS_EQUAL 265 #define T_MULTIPLY_EQUAL 266 #define T_DIVIDE_EQUAL 267 -#define T_TYPE_DICTIONARY 268 -#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_TYPE_NAME 274 -#define T_VALIDATOR 275 -#define T_REQUIRE 276 -#define T_ATTRIBUTE 277 -#define T_TYPE 278 -#define T_ABSTRACT 279 -#define T_LOCAL 280 -#define T_OBJECT 281 -#define T_TEMPLATE 282 -#define T_INCLUDE 283 -#define T_LIBRARY 284 -#define T_INHERITS 285 -#define T_PARTIAL 286 +#define T_SET 268 +#define T_TYPE_DICTIONARY 269 +#define T_TYPE_ARRAY 270 +#define T_TYPE_NUMBER 271 +#define T_TYPE_STRING 272 +#define T_TYPE_SCALAR 273 +#define T_TYPE_ANY 274 +#define T_TYPE_NAME 275 +#define T_VALIDATOR 276 +#define T_REQUIRE 277 +#define T_ATTRIBUTE 278 +#define T_TYPE 279 +#define T_ABSTRACT 280 +#define T_LOCAL 281 +#define T_OBJECT 282 +#define T_TEMPLATE 283 +#define T_INCLUDE 284 +#define T_LIBRARY 285 +#define T_INHERITS 286 +#define T_PARTIAL 287 @@ -214,7 +217,7 @@ typedef union YYSTYPE { /* Line 293 of yacc.c */ -#line 53 "config_parser.yy" +#line 54 "config_parser.yy" char *text; double num; @@ -229,7 +232,7 @@ typedef union YYSTYPE /* Line 293 of yacc.c */ -#line 233 "../../../lib/config/config_parser.cc" +#line 236 "../../../lib/config/config_parser.cc" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -253,7 +256,7 @@ typedef struct YYLTYPE /* Copy the second part of user declarations. */ /* Line 343 of yacc.c */ -#line 112 "config_parser.yy" +#line 118 "config_parser.yy" int yylex(YYSTYPE *lvalp, YYLTYPE *llocp, void *scanner); @@ -290,7 +293,7 @@ void ConfigCompiler::Compile(void) /* Line 343 of yacc.c */ -#line 294 "../../../lib/config/config_parser.cc" +#line 297 "../../../lib/config/config_parser.cc" #ifdef short # undef short @@ -511,20 +514,20 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 2 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 83 +#define YYLAST 122 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 43 +#define YYNTOKENS 46 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 32 +#define YYNNTS 35 /* YYNRULES -- Number of rules. */ -#define YYNRULES 75 +#define YYNRULES 88 /* YYNRULES -- Number of states. */ -#define YYNSTATES 102 +#define YYNSTATES 128 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 286 +#define YYMAXUTOK 287 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -535,16 +538,16 @@ static const yytype_uint8 yytranslate[] = 0, 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, + 42, 43, 35, 33, 41, 34, 2, 36, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 39, 40, 34, 32, 38, 33, 2, 35, 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, 44, 2, 45, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 41, 2, 42, 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, 36, 2, 37, 2, 2, 2, 2, + 2, 2, 2, 39, 38, 40, 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, @@ -560,7 +563,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, 30, 31 + 25, 26, 27, 28, 29, 30, 31, 32 }; #if YYDEBUG @@ -568,52 +571,58 @@ static const yytype_uint8 yytranslate[] = YYRHS. */ 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, 74, 79, - 80, 83, 85, 87, 89, 91, 93, 95, 97, 98, - 105, 108, 110, 111, 114, 116, 118, 119, 121, 125, - 126, 129, 133, 135, 138, 139, 141, 145, 149, 156, - 158, 160, 162, 164, 166, 170, 172, 175, 176, 178, - 182, 184, 186, 188, 190, 192 + 0, 0, 3, 4, 7, 9, 11, 13, 15, 17, + 20, 23, 26, 31, 33, 35, 36, 43, 44, 46, + 47, 52, 54, 57, 58, 60, 64, 67, 70, 74, + 81, 86, 87, 90, 92, 94, 96, 98, 100, 102, + 104, 105, 112, 115, 117, 118, 121, 123, 125, 126, + 128, 132, 133, 136, 140, 142, 145, 146, 148, 152, + 156, 163, 165, 167, 169, 171, 173, 177, 179, 182, + 183, 185, 189, 191, 193, 195, 197, 201, 203, 205, + 209, 213, 217, 221, 225, 229, 233, 235, 237 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { - 44, 0, -1, -1, 44, 45, -1, 58, -1, 49, - -1, 46, -1, 47, -1, 28, 3, -1, 28, 4, - -1, 29, 3, -1, 7, -1, 3, -1, -1, 51, - 23, 48, 50, 57, 52, -1, -1, 31, -1, -1, - 36, 53, 54, 37, -1, 55, -1, 55, 38, -1, - -1, 56, -1, 55, 38, 56, -1, 21, 3, -1, - 20, 3, -1, 22, 49, 3, -1, 22, 19, 39, - 48, 40, 3, -1, 22, 49, 3, 52, -1, -1, - 30, 48, -1, 13, -1, 14, -1, 15, -1, 16, - -1, 17, -1, 18, -1, 19, -1, -1, 59, 60, - 48, 3, 64, 65, -1, 61, 26, -1, 27, -1, - -1, 61, 62, -1, 24, -1, 25, -1, -1, 3, - -1, 63, 38, 3, -1, -1, 30, 63, -1, 36, - 66, 37, -1, 67, -1, 67, 38, -1, -1, 68, - -1, 67, 38, 68, -1, 48, 69, 74, -1, 48, - 41, 3, 42, 69, 74, -1, 8, -1, 9, -1, - 10, -1, 11, -1, 12, -1, 41, 71, 42, -1, - 72, -1, 72, 38, -1, -1, 74, -1, 72, 38, - 74, -1, 3, -1, 5, -1, 6, -1, 70, -1, - 73, -1, 65, -1 + 47, 0, -1, -1, 47, 48, -1, 62, -1, 53, + -1, 49, -1, 50, -1, 51, -1, 29, 3, -1, + 29, 4, -1, 30, 3, -1, 13, 52, 8, 80, + -1, 7, -1, 3, -1, -1, 55, 24, 52, 54, + 61, 56, -1, -1, 32, -1, -1, 39, 57, 58, + 40, -1, 59, -1, 59, 41, -1, -1, 60, -1, + 59, 41, 60, -1, 22, 3, -1, 21, 3, -1, + 23, 53, 3, -1, 23, 20, 42, 52, 43, 3, + -1, 23, 53, 3, 56, -1, -1, 31, 52, -1, + 14, -1, 15, -1, 16, -1, 17, -1, 18, -1, + 19, -1, 20, -1, -1, 63, 64, 52, 3, 68, + 69, -1, 65, 27, -1, 28, -1, -1, 65, 66, + -1, 25, -1, 26, -1, -1, 3, -1, 67, 41, + 3, -1, -1, 31, 67, -1, 39, 70, 40, -1, + 71, -1, 71, 41, -1, -1, 72, -1, 71, 41, + 72, -1, 52, 73, 80, -1, 52, 44, 3, 45, + 73, 80, -1, 8, -1, 9, -1, 10, -1, 11, + -1, 12, -1, 44, 75, 45, -1, 76, -1, 76, + 41, -1, -1, 80, -1, 76, 41, 80, -1, 3, + -1, 5, -1, 6, -1, 74, -1, 42, 79, 43, + -1, 5, -1, 52, -1, 79, 33, 79, -1, 79, + 34, 79, -1, 79, 35, 79, -1, 79, 36, 79, + -1, 79, 37, 79, -1, 79, 38, 79, -1, 42, + 79, 43, -1, 77, -1, 69, -1, 78, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 148, 148, 149, 152, 152, 152, 152, 155, 160, - 166, 172, 173, 180, 179, 209, 212, 219, 218, 230, - 231, 233, 234, 235, 238, 243, 248, 255, 263, 272, - 273, 280, 281, 282, 283, 284, 285, 286, 293, 293, - 338, 339, 344, 345, 348, 352, 359, 362, 368, 381, - 384, 390, 396, 400, 406, 409, 415, 427, 433, 447, - 448, 449, 450, 451, 457, 463, 467, 473, 476, 491, - 511, 516, 520, 524, 534, 535 + 0, 154, 154, 155, 158, 158, 158, 158, 158, 161, + 166, 172, 178, 185, 186, 193, 192, 222, 225, 232, + 231, 243, 244, 246, 247, 248, 251, 256, 261, 268, + 276, 285, 286, 293, 294, 295, 296, 297, 298, 299, + 306, 306, 351, 352, 357, 358, 361, 365, 372, 375, + 381, 394, 397, 403, 409, 413, 419, 422, 428, 440, + 446, 460, 461, 462, 463, 464, 470, 476, 480, 486, + 489, 504, 524, 529, 533, 537, 547, 552, 556, 561, + 565, 569, 573, 577, 581, 585, 591, 592, 597 }; #endif @@ -625,24 +634,26 @@ 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)\"", "\"dictionary (T_TYPE_DICTIONARY)\"", - "\"array (T_TYPE_ARRAY)\"", "\"number (T_TYPE_NUMBER)\"", - "\"string (T_TYPE_STRING)\"", "\"scalar (T_TYPE_SCALAR)\"", - "\"any (T_TYPE_ANY)\"", "\"name (T_TYPE_NAME)\"", - "\"%validator (T_VALIDATOR)\"", "\"%require (T_REQUIRE)\"", - "\"%attribute (T_ATTRIBUTE)\"", "\"type (T_TYPE)\"", - "\"abstract (T_ABSTRACT)\"", "\"local (T_LOCAL)\"", + "\"/= (T_DIVIDE_EQUAL)\"", "\"set (T_SET)\"", + "\"dictionary (T_TYPE_DICTIONARY)\"", "\"array (T_TYPE_ARRAY)\"", + "\"number (T_TYPE_NUMBER)\"", "\"string (T_TYPE_STRING)\"", + "\"scalar (T_TYPE_SCALAR)\"", "\"any (T_TYPE_ANY)\"", + "\"name (T_TYPE_NAME)\"", "\"%validator (T_VALIDATOR)\"", + "\"%require (T_REQUIRE)\"", "\"%attribute (T_ATTRIBUTE)\"", + "\"type (T_TYPE)\"", "\"abstract (T_ABSTRACT)\"", "\"local (T_LOCAL)\"", "\"object (T_OBJECT)\"", "\"template (T_TEMPLATE)\"", "\"include (T_INCLUDE)\"", "\"library (T_LIBRARY)\"", "\"inherits (T_INHERITS)\"", "\"partial (T_PARTIAL)\"", "'+'", "'-'", - "'*'", "'/'", "'{'", "'}'", "','", "'('", "')'", "'['", "']'", "$accept", - "statements", "statement", "include", "library", "identifier", "type", - "$@1", "partial_specifier", "typerulelist", "$@2", "typerules", - "typerules_inner", "typerule", "type_inherits_specifier", "object", - "$@3", "object_declaration", "attributes", "attribute", - "object_inherits_list", "object_inherits_specifier", "expressionlist", - "expressions", "expressions_inner", "expression", "operator", "array", - "array_items", "array_items_inner", "simplevalue", "value", 0 + "'*'", "'/'", "'&'", "'|'", "'{'", "'}'", "','", "'('", "')'", "'['", + "']'", "$accept", "statements", "statement", "include", "library", + "variable", "identifier", "type", "$@1", "partial_specifier", + "typerulelist", "$@2", "typerules", "typerules_inner", "typerule", + "type_inherits_specifier", "object", "$@3", "object_declaration", + "attributes", "attribute", "object_inherits_list", + "object_inherits_specifier", "expressionlist", "expressions", + "expressions_inner", "expression", "operator", "array", "array_items", + "array_items_inner", "simplevalue", "constterm", "constexpression", + "value", 0 }; #endif @@ -654,35 +665,37 @@ 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, - 285, 286, 43, 45, 42, 47, 123, 125, 44, 40, - 41, 91, 93 + 285, 286, 287, 43, 45, 42, 47, 38, 124, 123, + 125, 44, 40, 41, 91, 93 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 43, 44, 44, 45, 45, 45, 45, 46, 46, - 47, 48, 48, 50, 49, 51, 51, 53, 52, 54, - 54, 55, 55, 55, 56, 56, 56, 56, 56, 57, - 57, 49, 49, 49, 49, 49, 49, 49, 59, 58, - 60, 60, 61, 61, 62, 62, 63, 63, 63, 64, - 64, 65, 66, 66, 67, 67, 67, 68, 68, 69, - 69, 69, 69, 69, 70, 71, 71, 72, 72, 72, - 73, 73, 73, 73, 74, 74 + 0, 46, 47, 47, 48, 48, 48, 48, 48, 49, + 49, 50, 51, 52, 52, 54, 53, 55, 55, 57, + 56, 58, 58, 59, 59, 59, 60, 60, 60, 60, + 60, 61, 61, 53, 53, 53, 53, 53, 53, 53, + 63, 62, 64, 64, 65, 65, 66, 66, 67, 67, + 67, 68, 68, 69, 70, 70, 71, 71, 71, 72, + 72, 73, 73, 73, 73, 73, 74, 75, 75, 76, + 76, 76, 77, 77, 77, 77, 78, 79, 79, 79, + 79, 79, 79, 79, 79, 79, 80, 80, 80 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ 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, 6, 4, 0, - 2, 1, 1, 1, 1, 1, 1, 1, 0, 6, - 2, 1, 0, 2, 1, 1, 0, 1, 3, 0, - 2, 3, 1, 2, 0, 1, 3, 3, 6, 1, - 1, 1, 1, 1, 3, 1, 2, 0, 1, 3, - 1, 1, 1, 1, 1, 1 + 0, 2, 0, 2, 1, 1, 1, 1, 1, 2, + 2, 2, 4, 1, 1, 0, 6, 0, 1, 0, + 4, 1, 2, 0, 1, 3, 2, 2, 3, 6, + 4, 0, 2, 1, 1, 1, 1, 1, 1, 1, + 0, 6, 2, 1, 0, 2, 1, 1, 0, 1, + 3, 0, 2, 3, 1, 2, 0, 1, 3, 3, + 6, 1, 1, 1, 1, 1, 3, 1, 2, 0, + 1, 3, 1, 1, 1, 1, 3, 1, 1, 3, + 3, 3, 3, 3, 3, 3, 1, 1, 1 }; /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. @@ -690,106 +703,120 @@ static const yytype_uint8 yyr2[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 2, 38, 1, 31, 32, 33, 34, 35, 36, 37, - 0, 0, 16, 3, 6, 7, 5, 0, 4, 42, - 8, 9, 10, 0, 41, 0, 0, 12, 11, 13, - 0, 44, 45, 40, 43, 29, 49, 0, 0, 46, - 0, 30, 17, 14, 47, 50, 54, 39, 21, 0, - 0, 0, 52, 55, 0, 0, 15, 0, 19, 22, - 48, 59, 60, 61, 62, 63, 0, 0, 51, 53, - 25, 24, 37, 0, 18, 20, 0, 70, 71, 72, - 67, 75, 73, 74, 57, 56, 0, 26, 23, 0, - 0, 65, 68, 0, 28, 0, 64, 66, 0, 58, - 69, 27 + 2, 40, 1, 0, 33, 34, 35, 36, 37, 38, + 39, 0, 0, 18, 3, 6, 7, 8, 5, 0, + 4, 44, 14, 13, 0, 9, 10, 11, 0, 43, + 0, 0, 0, 15, 0, 46, 47, 42, 45, 72, + 73, 74, 56, 0, 69, 87, 75, 86, 88, 12, + 31, 51, 0, 0, 54, 57, 77, 0, 78, 0, + 0, 67, 70, 0, 0, 48, 0, 61, 62, 63, + 64, 65, 0, 0, 53, 55, 0, 0, 0, 0, + 0, 0, 0, 76, 66, 68, 32, 19, 16, 49, + 52, 41, 0, 59, 58, 85, 79, 80, 81, 82, + 83, 84, 71, 23, 0, 0, 0, 0, 17, 0, + 21, 24, 50, 0, 27, 26, 39, 0, 20, 22, + 60, 0, 28, 25, 0, 30, 0, 29 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { - -1, 1, 13, 14, 15, 50, 16, 35, 17, 43, - 48, 57, 58, 59, 38, 18, 19, 25, 26, 34, - 45, 40, 81, 51, 52, 53, 67, 82, 90, 91, - 83, 84 + -1, 1, 14, 15, 16, 17, 58, 18, 50, 19, + 88, 103, 109, 110, 111, 64, 20, 21, 30, 31, + 38, 90, 66, 45, 53, 54, 55, 73, 46, 60, + 61, 47, 48, 59, 49 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -49 +#define YYPACT_NINF -47 static const yytype_int8 yypact[] = { - -49, 12, -49, -49, -49, -49, -49, -49, -49, -49, - 7, 10, -49, -49, -49, -49, -49, -1, -49, -4, - -49, -49, -49, 39, -49, 39, 31, -49, -49, -49, - 21, -49, -49, -49, -49, 6, 14, 39, 1, 45, - 9, -49, -49, -49, -49, 23, 39, -49, 38, 59, - -3, 27, 28, -49, 62, 64, 2, 32, 30, -49, - -49, -49, -49, -49, -49, -49, 67, -2, -49, 39, - -49, -49, 33, 68, -49, 38, 34, -49, -49, -49, - -2, -49, -49, -49, -49, -49, 39, 1, -49, 42, - 35, 36, -49, 40, -49, -2, -49, -2, 70, -49, - -49, -49 + -47, 37, -47, 0, -47, -47, -47, -47, -47, -47, + -47, 43, 6, -47, -47, -47, -47, -47, -47, -7, + -47, -4, -47, -47, 18, -47, -47, -47, 0, -47, + 0, 61, -1, -47, 26, -47, -47, -47, -47, -47, + -47, -47, 0, 3, -1, -47, -47, -47, -47, -47, + 9, 13, 4, 28, 8, -47, -47, 3, -47, -15, + 44, 30, -47, 0, 62, 97, 63, -47, -47, -47, + -47, -47, 100, -1, -47, 0, 47, 3, 3, 3, + 3, 3, 3, -47, -47, -1, -47, -47, -47, -47, + 64, -47, 65, -47, -47, -47, 27, 27, 21, 21, + 66, -47, -47, 76, 103, 84, 104, 105, 59, 69, + 70, -47, -47, -1, -47, -47, 71, 109, -47, 76, + -47, 0, 62, -47, 72, -47, 111, -47 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -49, -49, -49, -49, -49, -23, 19, -49, -49, -9, - -49, -49, -49, 4, -49, -49, -49, -49, -49, -49, - -49, -49, 41, -49, -49, 13, -6, -49, -49, -49, - -49, -48 + -47, -47, -47, -47, -47, -47, -3, 11, -47, -47, + -6, -47, -47, -47, -2, -47, -47, -47, -47, -47, + -47, -47, -47, 54, -47, -47, 46, 17, -47, -47, + -47, -47, -47, -46, -43 }; /* 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 YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -16 +#define YYTABLE_NINF -18 static const yytype_int8 yytable[] = { - 29, 77, 30, 78, 79, 61, 62, 63, 64, 65, - 20, 21, 2, 22, 41, 3, 4, 5, 6, 7, - 8, 72, 23, 24, 36, 3, 4, 5, 6, 7, - 8, 9, 92, 12, 46, -15, 37, 42, 66, 80, - 10, 11, 27, 12, 39, 46, 28, 99, 44, 100, - 61, 62, 63, 64, 65, 31, 32, 33, 54, 55, - 56, 49, 60, 93, 68, 70, 69, 71, 75, 74, - 76, 87, 86, 101, 97, 73, 89, 96, 94, 88, - 98, 47, 85, 95 + 24, 62, 39, 22, 40, 41, 22, 23, 56, 27, + 23, 76, 67, 68, 69, 70, 71, 28, 77, 78, + 79, 80, 81, 82, 29, 33, 32, 34, 83, 51, + 93, 96, 97, 98, 99, 100, 101, 2, 42, 52, + 63, 43, 102, 44, 65, 57, 25, 26, 72, 75, + 3, 4, 5, 6, 7, 8, 9, 10, 81, 82, + 86, -17, 79, 80, 81, 82, 11, 12, 74, 13, + 120, 85, 52, 4, 5, 6, 7, 8, 9, 116, + 77, 78, 79, 80, 81, 82, 35, 36, 37, 84, + 95, 13, 67, 68, 69, 70, 71, 106, 107, 108, + 89, 87, 42, 92, 82, 104, 112, 114, 115, 118, + 105, 119, 122, 121, 127, 126, 125, 123, 124, 117, + 91, 94, 113 }; #define yypact_value_is_default(yystate) \ - ((yystate) == (-49)) + ((yystate) == (-47)) #define yytable_value_is_error(yytable_value) \ YYID (0) static const yytype_uint8 yycheck[] = { - 23, 3, 25, 5, 6, 8, 9, 10, 11, 12, - 3, 4, 0, 3, 37, 13, 14, 15, 16, 17, - 18, 19, 23, 27, 3, 13, 14, 15, 16, 17, - 18, 19, 80, 31, 36, 23, 30, 36, 41, 41, - 28, 29, 3, 31, 30, 36, 7, 95, 3, 97, - 8, 9, 10, 11, 12, 24, 25, 26, 20, 21, - 22, 38, 3, 86, 37, 3, 38, 3, 38, 37, - 3, 3, 39, 3, 38, 56, 42, 42, 87, 75, - 40, 40, 69, 89 + 3, 44, 3, 3, 5, 6, 3, 7, 5, 3, + 7, 57, 8, 9, 10, 11, 12, 24, 33, 34, + 35, 36, 37, 38, 28, 28, 8, 30, 43, 3, + 73, 77, 78, 79, 80, 81, 82, 0, 39, 42, + 31, 42, 85, 44, 31, 42, 3, 4, 44, 41, + 13, 14, 15, 16, 17, 18, 19, 20, 37, 38, + 63, 24, 35, 36, 37, 38, 29, 30, 40, 32, + 113, 41, 75, 14, 15, 16, 17, 18, 19, 20, + 33, 34, 35, 36, 37, 38, 25, 26, 27, 45, + 43, 32, 8, 9, 10, 11, 12, 21, 22, 23, + 3, 39, 39, 3, 38, 41, 3, 3, 3, 40, + 45, 41, 3, 42, 3, 43, 122, 119, 121, 108, + 66, 75, 105 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 44, 0, 13, 14, 15, 16, 17, 18, 19, - 28, 29, 31, 45, 46, 47, 49, 51, 58, 59, - 3, 4, 3, 23, 27, 60, 61, 3, 7, 48, - 48, 24, 25, 26, 62, 50, 3, 30, 57, 30, - 64, 48, 36, 52, 3, 63, 36, 65, 53, 38, - 48, 66, 67, 68, 20, 21, 22, 54, 55, 56, - 3, 8, 9, 10, 11, 12, 41, 69, 37, 38, - 3, 3, 19, 49, 37, 38, 3, 3, 5, 6, - 41, 65, 70, 73, 74, 68, 39, 3, 56, 42, - 71, 72, 74, 48, 52, 69, 42, 38, 40, 74, - 74, 3 + 0, 47, 0, 13, 14, 15, 16, 17, 18, 19, + 20, 29, 30, 32, 48, 49, 50, 51, 53, 55, + 62, 63, 3, 7, 52, 3, 4, 3, 24, 28, + 64, 65, 8, 52, 52, 25, 26, 27, 66, 3, + 5, 6, 39, 42, 44, 69, 74, 77, 78, 80, + 54, 3, 52, 70, 71, 72, 5, 42, 52, 79, + 75, 76, 80, 31, 61, 31, 68, 8, 9, 10, + 11, 12, 44, 73, 40, 41, 79, 33, 34, 35, + 36, 37, 38, 43, 45, 41, 52, 39, 56, 3, + 67, 69, 3, 80, 72, 43, 79, 79, 79, 79, + 79, 79, 80, 57, 41, 45, 21, 22, 23, 58, + 59, 60, 3, 73, 3, 3, 20, 53, 40, 41, + 80, 42, 3, 60, 52, 56, 43, 3 }; #define yyerrok (yyerrstatus = 0) @@ -1672,30 +1699,30 @@ yyreduce: YY_REDUCE_PRINT (yyn); switch (yyn) { - case 8: + case 9: /* Line 1806 of yacc.c */ -#line 156 "config_parser.yy" +#line 162 "config_parser.yy" { context->HandleInclude((yyvsp[(2) - (2)].text), false, yylloc); free((yyvsp[(2) - (2)].text)); } break; - case 9: + case 10: /* Line 1806 of yacc.c */ -#line 161 "config_parser.yy" +#line 167 "config_parser.yy" { context->HandleInclude((yyvsp[(2) - (2)].text), true, yylloc); free((yyvsp[(2) - (2)].text)); } break; - case 10: + case 11: /* Line 1806 of yacc.c */ -#line 167 "config_parser.yy" +#line 173 "config_parser.yy" { context->HandleLibrary((yyvsp[(2) - (2)].text)); free((yyvsp[(2) - (2)].text)); @@ -1705,16 +1732,27 @@ yyreduce: case 12: /* Line 1806 of yacc.c */ -#line 174 "config_parser.yy" +#line 179 "config_parser.yy" + { + ScriptVariable::Set((yyvsp[(2) - (4)].text), *(yyvsp[(4) - (4)].variant)); + free((yyvsp[(2) - (4)].text)); + delete (yyvsp[(4) - (4)].variant); + } + break; + + case 14: + +/* Line 1806 of yacc.c */ +#line 187 "config_parser.yy" { (yyval.text) = (yyvsp[(1) - (1)].text); } break; - case 13: + case 15: /* Line 1806 of yacc.c */ -#line 180 "config_parser.yy" +#line 193 "config_parser.yy" { String name = String((yyvsp[(3) - (3)].text)); free((yyvsp[(3) - (3)].text)); @@ -1731,10 +1769,10 @@ yyreduce: } break; - case 14: + case 16: /* Line 1806 of yacc.c */ -#line 195 "config_parser.yy" +#line 208 "config_parser.yy" { TypeRuleList::Ptr ruleList = *(yyvsp[(6) - (6)].variant); m_Type->GetRuleList()->AddRules(ruleList); @@ -1748,67 +1786,67 @@ yyreduce: } break; - case 15: + case 17: /* Line 1806 of yacc.c */ -#line 209 "config_parser.yy" +#line 222 "config_parser.yy" { (yyval.num) = 0; } break; - case 16: + case 18: /* Line 1806 of yacc.c */ -#line 213 "config_parser.yy" +#line 226 "config_parser.yy" { (yyval.num) = 1; } break; - case 17: + case 19: /* Line 1806 of yacc.c */ -#line 219 "config_parser.yy" +#line 232 "config_parser.yy" { m_RuleLists.push(boost::make_shared()); } break; - case 18: + case 20: /* Line 1806 of yacc.c */ -#line 224 "config_parser.yy" +#line 237 "config_parser.yy" { (yyval.variant) = new Value(m_RuleLists.top()); m_RuleLists.pop(); } break; - case 24: + case 26: /* Line 1806 of yacc.c */ -#line 239 "config_parser.yy" +#line 252 "config_parser.yy" { m_RuleLists.top()->AddRequire((yyvsp[(2) - (2)].text)); free((yyvsp[(2) - (2)].text)); } break; - case 25: + case 27: /* Line 1806 of yacc.c */ -#line 244 "config_parser.yy" +#line 257 "config_parser.yy" { m_RuleLists.top()->SetValidator((yyvsp[(2) - (2)].text)); free((yyvsp[(2) - (2)].text)); } break; - case 26: + case 28: /* Line 1806 of yacc.c */ -#line 249 "config_parser.yy" +#line 262 "config_parser.yy" { TypeRule rule((yyvsp[(2) - (3)].type), String(), (yyvsp[(3) - (3)].text), TypeRuleList::Ptr(), yylloc); free((yyvsp[(3) - (3)].text)); @@ -1817,10 +1855,10 @@ yyreduce: } break; - case 27: + case 29: /* Line 1806 of yacc.c */ -#line 256 "config_parser.yy" +#line 269 "config_parser.yy" { TypeRule rule((yyvsp[(2) - (6)].type), (yyvsp[(4) - (6)].text), (yyvsp[(6) - (6)].text), TypeRuleList::Ptr(), yylloc); free((yyvsp[(4) - (6)].text)); @@ -1830,10 +1868,10 @@ yyreduce: } break; - case 28: + case 30: /* Line 1806 of yacc.c */ -#line 264 "config_parser.yy" +#line 277 "config_parser.yy" { TypeRule rule((yyvsp[(2) - (4)].type), String(), (yyvsp[(3) - (4)].text), *(yyvsp[(4) - (4)].variant), yylloc); free((yyvsp[(3) - (4)].text)); @@ -1842,39 +1880,39 @@ yyreduce: } break; - case 30: + case 32: /* Line 1806 of yacc.c */ -#line 274 "config_parser.yy" +#line 287 "config_parser.yy" { m_Type->SetParent((yyvsp[(2) - (2)].text)); free((yyvsp[(2) - (2)].text)); } break; - case 37: + case 39: /* Line 1806 of yacc.c */ -#line 287 "config_parser.yy" +#line 300 "config_parser.yy" { (yyval.type) = (yyvsp[(1) - (1)].type); } break; - case 38: + case 40: /* Line 1806 of yacc.c */ -#line 293 "config_parser.yy" +#line 306 "config_parser.yy" { m_Abstract = false; m_Local = false; } break; - case 39: + case 41: /* Line 1806 of yacc.c */ -#line 298 "config_parser.yy" +#line 311 "config_parser.yy" { ConfigItemBuilder::Ptr item = boost::make_shared(yylloc); @@ -1915,46 +1953,46 @@ yyreduce: } break; - case 41: + case 43: /* Line 1806 of yacc.c */ -#line 340 "config_parser.yy" +#line 353 "config_parser.yy" { m_Abstract = true; } break; - case 44: + case 46: /* Line 1806 of yacc.c */ -#line 349 "config_parser.yy" +#line 362 "config_parser.yy" { m_Abstract = true; } break; - case 45: + case 47: /* Line 1806 of yacc.c */ -#line 353 "config_parser.yy" +#line 366 "config_parser.yy" { m_Local = true; } break; - case 46: + case 48: /* Line 1806 of yacc.c */ -#line 359 "config_parser.yy" +#line 372 "config_parser.yy" { (yyval.slist) = NULL; } break; - case 47: + case 49: /* Line 1806 of yacc.c */ -#line 363 "config_parser.yy" +#line 376 "config_parser.yy" { (yyval.slist) = new std::vector(); (yyval.slist)->push_back((yyvsp[(1) - (1)].text)); @@ -1962,10 +2000,10 @@ yyreduce: } break; - case 48: + case 50: /* Line 1806 of yacc.c */ -#line 369 "config_parser.yy" +#line 382 "config_parser.yy" { if ((yyvsp[(1) - (3)].slist)) (yyval.slist) = (yyvsp[(1) - (3)].slist); @@ -1977,64 +2015,64 @@ yyreduce: } break; - case 49: + case 51: /* Line 1806 of yacc.c */ -#line 381 "config_parser.yy" +#line 394 "config_parser.yy" { (yyval.slist) = NULL; } break; - case 50: + case 52: /* Line 1806 of yacc.c */ -#line 385 "config_parser.yy" +#line 398 "config_parser.yy" { (yyval.slist) = (yyvsp[(2) - (2)].slist); } break; - case 51: + case 53: /* Line 1806 of yacc.c */ -#line 391 "config_parser.yy" +#line 404 "config_parser.yy" { (yyval.exprl) = (yyvsp[(2) - (3)].exprl); } break; - case 52: + case 54: /* Line 1806 of yacc.c */ -#line 397 "config_parser.yy" +#line 410 "config_parser.yy" { (yyval.exprl) = (yyvsp[(1) - (1)].exprl); } break; - case 53: + case 55: /* Line 1806 of yacc.c */ -#line 401 "config_parser.yy" +#line 414 "config_parser.yy" { (yyval.exprl) = (yyvsp[(1) - (2)].exprl); } break; - case 54: + case 56: /* Line 1806 of yacc.c */ -#line 406 "config_parser.yy" +#line 419 "config_parser.yy" { (yyval.exprl) = NULL; } break; - case 55: + case 57: /* Line 1806 of yacc.c */ -#line 410 "config_parser.yy" +#line 423 "config_parser.yy" { (yyval.exprl) = new ExpressionList(); (yyval.exprl)->AddExpression(*(yyvsp[(1) - (1)].expr)); @@ -2042,10 +2080,10 @@ yyreduce: } break; - case 56: + case 58: /* Line 1806 of yacc.c */ -#line 416 "config_parser.yy" +#line 429 "config_parser.yy" { if ((yyvsp[(1) - (3)].exprl)) (yyval.exprl) = (yyvsp[(1) - (3)].exprl); @@ -2057,10 +2095,10 @@ yyreduce: } break; - case 57: + case 59: /* Line 1806 of yacc.c */ -#line 428 "config_parser.yy" +#line 441 "config_parser.yy" { (yyval.expr) = new Expression((yyvsp[(1) - (3)].text), (yyvsp[(2) - (3)].op), *(yyvsp[(3) - (3)].variant), yylloc); free((yyvsp[(1) - (3)].text)); @@ -2068,10 +2106,10 @@ yyreduce: } break; - case 58: + case 60: /* Line 1806 of yacc.c */ -#line 434 "config_parser.yy" +#line 447 "config_parser.yy" { Expression subexpr((yyvsp[(3) - (6)].text), (yyvsp[(5) - (6)].op), *(yyvsp[(6) - (6)].variant), yylloc); free((yyvsp[(3) - (6)].text)); @@ -2085,55 +2123,55 @@ yyreduce: } break; - case 63: + case 65: /* Line 1806 of yacc.c */ -#line 452 "config_parser.yy" +#line 465 "config_parser.yy" { (yyval.op) = (yyvsp[(1) - (1)].op); } break; - case 64: + case 66: /* Line 1806 of yacc.c */ -#line 458 "config_parser.yy" +#line 471 "config_parser.yy" { (yyval.array) = (yyvsp[(2) - (3)].array); } break; - case 65: + case 67: /* Line 1806 of yacc.c */ -#line 464 "config_parser.yy" +#line 477 "config_parser.yy" { (yyval.array) = (yyvsp[(1) - (1)].array); } break; - case 66: + case 68: /* Line 1806 of yacc.c */ -#line 468 "config_parser.yy" +#line 481 "config_parser.yy" { (yyval.array) = (yyvsp[(1) - (2)].array); } break; - case 67: + case 69: /* Line 1806 of yacc.c */ -#line 473 "config_parser.yy" +#line 486 "config_parser.yy" { (yyval.array) = NULL; } break; - case 68: + case 70: /* Line 1806 of yacc.c */ -#line 477 "config_parser.yy" +#line 490 "config_parser.yy" { (yyval.array) = new Array(); @@ -2150,10 +2188,10 @@ yyreduce: } break; - case 69: + case 71: /* Line 1806 of yacc.c */ -#line 492 "config_parser.yy" +#line 505 "config_parser.yy" { if ((yyvsp[(1) - (3)].array)) (yyval.array) = (yyvsp[(1) - (3)].array); @@ -2173,38 +2211,38 @@ yyreduce: } break; - case 70: + case 72: /* Line 1806 of yacc.c */ -#line 512 "config_parser.yy" +#line 525 "config_parser.yy" { (yyval.variant) = new Value((yyvsp[(1) - (1)].text)); free((yyvsp[(1) - (1)].text)); } break; - case 71: + case 73: /* Line 1806 of yacc.c */ -#line 517 "config_parser.yy" +#line 530 "config_parser.yy" { (yyval.variant) = new Value((yyvsp[(1) - (1)].num)); } break; - case 72: + case 74: /* Line 1806 of yacc.c */ -#line 521 "config_parser.yy" +#line 534 "config_parser.yy" { (yyval.variant) = new Value(); } break; - case 73: + case 75: /* Line 1806 of yacc.c */ -#line 525 "config_parser.yy" +#line 538 "config_parser.yy" { if ((yyvsp[(1) - (1)].array) == NULL) (yyvsp[(1) - (1)].array) = new Array(); @@ -2214,20 +2252,120 @@ yyreduce: } break; - case 75: + case 76: + +/* Line 1806 of yacc.c */ +#line 548 "config_parser.yy" + { + (yyval.num) = (yyvsp[(2) - (3)].num); + } + break; + + case 77: + +/* Line 1806 of yacc.c */ +#line 553 "config_parser.yy" + { + (yyval.num) = (yyvsp[(1) - (1)].num); + } + break; + + case 78: + +/* Line 1806 of yacc.c */ +#line 557 "config_parser.yy" + { + (yyval.num) = ScriptVariable::Get((yyvsp[(1) - (1)].text)); + free((yyvsp[(1) - (1)].text)); + } + break; + + case 79: /* Line 1806 of yacc.c */ -#line 536 "config_parser.yy" +#line 562 "config_parser.yy" + { + (yyval.num) = (yyvsp[(1) - (3)].num) + (yyvsp[(3) - (3)].num); + } + break; + + case 80: + +/* Line 1806 of yacc.c */ +#line 566 "config_parser.yy" + { + (yyval.num) = (yyvsp[(1) - (3)].num) - (yyvsp[(3) - (3)].num); + } + break; + + case 81: + +/* Line 1806 of yacc.c */ +#line 570 "config_parser.yy" + { + (yyval.num) = (yyvsp[(1) - (3)].num) * (yyvsp[(3) - (3)].num); + } + break; + + case 82: + +/* Line 1806 of yacc.c */ +#line 574 "config_parser.yy" + { + (yyval.num) = (yyvsp[(1) - (3)].num) / (yyvsp[(3) - (3)].num); + } + break; + + case 83: + +/* Line 1806 of yacc.c */ +#line 578 "config_parser.yy" + { + (yyval.num) = (long)(yyvsp[(1) - (3)].num) & (long)(yyvsp[(3) - (3)].num); + } + break; + + case 84: + +/* Line 1806 of yacc.c */ +#line 582 "config_parser.yy" + { + (yyval.num) = (long)(yyvsp[(1) - (3)].num) | (long)(yyvsp[(3) - (3)].num); + } + break; + + case 85: + +/* Line 1806 of yacc.c */ +#line 586 "config_parser.yy" + { + (yyval.num) = (yyvsp[(2) - (3)].num); + } + break; + + case 87: + +/* Line 1806 of yacc.c */ +#line 593 "config_parser.yy" { ExpressionList::Ptr exprl = ExpressionList::Ptr((yyvsp[(1) - (1)].exprl)); (yyval.variant) = new Value(exprl); } break; + case 88: + +/* Line 1806 of yacc.c */ +#line 598 "config_parser.yy" + { + (yyval.variant) = new Value((yyvsp[(1) - (1)].num)); + } + break; + /* Line 1806 of yacc.c */ -#line 2231 "../../../lib/config/config_parser.cc" +#line 2369 "../../../lib/config/config_parser.cc" default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -2465,6 +2603,6 @@ yyreturn: /* Line 2067 of yacc.c */ -#line 541 "config_parser.yy" +#line 602 "config_parser.yy" diff --git a/lib/config/config_parser.h b/lib/config/config_parser.h index 15bd6300c..1f9174eb9 100644 --- a/lib/config/config_parser.h +++ b/lib/config/config_parser.h @@ -65,6 +65,7 @@ #include "base/value.h" #include "base/utility.h" #include "base/array.h" +#include "base/scriptvariable.h" #include #include #include @@ -79,7 +80,7 @@ using namespace icinga; /* Line 2068 of yacc.c */ -#line 83 "../../../lib/config/config_parser.h" +#line 84 "../../../lib/config/config_parser.h" /* Tokens. */ #ifndef YYTOKENTYPE @@ -97,25 +98,26 @@ using namespace icinga; T_MINUS_EQUAL = 265, T_MULTIPLY_EQUAL = 266, T_DIVIDE_EQUAL = 267, - T_TYPE_DICTIONARY = 268, - T_TYPE_ARRAY = 269, - T_TYPE_NUMBER = 270, - T_TYPE_STRING = 271, - T_TYPE_SCALAR = 272, - T_TYPE_ANY = 273, - T_TYPE_NAME = 274, - T_VALIDATOR = 275, - T_REQUIRE = 276, - T_ATTRIBUTE = 277, - T_TYPE = 278, - T_ABSTRACT = 279, - T_LOCAL = 280, - T_OBJECT = 281, - T_TEMPLATE = 282, - T_INCLUDE = 283, - T_LIBRARY = 284, - T_INHERITS = 285, - T_PARTIAL = 286 + T_SET = 268, + T_TYPE_DICTIONARY = 269, + T_TYPE_ARRAY = 270, + T_TYPE_NUMBER = 271, + T_TYPE_STRING = 272, + T_TYPE_SCALAR = 273, + T_TYPE_ANY = 274, + T_TYPE_NAME = 275, + T_VALIDATOR = 276, + T_REQUIRE = 277, + T_ATTRIBUTE = 278, + T_TYPE = 279, + T_ABSTRACT = 280, + T_LOCAL = 281, + T_OBJECT = 282, + T_TEMPLATE = 283, + T_INCLUDE = 284, + T_LIBRARY = 285, + T_INHERITS = 286, + T_PARTIAL = 287 }; #endif /* Tokens. */ @@ -129,25 +131,26 @@ using namespace icinga; #define T_MINUS_EQUAL 265 #define T_MULTIPLY_EQUAL 266 #define T_DIVIDE_EQUAL 267 -#define T_TYPE_DICTIONARY 268 -#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_TYPE_NAME 274 -#define T_VALIDATOR 275 -#define T_REQUIRE 276 -#define T_ATTRIBUTE 277 -#define T_TYPE 278 -#define T_ABSTRACT 279 -#define T_LOCAL 280 -#define T_OBJECT 281 -#define T_TEMPLATE 282 -#define T_INCLUDE 283 -#define T_LIBRARY 284 -#define T_INHERITS 285 -#define T_PARTIAL 286 +#define T_SET 268 +#define T_TYPE_DICTIONARY 269 +#define T_TYPE_ARRAY 270 +#define T_TYPE_NUMBER 271 +#define T_TYPE_STRING 272 +#define T_TYPE_SCALAR 273 +#define T_TYPE_ANY 274 +#define T_TYPE_NAME 275 +#define T_VALIDATOR 276 +#define T_REQUIRE 277 +#define T_ATTRIBUTE 278 +#define T_TYPE 279 +#define T_ABSTRACT 280 +#define T_LOCAL 281 +#define T_OBJECT 282 +#define T_TEMPLATE 283 +#define T_INCLUDE 284 +#define T_LIBRARY 285 +#define T_INHERITS 286 +#define T_PARTIAL 287 @@ -157,7 +160,7 @@ typedef union YYSTYPE { /* Line 2068 of yacc.c */ -#line 53 "config_parser.yy" +#line 54 "config_parser.yy" char *text; double num; @@ -172,7 +175,7 @@ typedef union YYSTYPE /* Line 2068 of yacc.c */ -#line 176 "../../../lib/config/config_parser.h" +#line 179 "../../../lib/config/config_parser.h" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ diff --git a/lib/config/config_parser.yy b/lib/config/config_parser.yy index 201460d03..283f69533 100644 --- a/lib/config/config_parser.yy +++ b/lib/config/config_parser.yy @@ -29,6 +29,7 @@ #include "base/value.h" #include "base/utility.h" #include "base/array.h" +#include "base/scriptvariable.h" #include #include #include @@ -72,6 +73,7 @@ using namespace icinga; %token T_MINUS_EQUAL "-= (T_MINUS_EQUAL)" %token T_MULTIPLY_EQUAL "*= (T_MULTIPLY_EQUAL)" %token T_DIVIDE_EQUAL "/= (T_DIVIDE_EQUAL)" +%token T_SET "set (T_SET)" %token T_TYPE_DICTIONARY "dictionary (T_TYPE_DICTIONARY)" %token T_TYPE_ARRAY "array (T_TYPE_ARRAY)" %token T_TYPE_NUMBER "number (T_TYPE_NUMBER)" @@ -107,8 +109,12 @@ using namespace icinga; %type partial_specifier %type object_inherits_list %type object_inherits_specifier +%type constterm +%type constexpression %left '+' '-' %left '*' '/' +%left '&' +%left '|' %{ int yylex(YYSTYPE *lvalp, YYLTYPE *llocp, void *scanner); @@ -149,7 +155,7 @@ statements: /* empty */ | statements statement ; -statement: object | type | include | library +statement: object | type | include | library | variable ; include: T_INCLUDE T_STRING @@ -169,6 +175,13 @@ library: T_LIBRARY T_STRING free($2); } +variable: T_SET identifier T_EQUAL value + { + ScriptVariable::Set($2, *$4); + free($2); + delete $4; + } + identifier: T_IDENTIFIER | T_STRING { @@ -531,11 +544,59 @@ simplevalue: T_STRING } ; +constterm: '(' constexpression ')' + { + $$ = $2; + } + +constexpression: T_NUMBER + { + $$ = $1; + } + | identifier + { + $$ = ScriptVariable::Get($1); + free($1); + } + | constexpression '+' constexpression + { + $$ = $1 + $3; + } + | constexpression '-' constexpression + { + $$ = $1 - $3; + } + | constexpression '*' constexpression + { + $$ = $1 * $3; + } + | constexpression '/' constexpression + { + $$ = $1 / $3; + } + | constexpression '&' constexpression + { + $$ = (long)$1 & (long)$3; + } + | constexpression '|' constexpression + { + $$ = (long)$1 | (long)$3; + } + | '(' constexpression ')' + { + $$ = $2; + } + ; + value: simplevalue | expressionlist { ExpressionList::Ptr exprl = ExpressionList::Ptr($1); $$ = new Value(exprl); } + | constterm + { + $$ = new Value($1); + } ; %% -- 2.40.0