From 5d2df98840a78e28118f0bd435ff2e3905269617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20S=2E=20Montero?= Date: Sat, 7 Mar 2009 00:54:49 +0000 Subject: [PATCH] Improved template & variable parsers. Now variables can only have alpha-numeric characters and numbers. Values can be numbers or strings. git-svn-id: http://svn.opennebula.org/one/trunk@391 3034c82b-c49b-4eb3-8279-a7acafdc01c0 --- src/template/template_parser.c | 143 +++++++++++++++------------ src/template/template_parser.h | 2 +- src/template/template_parser.l | 24 ++--- src/template/template_syntax.cc | 111 ++++++++++----------- src/template/template_syntax.h | 6 +- src/template/template_syntax.y | 53 +++++----- src/vm/vm_var_parser.c | 166 ++++++++++++++++---------------- src/vm/vm_var_parser.h | 2 +- src/vm/vm_var_parser.l | 23 +++-- src/vm/vm_var_syntax.cc | 123 ++++++++++++----------- src/vm/vm_var_syntax.h | 19 ++-- src/vm/vm_var_syntax.y | 30 ++++-- src/vmm_mad/kvm/vmm_kvm.conf | 2 +- 13 files changed, 379 insertions(+), 325 deletions(-) diff --git a/src/template/template_parser.c b/src/template/template_parser.c index 56db87201e..0355185031 100644 --- a/src/template/template_parser.c +++ b/src/template/template_parser.c @@ -393,8 +393,8 @@ static void yy_fatal_error (yyconst char msg[] ); *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; -#define YY_NUM_RULES 12 -#define YY_END_OF_BUFFER 13 +#define YY_NUM_RULES 13 +#define YY_END_OF_BUFFER 14 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -402,12 +402,13 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[39] = +static yyconst flex_int16_t yy_accept[47] = { 0, - 3, 2, 13, 11, 3, 8, 11, 1, 11, 5, - 4, 6, 7, 2, 11, 3, 0, 3, 5, 4, - 6, 7, 11, 0, 9, 1, 11, 0, 10, 5, - 4, 6, 7, 2, 3, 9, 10, 0 + 3, 2, 14, 13, 3, 8, 13, 1, 13, 5, + 13, 11, 4, 12, 6, 7, 2, 3, 0, 3, + 5, 4, 6, 7, 0, 1, 0, 5, 11, 0, + 11, 12, 4, 12, 6, 7, 2, 3, 9, 10, + 11, 11, 11, 11, 11, 0 } ; static yyconst flex_int32_t yy_ec[256] = @@ -416,16 +417,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, 5, 1, 1, 1, 6, 1, - 1, 1, 1, 7, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 8, 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, - 9, 1, 10, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 7, 8, 1, 1, 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, + 12, 1, 13, 1, 11, 1, 11, 11, 11, 11, - 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, + 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, 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, @@ -442,57 +443,66 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[11] = +static yyconst flex_int32_t yy_meta[14] = { 0, - 1, 2, 3, 1, 4, 1, 4, 4, 4, 4 + 1, 2, 3, 4, 1, 5, 1, 1, 6, 1, + 6, 1, 1 } ; -static yyconst flex_int16_t yy_base[46] = +static yyconst flex_int16_t yy_base[55] = { 0, - 0, 38, 38, 0, 9, 18, 23, 0, 29, 0, - 35, 0, 32, 30, 0, 0, 0, 0, 0, 29, - 0, 26, 35, 22, 0, 0, 41, 19, 0, 0, - 20, 0, 19, 13, 0, 68, 68, 68, 12, 47, - 51, 55, 58, 60, 63 + 0, 75, 76, 78, 12, 24, 0, 0, 0, 0, + 66, 21, 72, 0, 0, 71, 67, 0, 0, 0, + 0, 59, 0, 53, 43, 0, 36, 0, 28, 25, + 24, 22, 26, 0, 0, 25, 21, 0, 78, 78, + 12, 11, 27, 0, 9, 78, 38, 44, 50, 55, + 58, 10, 63, 66 } ; -static yyconst flex_int16_t yy_def[46] = +static yyconst flex_int16_t yy_def[55] = { 0, - 38, 1, 38, 39, 38, 5, 40, 41, 42, 43, - 38, 44, 38, 5, 39, 5, 6, 45, 43, 38, - 44, 38, 40, 40, 39, 41, 42, 42, 39, 43, - 38, 44, 38, 5, 45, 38, 38, 0, 38, 38, - 38, 38, 38, 38, 38 + 46, 1, 46, 46, 46, 5, 47, 48, 49, 50, + 46, 51, 46, 52, 53, 46, 5, 5, 6, 54, + 50, 46, 53, 46, 47, 48, 49, 50, 51, 46, + 51, 52, 46, 52, 53, 46, 5, 54, 46, 46, + 51, 46, 51, 32, 51, 0, 46, 46, 46, 46, + 46, 46, 46, 46 } ; -static yyconst flex_int16_t yy_nxt[79] = +static yyconst flex_int16_t yy_nxt[92] = { 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 16, 17, 15, 18, 34, 19, 20, 21, 22, 17, - 33, 31, 38, 23, 37, 36, 25, 33, 23, 27, - 31, 34, 27, 33, 29, 23, 31, 38, 25, 14, - 23, 27, 38, 38, 27, 38, 29, 24, 24, 24, - 24, 26, 26, 38, 26, 28, 28, 28, 28, 30, - 30, 32, 32, 35, 35, 38, 35, 3, 38, 38, - 38, 38, 38, 38, 38, 38, 38, 38 + 14, 15, 16, 18, 19, 34, 20, 45, 21, 42, + 45, 22, 37, 23, 24, 19, 36, 33, 46, 31, + 44, 32, 43, 42, 32, 43, 41, 32, 25, 25, + 25, 40, 25, 25, 26, 26, 39, 26, 26, 26, + 27, 27, 27, 27, 36, 27, 28, 28, 30, 30, + 33, 30, 30, 30, 35, 35, 38, 38, 37, 38, + 38, 38, 36, 33, 29, 46, 17, 3, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46 + } ; -static yyconst flex_int16_t yy_chk[79] = +static yyconst flex_int16_t yy_chk[92] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 5, 5, 39, 5, 34, 5, 5, 5, 5, 6, - 33, 31, 6, 7, 28, 24, 7, 22, 7, 9, - 20, 14, 9, 13, 9, 23, 11, 3, 23, 2, - 23, 27, 0, 0, 27, 0, 27, 40, 40, 40, - 40, 41, 41, 0, 41, 42, 42, 42, 42, 43, - 43, 44, 44, 45, 45, 0, 45, 38, 38, 38, - 38, 38, 38, 38, 38, 38, 38, 38 + 1, 1, 1, 5, 5, 52, 5, 45, 5, 42, + 41, 5, 37, 5, 5, 6, 36, 33, 6, 12, + 32, 12, 31, 30, 31, 43, 29, 43, 47, 47, + 47, 27, 47, 47, 48, 48, 25, 48, 48, 48, + 49, 49, 49, 49, 24, 49, 50, 50, 51, 51, + 22, 51, 51, 51, 53, 53, 54, 54, 17, 54, + 54, 54, 16, 13, 11, 3, 2, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46 + } ; /* Table of booleans, true if rule could match eol. */ -static yyconst flex_int32_t yy_rule_can_match_eol[13] = +static yyconst flex_int32_t yy_rule_can_match_eol[14] = { 0, -0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, }; +0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, }; static yy_state_type yy_last_accepting_state; static char *yy_last_accepting_cpos; @@ -538,7 +548,7 @@ char *template_text; #define YY_USER_ACTION llocp->first_line = template_lineno; \ llocp->first_column = llocp->last_column; \ llocp->last_column += template_leng; -#line 542 "template_parser.c" +#line 552 "template_parser.c" #define INITIAL 0 @@ -725,7 +735,7 @@ YY_DECL /* --- Comments and blanks --- */ -#line 729 "template_parser.c" +#line 739 "template_parser.c" if ( !(yy_init) ) { @@ -779,13 +789,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 >= 39 ) + if ( yy_current_state >= 47 ) 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_base[yy_current_state] != 68 ); + while ( yy_base[yy_current_state] != 78 ); yy_find_action: yy_act = yy_accept[yy_current_state]; @@ -839,33 +849,33 @@ case 4: /* rule 4 can match eol */ YY_RULE_SETUP #line 48 "template_parser.l" -{return EQUAL;} +{ return EQUAL;} YY_BREAK case 5: /* rule 5 can match eol */ YY_RULE_SETUP #line 49 "template_parser.l" -{return COMMA;} +{ return COMMA;} YY_BREAK case 6: /* rule 6 can match eol */ YY_RULE_SETUP #line 50 "template_parser.l" -{return OBRACKET;} +{ return OBRACKET;} YY_BREAK case 7: /* rule 7 can match eol */ YY_RULE_SETUP #line 51 "template_parser.l" -{return CBRACKET;} +{ return CBRACKET;} YY_BREAK case 8: /* rule 8 can match eol */ YY_RULE_SETUP #line 52 "template_parser.l" -{return NL;} +{ return NL;} YY_BREAK -/* --- Strings, anything but =,][# Also quoted form --- */ +/* --- Strings in quoted form and variables alphanumeric - and _ --- */ case 9: /* rule 9 can match eol */ YY_RULE_SETUP @@ -890,9 +900,14 @@ YY_RULE_SETUP case 12: YY_RULE_SETUP #line 66 "template_parser.l" +{ lvalp->val_str = strdup(template_text); return VARIABLE;} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 68 "template_parser.l" ECHO; YY_BREAK -#line 896 "template_parser.c" +#line 911 "template_parser.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1185,7 +1200,7 @@ static int yy_get_next_buffer (void) 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 >= 39 ) + if ( yy_current_state >= 47 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1213,11 +1228,11 @@ static int yy_get_next_buffer (void) 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 >= 39 ) + if ( yy_current_state >= 47 ) 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 == 38); + yy_is_jam = (yy_current_state == 46); return yy_is_jam ? 0 : yy_current_state; } @@ -1863,12 +1878,12 @@ void template_free (void * ptr ) #define YYTABLES_NAME "yytables" -#line 66 "template_parser.l" +#line 68 "template_parser.l" int template_wrap() { return 1; -} +} diff --git a/src/template/template_parser.h b/src/template/template_parser.h index a5f239b88e..ed20a9ca4d 100644 --- a/src/template/template_parser.h +++ b/src/template/template_parser.h @@ -311,7 +311,7 @@ extern int template_lex (void); #undef YY_DECL #endif -#line 66 "template_parser.l" +#line 68 "template_parser.l" #line 318 "template_parser.h" diff --git a/src/template/template_parser.l b/src/template/template_parser.l index 95d34011dc..f2f54b48fe 100644 --- a/src/template/template_parser.l +++ b/src/template/template_parser.l @@ -45,27 +45,29 @@ /* --- Tokens --- */ -[[:blank:]\n]*=[[:blank:]]* {return EQUAL;} -[[:blank:]\n]*,[[:blank:]\n]* {return COMMA;} -[[:blank:]\n]*\[[[:blank:]\n]* {return OBRACKET;} -[[:blank:]\n]*\][[:blank:]]* {return CBRACKET;} -\n {return NL;} +[[:blank:]\n]*=[[:blank:]]* { return EQUAL;} +[[:blank:]\n]*,[[:blank:]\n]* { return COMMA;} +[[:blank:]\n]*\[[[:blank:]\n]* { return OBRACKET;} +[[:blank:]\n]*\][[:blank:]]* { return CBRACKET;} +\n { return NL;} - /* --- Strings, anything but =,][# Also quoted form --- */ + /* --- Strings in quoted form and variables alphanumeric - and _ --- */ -\"[^\"]*\" { lvalp->val_str = strdup(yytext+1); +\"[^\"]+\" { lvalp->val_str = strdup(yytext+1); lvalp->val_str[yyleng-2] = '\0'; return STRING; } -'[^']*' { lvalp->val_str = strdup(yytext+1); +'[^']+' { lvalp->val_str = strdup(yytext+1); lvalp->val_str[yyleng-2] = '\0'; return STRING; } - -[^=#[:blank:]\n,\[\]]* { lvalp->val_str = strdup(yytext); return STRING;} + +-?[0-9]+(.[0-9]+)? { lvalp->val_str = strdup(yytext); return STRING;} + +[[:alnum:]_]+ { lvalp->val_str = strdup(yytext); return VARIABLE;} %% int template_wrap() { return 1; -} +} diff --git a/src/template/template_syntax.cc b/src/template/template_syntax.cc index 81611f4ce7..fac299cb0e 100644 --- a/src/template/template_syntax.cc +++ b/src/template/template_syntax.cc @@ -79,7 +79,8 @@ OBRACKET = 260, CBRACKET = 261, NL = 262, - STRING = 263 + STRING = 263, + VARIABLE = 264 }; #endif /* Tokens. */ @@ -89,6 +90,7 @@ #define CBRACKET 261 #define NL 262 #define STRING 263 +#define VARIABLE 264 @@ -109,7 +111,7 @@ #define YYERROR_VERBOSE -extern "C" +extern "C" { void template_error( YYLTYPE * llocp, @@ -150,7 +152,7 @@ typedef union YYSTYPE void * val_attr; } /* Line 187 of yacc.c. */ -#line 154 "template_syntax.cc" +#line 156 "template_syntax.cc" YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 @@ -175,7 +177,7 @@ typedef struct YYLTYPE /* Line 216 of yacc.c. */ -#line 179 "template_syntax.cc" +#line 181 "template_syntax.cc" #ifdef short # undef short @@ -392,10 +394,10 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 6 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 20 +#define YYLAST 19 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 9 +#define YYNTOKENS 10 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 4 /* YYNRULES -- Number of rules. */ @@ -405,7 +407,7 @@ union yyalloc /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 263 +#define YYMAXUTOK 264 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -439,7 +441,7 @@ 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, 1, 2, 3, 4, - 5, 6, 7, 8 + 5, 6, 7, 8, 9 }; #if YYDEBUG @@ -453,16 +455,16 @@ static const yytype_uint8 yyprhs[] = /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { - 10, 0, -1, 11, -1, 10, 11, -1, 8, 3, - 8, 7, -1, 8, 3, 5, 12, 6, 7, -1, - 8, 3, 7, -1, 7, -1, 8, 3, 8, -1, - 12, 4, 8, 3, 8, -1 + 11, 0, -1, 12, -1, 11, 12, -1, 9, 3, + 8, 7, -1, 9, 3, 5, 13, 6, 7, -1, + 9, 3, 7, -1, 7, -1, 9, 3, 8, -1, + 13, 4, 9, 3, 8, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 70, 70, 71, 74, 87, 101, 113, 116, 132 + 0, 71, 71, 72, 75, 88, 102, 114, 117, 133 }; #endif @@ -472,7 +474,8 @@ static const yytype_uint8 yyrline[] = static const char *const yytname[] = { "$end", "error", "$undefined", "EQUAL", "COMMA", "OBRACKET", "CBRACKET", - "NL", "STRING", "$accept", "template", "attribute", "array_val", 0 + "NL", "STRING", "VARIABLE", "$accept", "template", "attribute", + "array_val", 0 }; #endif @@ -481,14 +484,14 @@ static const char *const yytname[] = token YYLEX-NUM. */ static const yytype_uint16 yytoknum[] = { - 0, 256, 257, 258, 259, 260, 261, 262, 263 + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 9, 10, 10, 11, 11, 11, 11, 12, 12 + 0, 10, 11, 11, 12, 12, 12, 12, 13, 13 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -515,18 +518,18 @@ static const yytype_int8 yydefgoto[] = /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -5 +#define YYPACT_NINF -8 static const yytype_int8 yypact[] = { - -2, -5, -1, 0, -5, -4, -5, -5, 2, -5, - 6, 9, 5, -5, 7, 8, 10, -5, 11, -5, - 12, -5 + -1, -8, 2, 0, -8, -4, -8, -8, -7, -8, + 4, 10, 6, -8, 7, 5, 9, -8, 14, -8, + 11, -8 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -5, -5, 15, -5 + -8, -8, 15, -8 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -536,24 +539,22 @@ static const yytype_int8 yypgoto[] = #define YYTABLE_NINF -1 static const yytype_uint8 yytable[] = { - 6, 8, 5, 9, 10, 1, 2, 1, 2, 15, - 11, 16, 14, 13, 20, 17, 18, 19, 7, 0, - 21 + 6, 8, 11, 9, 10, 5, 1, 1, 2, 2, + 15, 13, 16, 14, 18, 17, 19, 20, 7, 21 }; -static const yytype_int8 yycheck[] = +static const yytype_uint8 yycheck[] = { - 0, 5, 3, 7, 8, 7, 8, 7, 8, 4, - 8, 6, 3, 7, 3, 8, 8, 7, 3, -1, - 8 + 0, 5, 9, 7, 8, 3, 7, 7, 9, 9, + 4, 7, 6, 3, 9, 8, 7, 3, 3, 8 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 7, 8, 10, 11, 3, 0, 11, 5, 7, - 8, 8, 12, 7, 3, 4, 6, 8, 8, 7, + 0, 7, 9, 11, 12, 3, 0, 12, 5, 7, + 8, 9, 13, 7, 3, 4, 6, 8, 9, 7, 3, 8 }; @@ -1404,67 +1405,67 @@ yyreduce: switch (yyn) { case 4: -#line 75 "template_syntax.y" +#line 76 "template_syntax.y" { Attribute * pattr; string name((yyvsp[(1) - (4)].val_str)); string value((yyvsp[(3) - (4)].val_str)); - + pattr = new SingleAttribute(name,value); tmpl->set(pattr); - + free((yyvsp[(1) - (4)].val_str)); free((yyvsp[(3) - (4)].val_str)); ;} break; case 5: -#line 88 "template_syntax.y" +#line 89 "template_syntax.y" { Attribute * pattr; string name((yyvsp[(1) - (6)].val_str)); map * amap; - + amap = static_cast *>((yyvsp[(4) - (6)].val_attr)); pattr = new VectorAttribute(name,*amap); - + tmpl->set(pattr); - + delete amap; free((yyvsp[(1) - (6)].val_str)); ;} break; case 6: -#line 102 "template_syntax.y" +#line 103 "template_syntax.y" { Attribute * pattr; string name((yyvsp[(1) - (3)].val_str)); string value(""); - + pattr = new SingleAttribute(name,value); - + tmpl->set(pattr); - + free((yyvsp[(1) - (3)].val_str)); ;} break; case 7: -#line 113 "template_syntax.y" +#line 114 "template_syntax.y" {;} break; case 8: -#line 117 "template_syntax.y" +#line 118 "template_syntax.y" { map* vattr; string name((yyvsp[(1) - (3)].val_str)); string value((yyvsp[(3) - (3)].val_str)); transform (name.begin(),name.end(),name.begin(),(int(*)(int))toupper); - + vattr = new map; vattr->insert(make_pair(name,value)); @@ -1476,18 +1477,18 @@ yyreduce: break; case 9: -#line 133 "template_syntax.y" +#line 134 "template_syntax.y" { string name((yyvsp[(3) - (5)].val_str)); string value((yyvsp[(5) - (5)].val_str)); map * attrmap; - - transform (name.begin(),name.end(),name.begin(),(int(*)(int))toupper); + + transform (name.begin(),name.end(),name.begin(),(int(*)(int))toupper); attrmap = static_cast *>((yyvsp[(1) - (5)].val_attr)); - + attrmap->insert(make_pair(name,value)); (yyval.val_attr) = (yyvsp[(1) - (5)].val_attr); - + free((yyvsp[(3) - (5)].val_str)); free((yyvsp[(5) - (5)].val_str)); ;} @@ -1495,7 +1496,7 @@ yyreduce: /* Line 1267 of yacc.c. */ -#line 1499 "template_syntax.cc" +#line 1500 "template_syntax.cc" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1715,7 +1716,7 @@ yyreturn: } -#line 148 "template_syntax.y" +#line 149 "template_syntax.y" extern "C" void template_error( @@ -1725,11 +1726,11 @@ extern "C" void template_error( const char * str) { int length; - + length = strlen(str)+ 64; - + *error_msg = (char *) malloc(sizeof(char)*length); - + if (*error_msg != 0) { snprintf(*error_msg, @@ -1740,5 +1741,5 @@ extern "C" void template_error( llocp->first_column, llocp->last_column); } -} +} diff --git a/src/template/template_syntax.h b/src/template/template_syntax.h index d6181ba6bc..4912359870 100644 --- a/src/template/template_syntax.h +++ b/src/template/template_syntax.h @@ -44,7 +44,8 @@ OBRACKET = 260, CBRACKET = 261, NL = 262, - STRING = 263 + STRING = 263, + VARIABLE = 264 }; #endif /* Tokens. */ @@ -54,6 +55,7 @@ #define CBRACKET 261 #define NL 262 #define STRING 263 +#define VARIABLE 264 @@ -66,7 +68,7 @@ typedef union YYSTYPE void * val_attr; } /* Line 1489 of yacc.c. */ -#line 70 "template_syntax.hh" +#line 72 "template_syntax.hh" YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 diff --git a/src/template/template_syntax.y b/src/template/template_syntax.y index 3b086e0972..9bd58915d3 100644 --- a/src/template/template_syntax.y +++ b/src/template/template_syntax.y @@ -29,7 +29,7 @@ #define YYERROR_VERBOSE -extern "C" +extern "C" { void template_error( YYLTYPE * llocp, @@ -58,9 +58,10 @@ int template_parse(Template * tmpl, char ** errmsg); %name-prefix = "template_" %output = "template_syntax.cc" -%token EQUAL COMMA OBRACKET CBRACKET +%token EQUAL COMMA OBRACKET CBRACKET %token NL %token STRING +%token VARIABLE %type array_val %type attribute %type template @@ -70,57 +71,57 @@ int template_parse(Template * tmpl, char ** errmsg); template: attribute | template attribute ; - -attribute: STRING EQUAL STRING NL + +attribute: VARIABLE EQUAL STRING NL { Attribute * pattr; string name($1); string value($3); - + pattr = new SingleAttribute(name,value); tmpl->set(pattr); - + free($1); free($3); } - | STRING EQUAL OBRACKET array_val CBRACKET NL + | VARIABLE EQUAL OBRACKET array_val CBRACKET NL { Attribute * pattr; string name($1); map * amap; - + amap = static_cast *>($4); pattr = new VectorAttribute(name,*amap); - + tmpl->set(pattr); - + delete amap; free($1); } - | STRING EQUAL NL + | VARIABLE EQUAL NL { Attribute * pattr; string name($1); string value(""); - + pattr = new SingleAttribute(name,value); - + tmpl->set(pattr); - + free($1); } | NL {}; ; - -array_val: STRING EQUAL STRING + +array_val: VARIABLE EQUAL STRING { map* vattr; string name($1); string value($3); transform (name.begin(),name.end(),name.begin(),(int(*)(int))toupper); - + vattr = new map; vattr->insert(make_pair(name,value)); @@ -129,18 +130,18 @@ array_val: STRING EQUAL STRING free($1); free($3); } - | array_val COMMA STRING EQUAL STRING + | array_val COMMA VARIABLE EQUAL STRING { string name($3); string value($5); map * attrmap; - - transform (name.begin(),name.end(),name.begin(),(int(*)(int))toupper); + + transform (name.begin(),name.end(),name.begin(),(int(*)(int))toupper); attrmap = static_cast *>($1); - + attrmap->insert(make_pair(name,value)); $$ = $1; - + free($3); free($5); } @@ -154,11 +155,11 @@ extern "C" void template_error( const char * str) { int length; - + length = strlen(str)+ 64; - + *error_msg = (char *) malloc(sizeof(char)*length); - + if (*error_msg != 0) { snprintf(*error_msg, @@ -169,4 +170,4 @@ extern "C" void template_error( llocp->first_column, llocp->last_column); } -} +} diff --git a/src/vm/vm_var_parser.c b/src/vm/vm_var_parser.c index 1d99003508..434281936c 100644 --- a/src/vm/vm_var_parser.c +++ b/src/vm/vm_var_parser.c @@ -393,8 +393,8 @@ static void yy_fatal_error (yyconst char msg[] ); *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; -#define YY_NUM_RULES 13 -#define YY_END_OF_BUFFER 14 +#define YY_NUM_RULES 12 +#define YY_END_OF_BUFFER 13 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -404,28 +404,28 @@ struct yy_trans_info }; static yyconst flex_int16_t yy_accept[33] = { 0, - 0, 0, 0, 0, 14, 12, 1, 10, 2, 10, - 9, 6, 4, 3, 5, 7, 8, 12, 10, 0, - 6, 5, 8, 10, 0, 10, 6, 3, 5, 7, - 11, 0 + 0, 0, 0, 0, 13, 11, 1, 10, 10, 12, + 10, 9, 3, 7, 2, 7, 4, 5, 11, 0, + 3, 2, 5, 0, 8, 3, 6, 7, 7, 2, + 4, 0 } ; static yyconst flex_int32_t yy_ec[256] = { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 3, 1, 4, 1, 1, 1, 1, - 1, 1, 1, 5, 1, 6, 1, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 1, 1, 1, - 8, 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, - 9, 1, 10, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 4, 1, 5, 1, 1, 1, 1, + 1, 1, 1, 6, 1, 7, 1, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 1, 1, 1, + 9, 1, 1, 1, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 11, 1, 12, 1, 10, 1, 10, 10, 10, 10, - 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, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 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, @@ -442,51 +442,52 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[11] = +static yyconst flex_int32_t yy_meta[13] = { 0, - 1, 2, 1, 3, 2, 2, 1, 2, 2, 2 + 1, 1, 1, 1, 2, 1, 1, 3, 1, 3, + 1, 1 } ; static yyconst flex_int16_t yy_base[37] = { 0, - 38, 28, 0, 0, 31, 0, 43, 0, 9, 19, - 43, 28, 43, 21, 23, 22, 43, 0, 0, 0, - 21, 19, 43, 26, 15, 0, 14, 0, 13, 11, - 43, 43, 33, 36, 11, 38 + 36, 35, 0, 0, 39, 0, 42, 42, 11, 42, + 34, 42, 35, 17, 30, 0, 24, 42, 0, 0, + 20, 19, 42, 15, 42, 16, 42, 0, 0, 14, + 13, 42, 27, 30, 33, 11 } ; static yyconst flex_int16_t yy_def[37] = { 0, - 33, 33, 32, 3, 32, 34, 32, 35, 32, 36, - 32, 32, 32, 35, 32, 32, 32, 34, 35, 9, - 32, 32, 32, 36, 36, 35, 32, 14, 32, 32, + 33, 33, 32, 3, 32, 34, 32, 32, 32, 32, + 35, 32, 32, 32, 32, 36, 32, 32, 34, 9, + 32, 32, 32, 35, 32, 32, 32, 14, 36, 32, 32, 0, 32, 32, 32, 32 } ; -static yyconst flex_int16_t yy_nxt[54] = +static yyconst flex_int16_t yy_nxt[55] = { 0, - 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, - 20, 19, 30, 21, 29, 27, 22, 31, 23, 24, - 29, 26, 27, 30, 29, 24, 24, 28, 26, 27, - 32, 7, 24, 6, 6, 6, 18, 18, 25, 25, - 25, 7, 5, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 32 + 8, 9, 10, 11, 12, 13, 8, 14, 15, 16, + 17, 18, 20, 29, 31, 30, 21, 26, 25, 22, + 30, 26, 23, 27, 28, 31, 29, 6, 6, 6, + 19, 30, 19, 24, 24, 24, 26, 25, 32, 7, + 7, 5, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32 } ; -static yyconst flex_int16_t yy_chk[54] = +static yyconst flex_int16_t yy_chk[55] = { 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 9, 35, 30, 9, 29, 27, 9, 25, 9, 10, - 22, 10, 21, 16, 15, 10, 24, 14, 24, 12, - 5, 2, 24, 33, 33, 33, 34, 34, 36, 36, - 36, 1, 32, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 32 + 3, 3, 9, 36, 31, 30, 9, 26, 24, 9, + 22, 21, 9, 14, 14, 17, 14, 33, 33, 33, + 34, 15, 34, 35, 35, 35, 13, 11, 5, 2, + 1, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32 } ; /* Table of booleans, true if rule could match eol. */ -static yyconst flex_int32_t yy_rule_can_match_eol[14] = +static yyconst flex_int32_t yy_rule_can_match_eol[13] = { 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, }; +0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, }; static yy_state_type yy_last_accepting_state; static char *yy_last_accepting_cpos; @@ -533,7 +534,7 @@ char *vm_var_text; llocp->first_column = llocp->last_column; \ llocp->last_column += vm_var_leng; -#line 537 "vm_var_parser.c" +#line 538 "vm_var_parser.c" #define INITIAL 0 #define VAR 1 @@ -722,9 +723,10 @@ YY_DECL /* $VARIABLE */ /* $VARIABLE[ATTR] */ /* $VARIABLE[ATTR,ATTR=VALUE] */ + /* $NUM.CONTEXT_VARIABLE */ /* ------------------------------------------------------------------------- */ -#line 728 "vm_var_parser.c" +#line 730 "vm_var_parser.c" if ( !(yy_init) ) { @@ -783,7 +785,7 @@ yy_match: yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_base[yy_current_state] != 43 ); + while ( yy_base[yy_current_state] != 42 ); yy_find_action: yy_act = yy_accept[yy_current_state]; @@ -819,82 +821,84 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 49 "vm_var_parser.l" +#line 50 "vm_var_parser.l" { BEGIN VAR;} YY_BREAK case 2: YY_RULE_SETUP -#line 51 "vm_var_parser.l" -{ BEGIN(INITIAL); return BLANK;} +#line 52 "vm_var_parser.l" +{ return EQUAL;} YY_BREAK case 3: YY_RULE_SETUP -#line 52 "vm_var_parser.l" -{ lvalp->val_int=atoi(vm_var_text); return INTEGER;} +#line 53 "vm_var_parser.l" +{ return COMMA;} YY_BREAK case 4: YY_RULE_SETUP -#line 53 "vm_var_parser.l" -{ return DOT;} +#line 54 "vm_var_parser.l" +{ return OBRACKET;} YY_BREAK case 5: YY_RULE_SETUP -#line 54 "vm_var_parser.l" -{ return EQUAL;} +#line 55 "vm_var_parser.l" +{ return CBRACKET;} YY_BREAK case 6: YY_RULE_SETUP -#line 55 "vm_var_parser.l" -{ return COMMA;} +#line 57 "vm_var_parser.l" +{ vm_var_text[vm_var_leng-1] = '\0'; + lvalp->val_int = atoi(vm_var_text); + return INTEGER;} YY_BREAK case 7: YY_RULE_SETUP -#line 56 "vm_var_parser.l" -{ return OBRACKET;} +#line 60 "vm_var_parser.l" +{ lvalp->val_str = strdup(vm_var_text); + return STRING;} YY_BREAK case 8: +/* rule 8 can match eol */ YY_RULE_SETUP -#line 57 "vm_var_parser.l" -{ return CBRACKET;} +#line 62 "vm_var_parser.l" +{ lvalp->val_str = strdup(vm_var_text+1); + lvalp->val_str[vm_var_leng-2] = '\0'; + return STRING;} YY_BREAK case 9: YY_RULE_SETUP -#line 58 "vm_var_parser.l" -{ return DOLLAR;} +#line 66 "vm_var_parser.l" +{ lvalp->val_char = '\0'; + return BLANK;} YY_BREAK case 10: -/* rule 10 can match eol */ YY_RULE_SETUP -#line 59 "vm_var_parser.l" -{ lvalp->val_str=strdup(vm_var_text); return STRING;} - YY_BREAK -case 11: -/* rule 11 can match eol */ -YY_RULE_SETUP -#line 60 "vm_var_parser.l" -{ lvalp->val_str = strdup(vm_var_text+1); - lvalp->val_str[vm_var_leng-2] = '\0'; - return STRING; } +#line 68 "vm_var_parser.l" +{ lvalp->val_char = *vm_var_text; + BEGIN(INITIAL); + return BLANK;} YY_BREAK case YY_STATE_EOF(VAR): -#line 64 "vm_var_parser.l" -{ BEGIN(INITIAL); return BLANK;} +#line 71 "vm_var_parser.l" +{ lvalp->val_char = '\0'; + BEGIN(INITIAL); + return BLANK;} YY_BREAK /* ------------------------------------------------------------------------- */ /* Just copy the string verbatim till we find a variable (starts with $) */ /* ------------------------------------------------------------------------- */ -case 12: -/* rule 12 can match eol */ +case 11: +/* rule 11 can match eol */ YY_RULE_SETUP -#line 70 "vm_var_parser.l" +#line 79 "vm_var_parser.l" { lvalp->val_str = strdup(vm_var_text); return RSTRING;} YY_BREAK -case 13: +case 12: YY_RULE_SETUP -#line 72 "vm_var_parser.l" +#line 81 "vm_var_parser.l" ECHO; YY_BREAK -#line 898 "vm_var_parser.c" +#line 902 "vm_var_parser.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1863,7 +1867,7 @@ void vm_var_free (void * ptr ) #define YYTABLES_NAME "yytables" -#line 72 "vm_var_parser.l" +#line 81 "vm_var_parser.l" diff --git a/src/vm/vm_var_parser.h b/src/vm/vm_var_parser.h index 5b75ec65c5..d9748caf7e 100644 --- a/src/vm/vm_var_parser.h +++ b/src/vm/vm_var_parser.h @@ -312,7 +312,7 @@ extern int vm_var_lex (void); #undef YY_DECL #endif -#line 72 "vm_var_parser.l" +#line 81 "vm_var_parser.l" #line 319 "vm_var_parser.h" diff --git a/src/vm/vm_var_parser.l b/src/vm/vm_var_parser.l index 38370d7421..984a4203fd 100644 --- a/src/vm/vm_var_parser.l +++ b/src/vm/vm_var_parser.l @@ -44,24 +44,33 @@ /* $VARIABLE */ /* $VARIABLE[ATTR] */ /* $VARIABLE[ATTR,ATTR=VALUE] */ + /* $NUM.CONTEXT_VARIABLE */ /* ------------------------------------------------------------------------- */ \$ { BEGIN VAR;} -[[:blank:]] { BEGIN(INITIAL); return BLANK;} -[[:digit:]]+ { lvalp->val_int=atoi(yytext); return INTEGER;} -\. { return DOT;} [[:blank:]]*=[[:blank:]]* { return EQUAL;} [[:blank:]]*,[[:blank:]]* { return COMMA;} \[[[:blank:]]* { return OBRACKET;} [[:blank:]]*\] { return CBRACKET;} -\$ { return DOLLAR;} -[^=,\[\]\$[:blank:]\.]+ { lvalp->val_str=strdup(yytext); return STRING;} + +[[:digit:]]+\. { yytext[yyleng-1] = '\0'; + lvalp->val_int = atoi(yytext); + return INTEGER;} +[[:alnum:]_]+ { lvalp->val_str = strdup(yytext); + return STRING;} \"[^\"]*\" { lvalp->val_str = strdup(yytext+1); lvalp->val_str[yyleng-2] = '\0'; - return STRING; } + return STRING;} -<> { BEGIN(INITIAL); return BLANK;} +\$ { lvalp->val_char = '\0'; + return BLANK;} +. { lvalp->val_char = *yytext; + BEGIN(INITIAL); + return BLANK;} +<> { lvalp->val_char = '\0'; + BEGIN(INITIAL); + return BLANK;} /* ------------------------------------------------------------------------- */ /* Just copy the string verbatim till we find a variable (starts with $) */ diff --git a/src/vm/vm_var_syntax.cc b/src/vm/vm_var_syntax.cc index 7bf81c4c7d..466bedbd56 100644 --- a/src/vm/vm_var_syntax.cc +++ b/src/vm/vm_var_syntax.cc @@ -79,11 +79,9 @@ OBRACKET = 260, CBRACKET = 261, BLANK = 262, - DOLLAR = 263, - DOT = 264, - STRING = 265, - RSTRING = 266, - INTEGER = 267 + STRING = 263, + RSTRING = 264, + INTEGER = 265 }; #endif /* Tokens. */ @@ -92,11 +90,9 @@ #define OBRACKET 260 #define CBRACKET 261 #define BLANK 262 -#define DOLLAR 263 -#define DOT 264 -#define STRING 265 -#define RSTRING 266 -#define INTEGER 267 +#define STRING 263 +#define RSTRING 264 +#define INTEGER 265 @@ -164,9 +160,10 @@ typedef union YYSTYPE { char * val_str; int val_int; + char val_char; } /* Line 187 of yacc.c. */ -#line 170 "vm_var_syntax.cc" +#line 167 "vm_var_syntax.cc" YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 @@ -191,7 +188,7 @@ typedef struct YYLTYPE /* Line 216 of yacc.c. */ -#line 195 "vm_var_syntax.cc" +#line 192 "vm_var_syntax.cc" #ifdef short # undef short @@ -408,20 +405,20 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 9 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 22 +#define YYLAST 21 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 13 +#define YYNTOKENS 11 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 3 /* YYNRULES -- Number of rules. */ #define YYNRULES 8 /* YYNRULES -- Number of states. */ -#define YYNSTATES 22 +#define YYNSTATES 21 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 267 +#define YYMAXUTOK 265 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -455,7 +452,7 @@ 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, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12 + 5, 6, 7, 8, 9, 10 }; #if YYDEBUG @@ -469,16 +466,16 @@ static const yytype_uint8 yyprhs[] = /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { - 14, 0, -1, 15, -1, 14, 15, -1, 11, -1, - 10, 7, -1, 10, 5, 10, 6, 7, -1, 10, - 5, 10, 4, 10, 3, 10, 6, 7, -1, 12, - 9, 10, 7, -1 + 12, 0, -1, 13, -1, 12, 13, -1, 9, -1, + 8, 7, -1, 8, 5, 8, 6, 7, -1, 8, + 5, 8, 4, 8, 3, 8, 6, 7, -1, 10, + 8, 7, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 81, 81, 82, 85, 90, 108, 140, 180 + 0, 83, 83, 84, 87, 92, 113, 148, 191 }; #endif @@ -488,8 +485,8 @@ static const yytype_uint8 yyrline[] = static const char *const yytname[] = { "$end", "error", "$undefined", "EQUAL", "COMMA", "OBRACKET", "CBRACKET", - "BLANK", "DOLLAR", "DOT", "STRING", "RSTRING", "INTEGER", "$accept", - "vm_string", "vm_variable", 0 + "BLANK", "STRING", "RSTRING", "INTEGER", "$accept", "vm_string", + "vm_variable", 0 }; #endif @@ -499,20 +496,20 @@ static const char *const yytname[] = static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267 + 265 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 13, 14, 14, 15, 15, 15, 15, 15 + 0, 11, 12, 12, 13, 13, 13, 13, 13 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { - 0, 2, 1, 2, 1, 2, 5, 9, 4 + 0, 2, 1, 2, 1, 2, 5, 9, 3 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -521,8 +518,8 @@ static const yytype_uint8 yyr2[] = static const yytype_uint8 yydefact[] = { 0, 0, 4, 0, 0, 2, 0, 5, 0, 1, - 3, 0, 0, 0, 0, 8, 0, 6, 0, 0, - 0, 7 + 3, 0, 8, 0, 0, 0, 6, 0, 0, 0, + 7 }; /* YYDEFGOTO[NTERM-NUM]. */ @@ -533,18 +530,18 @@ static const yytype_int8 yydefgoto[] = /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -10 +#define YYPACT_NINF -8 static const yytype_int8 yypact[] = { - -9, -1, -10, 4, 0, -10, -2, -10, 5, -10, - -10, 1, 2, 6, 7, -10, 14, -10, 8, 13, - 15, -10 + -7, -1, -8, 3, 0, -8, 4, -8, 6, -8, + -8, 1, -8, 7, 9, 11, -8, 10, 13, 14, + -8 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -10, -10, 16 + -8, -8, 16 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -554,25 +551,25 @@ static const yytype_int8 yypgoto[] = #define YYTABLE_NINF -1 static const yytype_uint8 yytable[] = { - 9, 1, 2, 3, 6, 13, 7, 14, 11, 15, - 1, 2, 3, 8, 17, 12, 16, 18, 19, 20, - 10, 0, 21 + 9, 1, 2, 3, 6, 13, 7, 14, 1, 2, + 3, 8, 11, 12, 17, 15, 16, 0, 18, 19, + 10, 20 }; static const yytype_int8 yycheck[] = { - 0, 10, 11, 12, 5, 4, 7, 6, 10, 7, - 10, 11, 12, 9, 7, 10, 10, 3, 10, 6, - 4, -1, 7 + 0, 8, 9, 10, 5, 4, 7, 6, 8, 9, + 10, 8, 8, 7, 3, 8, 7, -1, 8, 6, + 4, 7 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 10, 11, 12, 14, 15, 5, 7, 9, 0, - 15, 10, 10, 4, 6, 7, 10, 7, 3, 10, - 6, 7 + 0, 8, 9, 10, 12, 13, 5, 7, 8, 0, + 13, 8, 7, 4, 6, 8, 7, 3, 8, 6, + 7 }; #define yyerrok (yyerrstatus = 0) @@ -1436,7 +1433,7 @@ yyreduce: switch (yyn) { case 4: -#line 86 "vm_var_syntax.y" +#line 88 "vm_var_syntax.y" { (*parsed) << (yyvsp[(1) - (1)].val_str); free((yyvsp[(1) - (1)].val_str)); @@ -1444,7 +1441,7 @@ yyreduce: break; case 5: -#line 91 "vm_var_syntax.y" +#line 93 "vm_var_syntax.y" { string name((yyvsp[(1) - (2)].val_str)); string value = ""; @@ -1458,14 +1455,17 @@ yyreduce: (*parsed) << value; } - (*parsed) << ' '; + if ( (yyvsp[(2) - (2)].val_char) != '\0' ) + { + (*parsed) << (yyvsp[(2) - (2)].val_char); + } free((yyvsp[(1) - (2)].val_str)); ;} break; case 6: -#line 109 "vm_var_syntax.y" +#line 114 "vm_var_syntax.y" { vector values; const VectorAttribute * vattr; @@ -1492,7 +1492,10 @@ yyreduce: (*parsed) << value; } - (*parsed) << ' '; + if ( (yyvsp[(5) - (5)].val_char) != '\0' ) + { + (*parsed) << (yyvsp[(5) - (5)].val_char); + } free((yyvsp[(1) - (5)].val_str)); free((yyvsp[(3) - (5)].val_str)); @@ -1500,7 +1503,7 @@ yyreduce: break; case 7: -#line 141 "vm_var_syntax.y" +#line 149 "vm_var_syntax.y" { vector values; const VectorAttribute * vattr; @@ -1533,7 +1536,10 @@ yyreduce: (*parsed) << value; } - (*parsed) << ' '; + if ( (yyvsp[(9) - (9)].val_char) != '\0' ) + { + (*parsed) << (yyvsp[(9) - (9)].val_char); + } free((yyvsp[(1) - (9)].val_str)); free((yyvsp[(3) - (9)].val_str)); @@ -1543,16 +1549,16 @@ yyreduce: break; case 8: -#line 181 "vm_var_syntax.y" +#line 192 "vm_var_syntax.y" { - string name((yyvsp[(3) - (4)].val_str)); + string name((yyvsp[(2) - (3)].val_str)); string value = ""; VirtualMachine * tvm; vector values; const VectorAttribute * vattr; - tvm = vmpool->get((yyvsp[(1) - (4)].val_int),true); + tvm = vmpool->get((yyvsp[(1) - (3)].val_int),true); if ( tvm != 0 ) { @@ -1576,15 +1582,18 @@ yyreduce: (*parsed) << value; } - (*parsed) << ' '; + if ( (yyvsp[(3) - (3)].val_char) != '\0' ) + { + (*parsed) << (yyvsp[(3) - (3)].val_char); + } - free((yyvsp[(3) - (4)].val_str)); + free((yyvsp[(2) - (3)].val_str)); ;} break; /* Line 1267 of yacc.c. */ -#line 1588 "vm_var_syntax.cc" +#line 1597 "vm_var_syntax.cc" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1804,7 +1813,7 @@ yyreturn: } -#line 218 "vm_var_syntax.y" +#line 232 "vm_var_syntax.y" extern "C" void vm_var_error( diff --git a/src/vm/vm_var_syntax.h b/src/vm/vm_var_syntax.h index 8f741ae8bd..1df550f932 100644 --- a/src/vm/vm_var_syntax.h +++ b/src/vm/vm_var_syntax.h @@ -44,11 +44,9 @@ OBRACKET = 260, CBRACKET = 261, BLANK = 262, - DOLLAR = 263, - DOT = 264, - STRING = 265, - RSTRING = 266, - INTEGER = 267 + STRING = 263, + RSTRING = 264, + INTEGER = 265 }; #endif /* Tokens. */ @@ -57,11 +55,9 @@ #define OBRACKET 260 #define CBRACKET 261 #define BLANK 262 -#define DOLLAR 263 -#define DOT 264 -#define STRING 265 -#define RSTRING 266 -#define INTEGER 267 +#define STRING 263 +#define RSTRING 264 +#define INTEGER 265 @@ -72,9 +68,10 @@ typedef union YYSTYPE { char * val_str; int val_int; + char val_char; } /* Line 1489 of yacc.c. */ -#line 78 "vm_var_syntax.hh" +#line 75 "vm_var_syntax.hh" YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 diff --git a/src/vm/vm_var_syntax.y b/src/vm/vm_var_syntax.y index d3017df9be..58f96d10ed 100644 --- a/src/vm/vm_var_syntax.y +++ b/src/vm/vm_var_syntax.y @@ -60,6 +60,7 @@ int vm_var_parse (VirtualMachinePool * vmpool, %union { char * val_str; int val_int; + char val_char; }; %defines @@ -68,8 +69,9 @@ int vm_var_parse (VirtualMachinePool * vmpool, %name-prefix = "vm_var_" %output = "vm_var_syntax.cc" -%token EQUAL COMMA OBRACKET CBRACKET BLANK DOLLAR DOT +%token EQUAL COMMA OBRACKET CBRACKET +%token BLANK %token STRING %token RSTRING %token INTEGER @@ -101,7 +103,10 @@ vm_variable:RSTRING (*parsed) << value; } - (*parsed) << ' '; + if ( $2 != '\0' ) + { + (*parsed) << $2; + } free($1); } @@ -132,7 +137,10 @@ vm_variable:RSTRING (*parsed) << value; } - (*parsed) << ' '; + if ( $5 != '\0' ) + { + (*parsed) << $5; + } free($1); free($3); @@ -170,16 +178,19 @@ vm_variable:RSTRING (*parsed) << value; } - (*parsed) << ' '; + if ( $9 != '\0' ) + { + (*parsed) << $9; + } free($1); free($3); free($5); free($7); } - | INTEGER DOT STRING BLANK + | INTEGER STRING BLANK { - string name($3); + string name($2); string value = ""; VirtualMachine * tvm; @@ -210,9 +221,12 @@ vm_variable:RSTRING (*parsed) << value; } - (*parsed) << ' '; + if ( $3 != '\0' ) + { + (*parsed) << $3; + } - free($3); + free($2); } ; %% diff --git a/src/vmm_mad/kvm/vmm_kvm.conf b/src/vmm_mad/kvm/vmm_kvm.conf index 8124dd0cfe..fa62da68d8 100644 --- a/src/vmm_mad/kvm/vmm_kvm.conf +++ b/src/vmm_mad/kvm/vmm_kvm.conf @@ -9,5 +9,5 @@ #VCPU = 1 #MEMORY = 128 #OS = [ kernel="/vmlinuz", initrd="/initrd.img", root="sda1", boot=hd,kernel_cmd="ro"] -OS = [ boot=hd ] +OS = [ boot = "hd" ]