]> granicus.if.org Git - icinga2/commitdiff
Config compiler: Added support for floating point numbers as well as negative numbers.
authorGunnar Beutner <gunnar.beutner@netways.de>
Wed, 11 Jul 2012 19:03:22 +0000 (21:03 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Wed, 11 Jul 2012 19:03:22 +0000 (21:03 +0200)
dyn/config_lexer.cc
dyn/config_lexer.ll
dyn/config_parser.cc
dyn/config_parser.h
dyn/config_parser.yy

index b13d4230d70c43408e65547e50a7c2da58451b0d..ea13ff2d41f019fcb5f600845c82c311f959ee79 100644 (file)
@@ -379,15 +379,16 @@ struct yy_trans_info
        flex_int32_t yy_verify;
        flex_int32_t yy_nxt;
        };
-static yyconst flex_int16_t yy_accept[70] =
+static yyconst flex_int16_t yy_accept[72] =
     {   0,
         0,    0,    0,    0,   23,   21,   20,   20,   21,   21,
        21,   21,   21,    9,   10,    7,    7,    7,    7,    7,
-        7,   17,   18,   20,    0,    8,   13,   11,   12,   15,
-        0,   14,    9,    7,    7,    7,    7,    7,    7,   17,
-       16,   19,    7,    7,    7,    7,    7,    7,    7,    7,
-        7,    7,    6,    7,    7,    7,    7,    2,    7,    7,
-        7,    7,    3,    7,    4,    7,    1,    5,    0
+        7,   17,   18,   20,    0,    8,   13,   11,    9,   12,
+       15,    0,   14,    0,    7,    7,    7,    7,    7,    7,
+       17,   16,   19,    9,    7,    7,    7,    7,    7,    7,
+        7,    7,    7,    7,    6,    7,    7,    7,    7,    2,
+        7,    7,    7,    7,    3,    7,    4,    7,    1,    5,
+        0
     } ;
 
 static yyconst flex_int32_t yy_ec[256] =
@@ -396,16 +397,16 @@ static yyconst flex_int32_t yy_ec[256] =
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    2,    1,    4,    1,    1,    1,    1,    1,    1,
-        1,    5,    6,    1,    7,    1,    8,    9,    9,    9,
-        9,    9,    9,    9,    9,    9,    9,    1,    1,    1,
-       10,    1,    1,    1,   11,   11,   11,   11,   11,   11,
-       11,   11,   11,   11,   11,   11,   11,   11,   11,   11,
-       11,   11,   11,   11,   11,   11,   11,   11,   11,   11,
-        1,    1,    1,    1,   11,    1,   12,   13,   14,   15,
-
-       16,   11,   11,   17,   18,   19,   11,   20,   11,   21,
-       22,   11,   11,   23,   24,   25,   26,   11,   11,   11,
-       11,   11,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    5,    6,    1,    7,    8,    9,   10,   10,   10,
+       10,   10,   10,   10,   10,   10,   10,    1,    1,    1,
+       11,    1,    1,    1,   12,   12,   12,   12,   12,   12,
+       12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
+       12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
+        1,    1,    1,    1,   12,    1,   13,   14,   15,   16,
+
+       17,   12,   12,   18,   19,   20,   12,   21,   12,   22,
+       23,   12,   12,   24,   25,   26,   27,   12,   12,   12,
+       12,   12,    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,
@@ -422,69 +423,71 @@ static yyconst flex_int32_t yy_ec[256] =
         1,    1,    1,    1,    1
     } ;
 
-static yyconst flex_int32_t yy_meta[27] =
+static yyconst flex_int32_t yy_meta[28] =
     {   0,
-        1,    1,    2,    1,    3,    1,    4,    1,    4,    1,
-        4,    4,    4,    4,    4,    4,    4,    4,    4,    4,
-        4,    4,    4,    4,    4,    4
+        1,    1,    2,    1,    3,    1,    4,    1,    1,    4,
+        1,    4,    4,    4,    4,    4,    4,    4,    4,    4,
+        4,    4,    4,    4,    4,    4,    4
     } ;
 
-static yyconst flex_int16_t yy_base[75] =
+static yyconst flex_int16_t yy_base[77] =
     {   0,
-        0,    0,   87,   86,   90,   93,   25,   27,   85,   78,
-       77,   76,   26,   76,   93,    0,   71,   62,   60,   55,
-       67,    0,   71,   30,   74,   93,   93,   93,   93,   93,
-        0,   93,   68,    0,   52,   21,   61,   54,   54,    0,
-       93,    0,   47,   51,   54,   57,   48,   51,   43,   39,
-       41,   43,    0,   48,   49,   45,   41,    0,   33,   43,
-       40,   30,    0,   27,    0,   25,    0,    0,   93,   38,
-       42,   33,   46,   50
+        0,    0,   93,   92,   96,   99,   26,   28,   91,   83,
+       82,   22,   29,   27,   99,    0,   78,   69,   67,   62,
+       74,    0,   78,   39,   82,   99,   99,   99,   35,   99,
+       99,    0,   99,   75,    0,   59,   21,   68,   61,   61,
+        0,   99,    0,   70,   53,   57,   60,   63,   54,   57,
+       49,   45,   47,   49,    0,   54,   55,   51,   47,    0,
+       39,   49,   46,   36,    0,   33,    0,   31,    0,    0,
+       99,   45,   49,   40,   53,   57
     } ;
 
