From 5750ee5d1fa40fdf727b2e4eaf7b232fd4d8260a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20S=2E=20Montero?= Date: Thu, 3 Jul 2008 01:19:35 +0000 Subject: [PATCH] Multiple value attributes can now be in different lines git-svn-id: http://svn.opennebula.org/trunk@25 3034c82b-c49b-4eb3-8279-a7acafdc01c0 --- src/template/template_parser.c | 111 ++++++++++++++++---------------- src/template/template_parser.l | 16 ++--- src/template/template_syntax.cc | 81 +++++++++++------------ src/template/template_syntax.h | 24 ++++--- src/template/template_syntax.y | 2 +- 5 files changed, 116 insertions(+), 118 deletions(-) diff --git a/src/template/template_parser.c b/src/template/template_parser.c index 42673f2534..87c6a8348e 100644 --- a/src/template/template_parser.c +++ b/src/template/template_parser.c @@ -408,12 +408,12 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[40] = +static yyconst flex_int16_t yy_accept[39] = { 0, - 11, 2, 13, 11, 4, 3, 11, 12, 11, 6, - 5, 7, 8, 2, 11, 4, 3, 0, 6, 5, - 7, 8, 11, 0, 9, 0, 1, 11, 0, 10, - 6, 5, 7, 8, 2, 0, 9, 10, 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 } ; static yyconst flex_int32_t yy_ec[256] = @@ -450,55 +450,55 @@ static yyconst flex_int32_t yy_ec[256] = static yyconst flex_int32_t yy_meta[11] = { 0, - 1, 2, 2, 1, 2, 1, 2, 2, 2, 2 + 1, 2, 3, 1, 4, 1, 4, 4, 4, 4 } ; -static yyconst flex_int16_t yy_base[45] = +static yyconst flex_int16_t yy_base[46] = { 0, - 0, 58, 59, 0, 9, 61, 19, 55, 25, 55, - 54, 53, 52, 51, 0, 0, 61, 49, 40, 38, - 37, 34, 31, 30, 0, 30, 61, 37, 24, 0, - 26, 25, 22, 20, 19, 12, 61, 61, 61, 12, - 43, 45, 47, 49 + 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 } ; -static yyconst flex_int16_t yy_def[45] = +static yyconst flex_int16_t yy_def[46] = { 0, - 39, 1, 39, 40, 39, 39, 41, 42, 43, 39, - 39, 39, 39, 5, 40, 5, 39, 44, 39, 39, - 39, 39, 41, 41, 40, 42, 39, 43, 43, 40, - 39, 39, 39, 39, 5, 44, 39, 39, 0, 39, - 39, 39, 39, 39 + 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 } ; -static yyconst flex_int16_t yy_nxt[72] = +static yyconst flex_int16_t yy_nxt[79] = { 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 16, 17, 15, 18, 17, 19, 20, 21, 22, 23, - 35, 34, 25, 33, 23, 28, 32, 31, 28, 38, - 30, 23, 27, 37, 25, 34, 23, 28, 33, 32, - 28, 31, 30, 24, 24, 26, 26, 29, 29, 36, - 36, 17, 35, 34, 33, 32, 31, 27, 39, 14, - 3, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39 + 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 } ; -static yyconst flex_int16_t yy_chk[72] = +static yyconst flex_int16_t yy_chk[79] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 5, 5, 40, 5, 36, 5, 5, 5, 5, 7, - 35, 34, 7, 33, 7, 9, 32, 31, 9, 29, - 9, 23, 26, 24, 23, 22, 23, 28, 21, 20, - 28, 19, 28, 41, 41, 42, 42, 43, 43, 44, - 44, 18, 14, 13, 12, 11, 10, 8, 3, 2, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39 + 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 } ; /* Table of booleans, true if rule could match eol. */ static yyconst flex_int32_t yy_rule_can_match_eol[13] = { 0, -1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, }; +0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, }; static yy_state_type yy_last_accepting_state; static char *yy_last_accepting_cpos; @@ -756,13 +756,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 >= 40 ) + if ( yy_current_state >= 39 ) 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] != 61 ); + while ( yy_base[yy_current_state] != 68 ); yy_find_action: yy_act = yy_accept[yy_current_state]; @@ -797,7 +797,6 @@ do_action: /* This label is used only to access EOF actions. */ goto yy_find_action; case 1: -/* rule 1 can match eol */ YY_RULE_SETUP #line 42 "template_parser.l" ; @@ -808,36 +807,40 @@ YY_RULE_SETUP ; YY_BREAK case 3: -/* rule 3 can match eol */ YY_RULE_SETUP #line 44 "template_parser.l" -{return NL;} +; YY_BREAK /* --- Tokens --- */ case 4: +/* rule 4 can match eol */ YY_RULE_SETUP #line 48 "template_parser.l" -{return BLANK;} - YY_BREAK -case 5: -YY_RULE_SETUP -#line 49 "template_parser.l" {return EQUAL;} YY_BREAK -case 6: +case 5: +/* rule 5 can match eol */ YY_RULE_SETUP -#line 50 "template_parser.l" +#line 49 "template_parser.l" {return COMMA;} YY_BREAK -case 7: +case 6: +/* rule 6 can match eol */ YY_RULE_SETUP -#line 51 "template_parser.l" +#line 50 "template_parser.l" {return OBRACKET;} YY_BREAK +case 7: +/* rule 7 can match eol */ +YY_RULE_SETUP +#line 51 "template_parser.l" +{return CBRACKET;} + YY_BREAK case 8: +/* rule 8 can match eol */ YY_RULE_SETUP #line 52 "template_parser.l" -{return CBRACKET;} +{return NL;} YY_BREAK /* --- Strings, anything but =,][# Also quoted form --- */ case 9: @@ -866,7 +869,7 @@ YY_RULE_SETUP #line 66 "template_parser.l" ECHO; YY_BREAK -#line 870 "template_parser.c" +#line 873 "template_parser.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1159,7 +1162,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 >= 40 ) + if ( yy_current_state >= 39 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1187,11 +1190,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 >= 40 ) + if ( yy_current_state >= 39 ) 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 == 39); + yy_is_jam = (yy_current_state == 38); return yy_is_jam ? 0 : yy_current_state; } diff --git a/src/template/template_parser.l b/src/template/template_parser.l index 41fb41a6ca..054bb0c092 100644 --- a/src/template/template_parser.l +++ b/src/template/template_parser.l @@ -39,17 +39,17 @@ %% /* --- Comments and blanks --- */ -#.*\n ; -^[[:blank:]]* ; -[[:blank:]]*(#.*)?\n {return NL;} +#.* ; +^[[:blank:]]* ; +[[:blank:]]*(#.*)? ; /* --- Tokens --- */ -[[:blank:]]+ {return BLANK;} -[[:blank:]]*=[[:blank:]]* {return EQUAL;} -[[:blank:]]*,[[:blank:]]* {return COMMA;} -[[:blank:]]*\[[[:blank:]]* {return OBRACKET;} -[[:blank:]]*\][[:blank:]]* {return CBRACKET;} +[[: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 --- */ diff --git a/src/template/template_syntax.cc b/src/template/template_syntax.cc index 205d2b6dd7..81611f4ce7 100644 --- a/src/template/template_syntax.cc +++ b/src/template/template_syntax.cc @@ -75,22 +75,20 @@ know about them. */ enum yytokentype { EQUAL = 258, - BLANK = 259, - COMMA = 260, - OBRACKET = 261, - CBRACKET = 262, - NL = 263, - STRING = 264 + COMMA = 259, + OBRACKET = 260, + CBRACKET = 261, + NL = 262, + STRING = 263 }; #endif /* Tokens. */ #define EQUAL 258 -#define BLANK 259 -#define COMMA 260 -#define OBRACKET 261 -#define CBRACKET 262 -#define NL 263 -#define STRING 264 +#define COMMA 259 +#define OBRACKET 260 +#define CBRACKET 261 +#define NL 262 +#define STRING 263 @@ -152,7 +150,7 @@ typedef union YYSTYPE void * val_attr; } /* Line 187 of yacc.c. */ -#line 156 "template_syntax.cc" +#line 154 "template_syntax.cc" YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 @@ -177,7 +175,7 @@ typedef struct YYLTYPE /* Line 216 of yacc.c. */ -#line 181 "template_syntax.cc" +#line 179 "template_syntax.cc" #ifdef short # undef short @@ -394,10 +392,10 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 6 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 21 +#define YYLAST 20 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 10 +#define YYNTOKENS 9 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 4 /* YYNRULES -- Number of rules. */ @@ -407,7 +405,7 @@ union yyalloc /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 264 +#define YYMAXUTOK 263 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -441,7 +439,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 + 5, 6, 7, 8 }; #if YYDEBUG @@ -455,10 +453,10 @@ static const yytype_uint8 yyprhs[] = /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { - 11, 0, -1, 12, -1, 11, 12, -1, 9, 3, - 9, 8, -1, 9, 3, 6, 13, 7, 8, -1, - 9, 3, 8, -1, 8, -1, 9, 3, 9, -1, - 13, 5, 9, 3, 9, -1 + 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 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ @@ -473,9 +471,8 @@ static const yytype_uint8 yyrline[] = First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - "$end", "error", "$undefined", "EQUAL", "BLANK", "COMMA", "OBRACKET", - "CBRACKET", "NL", "STRING", "$accept", "template", "attribute", - "array_val", 0 + "$end", "error", "$undefined", "EQUAL", "COMMA", "OBRACKET", "CBRACKET", + "NL", "STRING", "$accept", "template", "attribute", "array_val", 0 }; #endif @@ -484,14 +481,14 @@ static const char *const yytname[] = token YYLEX-NUM. */ static const yytype_uint16 yytoknum[] = { - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264 + 0, 256, 257, 258, 259, 260, 261, 262, 263 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 10, 11, 11, 12, 12, 12, 12, 13, 13 + 0, 9, 10, 10, 11, 11, 11, 11, 12, 12 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -518,18 +515,18 @@ static const yytype_int8 yydefgoto[] = /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -6 +#define YYPACT_NINF -5 static const yytype_int8 yypact[] = { - -3, -6, -1, 0, -6, -5, -6, -6, -2, -6, - 3, 10, 5, -6, 6, 7, 9, -6, 11, -6, - 12, -6 + -2, -5, -1, 0, -5, -4, -5, -5, 2, -5, + 6, 9, 5, -5, 7, 8, 10, -5, 11, -5, + 12, -5 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -6, -6, 15, -6 + -5, -5, 15, -5 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -539,25 +536,25 @@ static const yytype_int8 yypgoto[] = #define YYTABLE_NINF -1 static const yytype_uint8 yytable[] = { - 6, 8, 5, 9, 10, 1, 2, 11, 1, 2, - 15, 13, 16, 14, 20, 17, 18, 19, 7, 0, - 0, 21 + 6, 8, 5, 9, 10, 1, 2, 1, 2, 15, + 11, 16, 14, 13, 20, 17, 18, 19, 7, 0, + 21 }; static const yytype_int8 yycheck[] = { - 0, 6, 3, 8, 9, 8, 9, 9, 8, 9, - 5, 8, 7, 3, 3, 9, 9, 8, 3, -1, - -1, 9 + 0, 5, 3, 7, 8, 7, 8, 7, 8, 4, + 8, 6, 3, 7, 3, 8, 8, 7, 3, -1, + 8 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 8, 9, 11, 12, 3, 0, 12, 6, 8, - 9, 9, 13, 8, 3, 5, 7, 9, 9, 8, - 3, 9 + 0, 7, 8, 10, 11, 3, 0, 11, 5, 7, + 8, 8, 12, 7, 3, 4, 6, 8, 8, 7, + 3, 8 }; #define yyerrok (yyerrstatus = 0) @@ -1498,7 +1495,7 @@ yyreduce: /* Line 1267 of yacc.c. */ -#line 1502 "template_syntax.cc" +#line 1499 "template_syntax.cc" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); diff --git a/src/template/template_syntax.h b/src/template/template_syntax.h index d4359a996d..d6181ba6bc 100644 --- a/src/template/template_syntax.h +++ b/src/template/template_syntax.h @@ -40,22 +40,20 @@ know about them. */ enum yytokentype { EQUAL = 258, - BLANK = 259, - COMMA = 260, - OBRACKET = 261, - CBRACKET = 262, - NL = 263, - STRING = 264 + COMMA = 259, + OBRACKET = 260, + CBRACKET = 261, + NL = 262, + STRING = 263 }; #endif /* Tokens. */ #define EQUAL 258 -#define BLANK 259 -#define COMMA 260 -#define OBRACKET 261 -#define CBRACKET 262 -#define NL 263 -#define STRING 264 +#define COMMA 259 +#define OBRACKET 260 +#define CBRACKET 261 +#define NL 262 +#define STRING 263 @@ -68,7 +66,7 @@ typedef union YYSTYPE void * val_attr; } /* Line 1489 of yacc.c. */ -#line 72 "template_syntax.hh" +#line 70 "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 6a88769147..54e1b5bdf6 100644 --- a/src/template/template_syntax.y +++ b/src/template/template_syntax.y @@ -58,7 +58,7 @@ int template_parse(Template * tmpl, char ** errmsg); %name-prefix = "template_" %output = "template_syntax.cc" -%token EQUAL BLANK COMMA OBRACKET CBRACKET +%token EQUAL COMMA OBRACKET CBRACKET %token NL %token STRING %type array_val