-static yyconst flex_int16_t yy_def[75] =
+static yyconst flex_int16_t yy_def[77] =
     {   0,
-       69,    1,   70,   70,   69,   69,   69,   69,   71,   69,
-       69,   69,   69,   69,   69,   72,   72,   72,   72,   72,
-       72,   73,   69,   69,   71,   69,   69,   69,   69,   69,
-       74,   69,   69,   72,   72,   72,   72,   72,   72,   73,
-       69,   74,   72,   72,   72,   72,   72,   72,   72,   72,
-       72,   72,   72,   72,   72,   72,   72,   72,   72,   72,
-       72,   72,   72,   72,   72,   72,   72,   72,    0,   69,
-       69,   69,   69,   69
+       71,    1,   72,   72,   71,   71,   71,   71,   73,   71,
+       71,   71,   71,   71,   71,   74,   74,   74,   74,   74,
+       74,   75,   71,   71,   73,   71,   71,   71,   71,   71,
+       71,   76,   71,   71,   74,   74,   74,   74,   74,   74,
+       75,   71,   76,   71,   74,   74,   74,   74,   74,   74,
+       74,   74,   74,   74,   74,   74,   74,   74,   74,   74,
+       74,   74,   74,   74,   74,   74,   74,   74,   74,   74,
+        0,   71,   71,   71,   71,   71
     } ;
 
-static yyconst flex_int16_t yy_nxt[120] =
+static yyconst flex_int16_t yy_nxt[127] =
     {   0,
-        6,    7,    8,    9,   10,   11,   12,   13,   14,   15,
-       16,   17,   16,   16,   16,   16,   16,   18,   16,   19,
-       20,   21,   16,   16,   16,   16,   24,   24,   24,   24,
-       30,   24,   24,   31,   44,   32,   34,   45,   22,   22,
-       22,   22,   25,   25,   25,   25,   40,   40,   68,   40,
-       42,   67,   42,   42,   66,   65,   64,   63,   62,   61,
-       60,   59,   58,   57,   56,   55,   54,   53,   52,   51,
-       50,   49,   48,   47,   46,   43,   33,   26,   41,   39,
-       38,   37,   36,   35,   33,   29,   28,   27,   26,   69,
-       23,   23,    5,   69,   69,   69,   69,   69,   69,   69,
-
-       69,   69,   69,   69,   69,   69,   69,   69,   69,   69,
-       69,   69,   69,   69,   69,   69,   69,   69,   69
+        6,    7,    8,    9,   10,   11,   12,    6,   13,   14,
+       15,   16,   17,   16,   16,   16,   16,   16,   18,   16,
+       19,   20,   21,   16,   16,   16,   16,   24,   24,   24,
+       24,   29,   30,   31,   34,   46,   29,   32,   47,   33,
+       24,   24,   34,   35,   29,   22,   22,   22,   22,   25,
+       25,   25,   25,   41,   41,   70,   41,   43,   69,   43,
+       43,   68,   67,   66,   65,   64,   63,   62,   61,   60,
+       59,   58,   57,   56,   55,   54,   53,   52,   51,   44,
+       50,   49,   48,   45,   44,   26,   42,   40,   39,   38,
+       37,   36,   28,   27,   26,   71,   23,   23,    5,   71,
+
+       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
+       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
+       71,   71,   71,   71,   71,   71
     } ;
 
-static yyconst flex_int16_t yy_chk[120] =
+static yyconst flex_int16_t yy_chk[127] =
     {   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,    7,    7,    8,    8,
-       13,   24,   24,   13,   36,   13,   72,   36,   70,   70,
-       70,   70,   71,   71,   71,   71,   73,   73,   66,   73,
-       74,   64,   74,   74,   62,   61,   60,   59,   57,   56,
-       55,   54,   52,   51,   50,   49,   48,   47,   46,   45,
-       44,   43,   39,   38,   37,   35,   33,   25,   23,   21,
-       20,   19,   18,   17,   14,   12,   11,   10,    9,    5,
-        4,    3,   69,   69,   69,   69,   69,   69,   69,   69,
-
-       69,   69,   69,   69,   69,   69,   69,   69,   69,   69,
-       69,   69,   69,   69,   69,   69,   69,   69,   69
+        1,    1,    1,    1,    1,    1,    1,    7,    7,    8,
+        8,   12,   12,   13,   14,   37,   14,   13,   37,   13,
+       24,   24,   29,   74,   29,   72,   72,   72,   72,   73,
+       73,   73,   73,   75,   75,   68,   75,   76,   66,   76,
+       76,   64,   63,   62,   61,   59,   58,   57,   56,   54,
+       53,   52,   51,   50,   49,   48,   47,   46,   45,   44,
+       40,   39,   38,   36,   34,   25,   23,   21,   20,   19,
+       18,   17,   11,   10,    9,    5,    4,    3,   71,   71,
+
+       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
+       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
+       71,   71,   71,   71,   71,   71
     } ;
 
 /* Table of booleans, true if rule could match eol. */
@@ -543,7 +546,7 @@ do {                                                        \
 } while (0)
 #define YY_NO_UNISTD_H 1
 
-#line 547 "config_lexer.cc"
+#line 550 "config_lexer.cc"
 
 #define INITIAL 0
 #define IN_C_COMMENT 1
@@ -792,7 +795,7 @@ YY_DECL
 
 #line 49 "config_lexer.ll"
 
-#line 796 "config_lexer.cc"
+#line 799 "config_lexer.cc"
 
     yylval = yylval_param;
 
@@ -849,13 +852,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 >= 70 )
+                               if ( yy_current_state >= 72 )
                                        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 != 69 );
+               while ( yy_current_state != 71 );
                yy_cp = yyg->yy_last_accepting_cpos;
                yy_current_state = yyg->yy_last_accepting_state;
 
@@ -931,7 +934,7 @@ YY_RULE_SETUP
 case 9:
 YY_RULE_SETUP
 #line 58 "config_lexer.ll"
-{ yylval->num = atoi(yytext); return T_NUMBER; }
+{ yylval->num = strtod(yytext, NULL); return T_NUMBER; }
        YY_BREAK
 case 10:
 YY_RULE_SETUP
@@ -1004,7 +1007,7 @@ YY_RULE_SETUP
 #line 79 "config_lexer.ll"
 ECHO;
        YY_BREAK
-#line 1008 "config_lexer.cc"
+#line 1011 "config_lexer.cc"
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(IN_C_COMMENT):
        yyterminate();
@@ -1300,7 +1303,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 >= 70 )
+                       if ( yy_current_state >= 72 )
                                yy_c = yy_meta[(unsigned int) yy_c];
                        }
                yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1329,11 +1332,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 >= 70 )
+               if ( yy_current_state >= 72 )
                        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 == 69);
+       yy_is_jam = (yy_current_state == 71);
 
        return yy_is_jam ? 0 : yy_current_state;
 }
index 9b46d0e195a3a93bf756c72bd766f44b9e539adc..70ff7b27e409ecfc4b614102094dd51d3e34664d 100644 (file)
@@ -55,7 +55,7 @@ inherits                      return T_INHERITS;
 null                           return T_NULL;
 [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; }
-[0-9]+                         { yylval->num = atoi(yytext); return T_NUMBER; }
+-?[0-9]+(\.[0-9]+)?            { yylval->num = strtod(yytext, NULL); return T_NUMBER; }
 =                              { yylval->op = OperatorSet; return T_EQUAL; }
 \+=                            { yylval->op = OperatorPlus; return T_PLUS_EQUAL; }
 -=                             { yylval->op = OperatorMinus; return T_MINUS_EQUAL; }
index 4676d4203d61a8b0ee5b8b79765ad6265474de40..6f68557508245162563314ab3d7da5c8196d7c6b 100644 (file)
@@ -172,7 +172,7 @@ typedef union YYSTYPE
 #line 38 "config_parser.yy"
 
        char *text;
-       int num;
+       double num;
        icinga::Variant *variant;
        icinga::ExpressionOperator op;
 
index 3eb48bf15bdb7b05e304e24402a24553723da27b..4c8ee940261568fce2ad2fe4839a38eb975d26e1 100644 (file)
@@ -115,7 +115,7 @@ typedef union YYSTYPE
 #line 38 "config_parser.yy"
 
        char *text;
-       int num;
+       double num;
        icinga::Variant *variant;
        icinga::ExpressionOperator op;
 
index 98f2817f2c31cf0a48889195e5956d14f5ea7996..9255237a52bba27e5449a11c2e7ecb1ba6ce34a0 100644 (file)
@@ -37,7 +37,7 @@ using namespace icinga;
 
 %union {
        char *text;
-       int num;
+       double num;
        icinga::Variant *variant;
        icinga::ExpressionOperator op;
 }