diff options
author | Jonathan McCrohan <jmccrohan@gmail.com> | 2011-12-01 23:47:41 +0000 |
---|---|---|
committer | Jonathan McCrohan <jmccrohan@gmail.com> | 2011-12-01 23:47:41 +0000 |
commit | 1eaceca55c7e62892fd28bfbb5fc03240a48cee3 (patch) | |
tree | 7243fcd09c57e06e72b15f0044fd2c77babd7843 /lib/grammar.c | |
parent | d4b5ddf4bcacd692011f5a597025c38a1262d6ca (diff) | |
parent | 429e46051dba814e7d6c74368eb1bba550222cbe (diff) | |
download | libconfig-1eaceca55c7e62892fd28bfbb5fc03240a48cee3.tar.gz |
Merge commit 'upstream/1.4.8'
Conflicts:
debian/changelog
debian/control
debian/libconfig++9-dev.install
debian/libconfig8.install
debian/libconfig9-dev.install
debian/rules
Diffstat (limited to '')
-rw-r--r-- | lib/grammar.c (renamed from grammar.c) | 701 |
1 files changed, 387 insertions, 314 deletions
diff --git a/grammar.c b/lib/grammar.c index 8317318..e95a569 100644 --- a/grammar.c +++ b/lib/grammar.c @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ -/* Skeleton implementation for Bison's Yacc-like parsers in C +/* A Bison parser, made by GNU Bison 2.4.1. */ - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + 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, or (at your option) - any later version. - + the Free Software Foundation, either version 3 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 Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,7 +28,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -47,7 +46,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.3" +#define YYBISON_VERSION "2.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -55,72 +54,29 @@ /* Pure parsers. */ #define YYPURE 1 +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + /* Using locations. */ #define YYLSP_NEEDED 0 /* Substitute the variable and function names. */ -#define yyparse libconfig_yyparse -#define yylex libconfig_yylex -#define yyerror libconfig_yyerror -#define yylval libconfig_yylval -#define yychar libconfig_yychar -#define yydebug libconfig_yydebug -#define yynerrs libconfig_yynerrs - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - TOK_BOOLEAN = 258, - TOK_INTEGER = 259, - TOK_HEX = 260, - TOK_INTEGER64 = 261, - TOK_HEX64 = 262, - TOK_FLOAT = 263, - TOK_STRING = 264, - TOK_NAME = 265, - TOK_EQUALS = 266, - TOK_NEWLINE = 267, - TOK_ARRAY_START = 268, - TOK_ARRAY_END = 269, - TOK_LIST_START = 270, - TOK_LIST_END = 271, - TOK_COMMA = 272, - TOK_GROUP_START = 273, - TOK_GROUP_END = 274, - TOK_END = 275, - TOK_GARBAGE = 276 - }; -#endif -/* Tokens. */ -#define TOK_BOOLEAN 258 -#define TOK_INTEGER 259 -#define TOK_HEX 260 -#define TOK_INTEGER64 261 -#define TOK_HEX64 262 -#define TOK_FLOAT 263 -#define TOK_STRING 264 -#define TOK_NAME 265 -#define TOK_EQUALS 266 -#define TOK_NEWLINE 267 -#define TOK_ARRAY_START 268 -#define TOK_ARRAY_END 269 -#define TOK_LIST_START 270 -#define TOK_LIST_END 271 -#define TOK_COMMA 272 -#define TOK_GROUP_START 273 -#define TOK_GROUP_END 274 -#define TOK_END 275 -#define TOK_GARBAGE 276 - - +#define yyparse libconfig_yyparse +#define yylex libconfig_yylex +#define yyerror libconfig_yyerror +#define yylval libconfig_yylval +#define yychar libconfig_yychar +#define yydebug libconfig_yydebug +#define yynerrs libconfig_yynerrs /* Copy the first part of user declarations. */ -#line 31 "grammar.y" + +/* Line 189 of yacc.c */ +#line 32 "grammar.y" #include <string.h> #include <stdlib.h> @@ -132,36 +88,50 @@ #ifndef _STDLIB_H #define _STDLIB_H #endif - + #include <malloc.h> #endif -#include "private.h" +#include "parsectx.h" +#include "scanctx.h" /* these delcarations are provided to suppress compiler warnings */ extern int libconfig_yylex(); extern int libconfig_yyget_lineno(); - + static const char *err_array_elem_type = "mismatched element type in array"; static const char *err_duplicate_setting = "duplicate setting name"; +#define _delete(P) free((void *)(P)) + #define IN_ARRAY() \ (ctx->parent && (ctx->parent->type == CONFIG_TYPE_ARRAY)) #define IN_LIST() \ (ctx->parent && (ctx->parent->type == CONFIG_TYPE_LIST)) -#define CAPTURE_PARSE_POS(S) \ - (S)->line = (unsigned int)libconfig_yyget_lineno(scanner) +static void capture_parse_pos(void *scanner, struct scan_context *scan_ctx, + config_setting_t *setting) +{ + setting->line = (unsigned int)libconfig_yyget_lineno(scanner); + setting->file = scanctx_current_filename(scan_ctx); +} + +#define CAPTURE_PARSE_POS(S) \ + capture_parse_pos(scanner, scan_ctx, (S)) void libconfig_yyerror(void *scanner, struct parse_context *ctx, - char const *s) + struct scan_context *scan_ctx, char const *s) { + if(ctx->config->error_text) return; ctx->config->error_line = libconfig_yyget_lineno(scanner); ctx->config->error_text = s; } +/* Line 189 of yacc.c */ +#line 134 "grammar.c" + /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 @@ -180,30 +150,88 @@ void libconfig_yyerror(void *scanner, struct parse_context *ctx, # define YYTOKEN_TABLE 0 #endif + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + TOK_BOOLEAN = 258, + TOK_INTEGER = 259, + TOK_HEX = 260, + TOK_INTEGER64 = 261, + TOK_HEX64 = 262, + TOK_FLOAT = 263, + TOK_STRING = 264, + TOK_NAME = 265, + TOK_EQUALS = 266, + TOK_NEWLINE = 267, + TOK_ARRAY_START = 268, + TOK_ARRAY_END = 269, + TOK_LIST_START = 270, + TOK_LIST_END = 271, + TOK_COMMA = 272, + TOK_GROUP_START = 273, + TOK_GROUP_END = 274, + TOK_SEMICOLON = 275, + TOK_GARBAGE = 276, + TOK_ERROR = 277 + }; +#endif +/* Tokens. */ +#define TOK_BOOLEAN 258 +#define TOK_INTEGER 259 +#define TOK_HEX 260 +#define TOK_INTEGER64 261 +#define TOK_HEX64 262 +#define TOK_FLOAT 263 +#define TOK_STRING 264 +#define TOK_NAME 265 +#define TOK_EQUALS 266 +#define TOK_NEWLINE 267 +#define TOK_ARRAY_START 268 +#define TOK_ARRAY_END 269 +#define TOK_LIST_START 270 +#define TOK_LIST_END 271 +#define TOK_COMMA 272 +#define TOK_GROUP_START 273 +#define TOK_GROUP_END 274 +#define TOK_SEMICOLON 275 +#define TOK_GARBAGE 276 +#define TOK_ERROR 277 + + + + #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 73 "grammar.y" { - long ival; + +/* Line 214 of yacc.c */ +#line 85 "grammar.y" + + int ival; long long llval; double fval; char *sval; -} -/* Line 187 of yacc.c. */ -#line 194 "grammar.c" - YYSTYPE; + + + +/* Line 214 of yacc.c */ +#line 223 "grammar.c" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif - /* Copy the second part of user declarations. */ -/* Line 216 of yacc.c. */ -#line 207 "grammar.c" +/* Line 264 of yacc.c */ +#line 235 "grammar.c" #ifdef short # undef short @@ -278,14 +306,14 @@ typedef short int yytype_int16; #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int -YYID (int i) +YYID (int yyi) #else static int -YYID (i) - int i; +YYID (yyi) + int yyi; #endif { - return i; + return yyi; } #endif @@ -366,9 +394,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss; - YYSTYPE yyvs; - }; + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) @@ -402,12 +430,12 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack) \ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ @@ -418,20 +446,20 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 6 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 32 +#define YYLAST 35 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 22 +#define YYNTOKENS 23 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 18 +#define YYNNTS 20 /* YYNRULES -- Number of rules. */ -#define YYNRULES 34 +#define YYNRULES 39 /* YYNRULES -- Number of states. */ -#define YYNSTATES 43 +#define YYNSTATES 47 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 276 +#define YYMAXUTOK 277 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -466,7 +494,7 @@ static const yytype_uint8 yytranslate[] = 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, 13, 14, - 15, 16, 17, 18, 19, 20, 21 + 15, 16, 17, 18, 19, 20, 21, 22 }; #if YYDEBUG @@ -475,31 +503,32 @@ static const yytype_uint8 yytranslate[] = static const yytype_uint8 yyprhs[] = { 0, 0, 3, 4, 6, 8, 11, 12, 14, 15, - 21, 22, 27, 28, 33, 35, 37, 39, 41, 43, - 45, 47, 49, 51, 53, 55, 57, 61, 62, 64, - 66, 70, 71, 73, 74 + 17, 19, 20, 26, 27, 32, 33, 38, 40, 42, + 44, 46, 48, 51, 53, 55, 57, 59, 61, 63, + 65, 67, 71, 72, 74, 76, 80, 81, 83, 84 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { - 23, 0, -1, -1, 24, -1, 26, -1, 24, 26, - -1, -1, 24, -1, -1, 10, 27, 11, 32, 20, - -1, -1, 13, 29, 37, 14, -1, -1, 15, 31, - 35, 16, -1, 33, -1, 28, -1, 30, -1, 38, + 24, 0, -1, -1, 25, -1, 28, -1, 25, 28, + -1, -1, 25, -1, -1, 20, -1, 17, -1, -1, + 10, 29, 11, 34, 27, -1, -1, 13, 31, 40, + 14, -1, -1, 15, 33, 38, 16, -1, 36, -1, + 30, -1, 32, -1, 41, -1, 9, -1, 35, 9, -1, 3, -1, 4, -1, 6, -1, 5, -1, 7, - -1, 8, -1, 9, -1, 32, -1, 34, 17, 32, - -1, -1, 34, -1, 33, -1, 36, 17, 33, -1, - -1, 36, -1, -1, 18, 39, 25, 19, -1 + -1, 8, -1, 35, -1, 34, -1, 37, 17, 34, + -1, -1, 37, -1, 36, -1, 39, 17, 36, -1, + -1, 39, -1, -1, 18, 42, 26, 19, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 88, 88, 90, 94, 95, 98, 100, 105, 104, - 125, 124, 148, 147, 170, 171, 172, 173, 177, 197, - 219, 241, 263, 285, 303, 330, 331, 334, 336, 340, - 341, 344, 346, 351, 350 + 0, 100, 100, 102, 106, 107, 110, 112, 115, 117, + 118, 123, 122, 142, 141, 165, 164, 187, 188, 189, + 190, 194, 195, 199, 219, 241, 263, 285, 307, 325, + 353, 354, 357, 359, 363, 364, 367, 369, 374, 373 }; #endif @@ -512,11 +541,11 @@ static const char *const yytname[] = "TOK_INTEGER64", "TOK_HEX64", "TOK_FLOAT", "TOK_STRING", "TOK_NAME", "TOK_EQUALS", "TOK_NEWLINE", "TOK_ARRAY_START", "TOK_ARRAY_END", "TOK_LIST_START", "TOK_LIST_END", "TOK_COMMA", "TOK_GROUP_START", - "TOK_GROUP_END", "TOK_END", "TOK_GARBAGE", "$accept", "configuration", - "setting_list", "setting_list_optional", "setting", "@1", "array", "@2", - "list", "@3", "value", "simple_value", "value_list", - "value_list_optional", "simple_value_list", "simple_value_list_optional", - "group", "@4", 0 + "TOK_GROUP_END", "TOK_SEMICOLON", "TOK_GARBAGE", "TOK_ERROR", "$accept", + "configuration", "setting_list", "setting_list_optional", + "setting_terminator", "setting", "$@1", "array", "$@2", "list", "$@3", + "value", "string", "simple_value", "value_list", "value_list_optional", + "simple_value_list", "simple_value_list_optional", "group", "$@4", 0 }; #endif @@ -527,26 +556,26 @@ 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 + 275, 276, 277 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 22, 23, 23, 24, 24, 25, 25, 27, 26, - 29, 28, 31, 30, 32, 32, 32, 32, 33, 33, - 33, 33, 33, 33, 33, 34, 34, 35, 35, 36, - 36, 37, 37, 39, 38 + 0, 23, 24, 24, 25, 25, 26, 26, 27, 27, + 27, 29, 28, 31, 30, 33, 32, 34, 34, 34, + 34, 35, 35, 36, 36, 36, 36, 36, 36, 36, + 37, 37, 38, 38, 39, 39, 40, 40, 42, 41 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { - 0, 2, 0, 1, 1, 2, 0, 1, 0, 5, - 0, 4, 0, 4, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 3, 0, 1, 1, - 3, 0, 1, 0, 4 + 0, 2, 0, 1, 1, 2, 0, 1, 0, 1, + 1, 0, 5, 0, 4, 0, 4, 1, 1, 1, + 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 3, 0, 1, 1, 3, 0, 1, 0, 4 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -554,37 +583,37 @@ static const yytype_uint8 yyr2[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 2, 8, 0, 3, 4, 0, 1, 5, 0, 18, - 19, 21, 20, 22, 23, 24, 10, 12, 33, 15, - 16, 0, 14, 17, 31, 27, 6, 9, 29, 32, - 0, 25, 28, 0, 7, 0, 0, 11, 0, 13, - 34, 30, 26 + 2, 11, 0, 3, 4, 0, 1, 5, 0, 23, + 24, 26, 25, 27, 28, 21, 13, 15, 38, 18, + 19, 8, 29, 17, 20, 36, 32, 6, 10, 9, + 12, 22, 34, 37, 0, 30, 33, 0, 7, 0, + 0, 14, 0, 16, 39, 35, 31 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { - -1, 2, 3, 35, 4, 5, 19, 24, 20, 25, - 21, 22, 32, 33, 29, 30, 23, 26 + -1, 2, 3, 39, 30, 4, 5, 19, 25, 20, + 26, 21, 22, 23, 36, 37, 33, 34, 24, 27 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -18 +#define YYPACT_NINF -26 static const yytype_int8 yypact[] = { - -1, -18, 12, -1, -18, 3, -18, -18, -2, -18, - -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, - -18, -5, -18, -18, 20, -2, -1, -18, -18, 0, - 4, -18, 2, 14, -1, 1, 20, -18, -2, -18, - -18, -18, -18 + -8, -26, 12, -8, -26, 5, -26, -26, 0, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -6, 10, -26, -26, 23, 0, -8, -26, -26, + -26, -26, -26, 3, 7, -26, 6, 8, -8, 14, + 23, -26, 0, -26, -26, -26, -26 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -18, -18, 6, -18, -3, -18, -18, -18, -18, -18, - -17, -14, -18, -18, -18, -18, -18, -18 + -26, -26, -5, -26, -26, -3, -26, -26, -26, -26, + -26, -25, -26, -15, -26, -26, -26, -26, -26, -26 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -594,29 +623,29 @@ static const yytype_int8 yypgoto[] = #define YYTABLE_NINF -1 static const yytype_uint8 yytable[] = { - 7, 9, 10, 11, 12, 13, 14, 15, 31, 1, - 28, 16, 6, 17, 8, 27, 18, 36, 37, 38, - 40, 42, 41, 9, 10, 11, 12, 13, 14, 15, - 39, 7, 34 + 7, 35, 1, 9, 10, 11, 12, 13, 14, 15, + 32, 28, 6, 16, 29, 17, 8, 46, 18, 31, + 40, 41, 38, 42, 43, 45, 9, 10, 11, 12, + 13, 14, 15, 44, 0, 7 }; -static const yytype_uint8 yycheck[] = +static const yytype_int8 yycheck[] = { - 3, 3, 4, 5, 6, 7, 8, 9, 25, 10, - 24, 13, 0, 15, 11, 20, 18, 17, 14, 17, - 19, 38, 36, 3, 4, 5, 6, 7, 8, 9, - 16, 34, 26 + 3, 26, 10, 3, 4, 5, 6, 7, 8, 9, + 25, 17, 0, 13, 20, 15, 11, 42, 18, 9, + 17, 14, 27, 17, 16, 40, 3, 4, 5, 6, + 7, 8, 9, 19, -1, 38 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 10, 23, 24, 26, 27, 0, 26, 11, 3, - 4, 5, 6, 7, 8, 9, 13, 15, 18, 28, - 30, 32, 33, 38, 29, 31, 39, 20, 33, 36, - 37, 32, 34, 35, 24, 25, 17, 14, 17, 16, - 19, 33, 32 + 0, 10, 24, 25, 28, 29, 0, 28, 11, 3, + 4, 5, 6, 7, 8, 9, 13, 15, 18, 30, + 32, 34, 35, 36, 41, 31, 33, 42, 17, 20, + 27, 9, 36, 39, 40, 34, 37, 38, 25, 26, + 17, 14, 17, 16, 19, 36, 34 }; #define yyerrok (yyerrstatus = 0) @@ -649,7 +678,7 @@ do \ } \ else \ { \ - yyerror (scanner, ctx, YY_("syntax error: cannot back up")); \ + yyerror (scanner, ctx, scan_ctx, YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (YYID (0)) @@ -729,7 +758,7 @@ do { \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ - Type, Value, scanner, ctx); \ + Type, Value, scanner, ctx, scan_ctx); \ YYFPRINTF (stderr, "\n"); \ } \ } while (YYID (0)) @@ -743,21 +772,23 @@ do { \ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *scanner, struct parse_context *ctx) +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx) #else static void -yy_symbol_value_print (yyoutput, yytype, yyvaluep, scanner, ctx) +yy_symbol_value_print (yyoutput, yytype, yyvaluep, scanner, ctx, scan_ctx) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; void *scanner; struct parse_context *ctx; + struct scan_context *scan_ctx; #endif { if (!yyvaluep) return; YYUSE (scanner); YYUSE (ctx); + YYUSE (scan_ctx); # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); @@ -779,15 +810,16 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, scanner, ctx) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *scanner, struct parse_context *ctx) +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx) #else static void -yy_symbol_print (yyoutput, yytype, yyvaluep, scanner, ctx) +yy_symbol_print (yyoutput, yytype, yyvaluep, scanner, ctx, scan_ctx) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; void *scanner; struct parse_context *ctx; + struct scan_context *scan_ctx; #endif { if (yytype < YYNTOKENS) @@ -795,7 +827,7 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, scanner, ctx) else YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - yy_symbol_value_print (yyoutput, yytype, yyvaluep, scanner, ctx); + yy_symbol_value_print (yyoutput, yytype, yyvaluep, scanner, ctx, scan_ctx); YYFPRINTF (yyoutput, ")"); } @@ -807,17 +839,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, scanner, ctx) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) #else static void -yy_stack_print (bottom, top) - yytype_int16 *bottom; - yytype_int16 *top; +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; #endif { YYFPRINTF (stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } YYFPRINTF (stderr, "\n"); } @@ -835,14 +870,15 @@ do { \ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_reduce_print (YYSTYPE *yyvsp, int yyrule, void *scanner, struct parse_context *ctx) +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx) #else static void -yy_reduce_print (yyvsp, yyrule, scanner, ctx) +yy_reduce_print (yyvsp, yyrule, scanner, ctx, scan_ctx) YYSTYPE *yyvsp; int yyrule; void *scanner; struct parse_context *ctx; + struct scan_context *scan_ctx; #endif { int yynrhs = yyr2[yyrule]; @@ -853,18 +889,18 @@ yy_reduce_print (yyvsp, yyrule, scanner, ctx) /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { - fprintf (stderr, " $%d = ", yyi + 1); + YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) - , scanner, ctx); - fprintf (stderr, "\n"); + , scanner, ctx, scan_ctx); + YYFPRINTF (stderr, "\n"); } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ - yy_reduce_print (yyvsp, Rule, scanner, ctx); \ + yy_reduce_print (yyvsp, Rule, scanner, ctx, scan_ctx); \ } while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that @@ -1115,20 +1151,22 @@ yysyntax_error (char *yyresult, int yystate, int yychar) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void *scanner, struct parse_context *ctx) +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx) #else static void -yydestruct (yymsg, yytype, yyvaluep, scanner, ctx) +yydestruct (yymsg, yytype, yyvaluep, scanner, ctx, scan_ctx) const char *yymsg; int yytype; YYSTYPE *yyvaluep; void *scanner; struct parse_context *ctx; + struct scan_context *scan_ctx; #endif { YYUSE (yyvaluep); YYUSE (scanner); YYUSE (ctx); + YYUSE (scan_ctx); if (!yymsg) yymsg = "Deleting"; @@ -1141,10 +1179,8 @@ yydestruct (yymsg, yytype, yyvaluep, scanner, ctx) break; } } - /* Prevent warnings from -Wmissing-prototypes. */ - #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); @@ -1153,7 +1189,7 @@ int yyparse (); #endif #else /* ! YYPARSE_PARAM */ #if defined __STDC__ || defined __cplusplus -int yyparse (void *scanner, struct parse_context *ctx); +int yyparse (void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx); #else int yyparse (); #endif @@ -1163,10 +1199,9 @@ int yyparse (); - -/*----------. -| yyparse. | -`----------*/ +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ @@ -1182,83 +1217,85 @@ yyparse (YYPARSE_PARAM) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) int -yyparse (void *scanner, struct parse_context *ctx) +yyparse (void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx) #else int -yyparse (scanner, ctx) +yyparse (scanner, ctx, scan_ctx) void *scanner; struct parse_context *ctx; + struct scan_context *scan_ctx; #endif #endif { - /* The look-ahead symbol. */ +/* The lookahead symbol. */ int yychar; -/* The semantic value of the look-ahead symbol. */ +/* The semantic value of the lookahead symbol. */ YYSTYPE yylval; -/* Number of syntax errors so far. */ -int yynerrs; + /* Number of syntax errors so far. */ + int yynerrs; - int yystate; - int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss = yyssa; - yytype_int16 *yyssp; + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; - YYSIZE_T yystacksize = YYINITDEPTH; + YYSIZE_T yystacksize; + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yystacksize = YYINITDEPTH; + YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ - yyssp = yyss; yyvsp = yyvs; @@ -1288,7 +1325,6 @@ int yynerrs; YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; - /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might @@ -1296,7 +1332,6 @@ int yynerrs; yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); yyss = yyss1; @@ -1319,9 +1354,8 @@ int yynerrs; (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); @@ -1332,7 +1366,6 @@ int yynerrs; yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); @@ -1342,6 +1375,9 @@ int yynerrs; YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + if (yystate == YYFINAL) + YYACCEPT; + goto yybackup; /*-----------. @@ -1350,16 +1386,16 @@ int yynerrs; yybackup: /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ + lookahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to look-ahead token. */ + /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a look-ahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); @@ -1391,20 +1427,16 @@ yybackup: goto yyreduce; } - if (yyn == YYFINAL) - YYACCEPT; - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; - /* Shift the look-ahead token. */ + /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - /* Discard the shifted token unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; + /* Discard the shifted token. */ + yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; @@ -1443,15 +1475,16 @@ yyreduce: YY_REDUCE_PRINT (yyn); switch (yyn) { - case 8: -#line 105 "grammar.y" + case 11: + +/* Line 1455 of yacc.c */ +#line 123 "grammar.y" { ctx->setting = config_setting_add(ctx->parent, (yyvsp[(1) - (1)].sval), CONFIG_TYPE_NONE); - free((yyvsp[(1) - (1)].sval)); - + if(ctx->setting == NULL) { - libconfig_yyerror(scanner, ctx, err_duplicate_setting); + libconfig_yyerror(scanner, ctx, scan_ctx, err_duplicate_setting); YYABORT; } else @@ -1461,8 +1494,10 @@ yyreduce: } break; - case 10: -#line 125 "grammar.y" + case 13: + +/* Line 1455 of yacc.c */ +#line 142 "grammar.y" { if(IN_LIST()) { @@ -1478,16 +1513,20 @@ yyreduce: } break; - case 11: -#line 140 "grammar.y" + case 14: + +/* Line 1455 of yacc.c */ +#line 157 "grammar.y" { if(ctx->parent) - ctx->parent = ctx->parent->parent; + ctx->parent = ctx->parent->parent; } break; - case 12: -#line 148 "grammar.y" + case 15: + +/* Line 1455 of yacc.c */ +#line 165 "grammar.y" { if(IN_LIST()) { @@ -1503,25 +1542,43 @@ yyreduce: } break; - case 13: -#line 163 "grammar.y" + case 16: + +/* Line 1455 of yacc.c */ +#line 180 "grammar.y" { if(ctx->parent) - ctx->parent = ctx->parent->parent; + ctx->parent = ctx->parent->parent; } break; - case 18: -#line 178 "grammar.y" + case 21: + +/* Line 1455 of yacc.c */ +#line 194 "grammar.y" + { parsectx_append_string(ctx, (yyvsp[(1) - (1)].sval)); free((yyvsp[(1) - (1)].sval)); } + break; + + case 22: + +/* Line 1455 of yacc.c */ +#line 195 "grammar.y" + { parsectx_append_string(ctx, (yyvsp[(2) - (2)].sval)); free((yyvsp[(2) - (2)].sval)); } + break; + + case 23: + +/* Line 1455 of yacc.c */ +#line 200 "grammar.y" { if(IN_ARRAY() || IN_LIST()) { config_setting_t *e = config_setting_set_bool_elem(ctx->parent, -1, (int)(yyvsp[(1) - (1)].ival)); - + if(! e) { - libconfig_yyerror(scanner, ctx, err_array_elem_type); + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); YYABORT; } else @@ -1534,15 +1591,17 @@ yyreduce: } break; - case 19: -#line 198 "grammar.y" + case 24: + +/* Line 1455 of yacc.c */ +#line 220 "grammar.y" { if(IN_ARRAY() || IN_LIST()) { config_setting_t *e = config_setting_set_int_elem(ctx->parent, -1, (yyvsp[(1) - (1)].ival)); if(! e) { - libconfig_yyerror(scanner, ctx, err_array_elem_type); + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); YYABORT; } else @@ -1559,15 +1618,17 @@ yyreduce: } break; - case 20: -#line 220 "grammar.y" + case 25: + +/* Line 1455 of yacc.c */ +#line 242 "grammar.y" { if(IN_ARRAY() || IN_LIST()) { config_setting_t *e = config_setting_set_int64_elem(ctx->parent, -1, (yyvsp[(1) - (1)].llval)); if(! e) { - libconfig_yyerror(scanner, ctx, err_array_elem_type); + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); YYABORT; } else @@ -1584,15 +1645,17 @@ yyreduce: } break; - case 21: -#line 242 "grammar.y" + case 26: + +/* Line 1455 of yacc.c */ +#line 264 "grammar.y" { if(IN_ARRAY() || IN_LIST()) { config_setting_t *e = config_setting_set_int_elem(ctx->parent, -1, (yyvsp[(1) - (1)].ival)); if(! e) { - libconfig_yyerror(scanner, ctx, err_array_elem_type); + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); YYABORT; } else @@ -1609,15 +1672,17 @@ yyreduce: } break; - case 22: -#line 264 "grammar.y" + case 27: + +/* Line 1455 of yacc.c */ +#line 286 "grammar.y" { if(IN_ARRAY() || IN_LIST()) { config_setting_t *e = config_setting_set_int64_elem(ctx->parent, -1, (yyvsp[(1) - (1)].llval)); if(! e) { - libconfig_yyerror(scanner, ctx, err_array_elem_type); + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); YYABORT; } else @@ -1634,15 +1699,17 @@ yyreduce: } break; - case 23: -#line 286 "grammar.y" + case 28: + +/* Line 1455 of yacc.c */ +#line 308 "grammar.y" { if(IN_ARRAY() || IN_LIST()) { config_setting_t *e = config_setting_set_float_elem(ctx->parent, -1, (yyvsp[(1) - (1)].fval)); if(! e) { - libconfig_yyerror(scanner, ctx, err_array_elem_type); + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); YYABORT; } else @@ -1655,18 +1722,20 @@ yyreduce: } break; - case 24: -#line 304 "grammar.y" + case 29: + +/* Line 1455 of yacc.c */ +#line 326 "grammar.y" { if(IN_ARRAY() || IN_LIST()) { - config_setting_t *e = config_setting_set_string_elem(ctx->parent, -1, - (yyvsp[(1) - (1)].sval)); - free((yyvsp[(1) - (1)].sval)); - + const char *s = parsectx_take_string(ctx); + config_setting_t *e = config_setting_set_string_elem(ctx->parent, -1, s); + _delete(s); + if(! e) { - libconfig_yyerror(scanner, ctx, err_array_elem_type); + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); YYABORT; } else @@ -1676,14 +1745,17 @@ yyreduce: } else { - config_setting_set_string(ctx->setting, (yyvsp[(1) - (1)].sval)); - free((yyvsp[(1) - (1)].sval)); + const char *s = parsectx_take_string(ctx); + config_setting_set_string(ctx->setting, s); + _delete(s); } } break; - case 33: -#line 351 "grammar.y" + case 38: + +/* Line 1455 of yacc.c */ +#line 374 "grammar.y" { if(IN_LIST()) { @@ -1699,8 +1771,10 @@ yyreduce: } break; - case 34: -#line 366 "grammar.y" + case 39: + +/* Line 1455 of yacc.c */ +#line 389 "grammar.y" { if(ctx->parent) ctx->parent = ctx->parent->parent; @@ -1708,8 +1782,9 @@ yyreduce: break; -/* Line 1267 of yacc.c. */ -#line 1713 "grammar.c" + +/* Line 1455 of yacc.c */ +#line 1788 "grammar.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1720,7 +1795,6 @@ yyreduce: *++yyvsp = yyval; - /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -1745,7 +1819,7 @@ yyerrlab: { ++yynerrs; #if ! YYERROR_VERBOSE - yyerror (scanner, ctx, YY_("syntax error")); + yyerror (scanner, ctx, scan_ctx, YY_("syntax error")); #else { YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); @@ -1769,11 +1843,11 @@ yyerrlab: if (0 < yysize && yysize <= yymsg_alloc) { (void) yysyntax_error (yymsg, yystate, yychar); - yyerror (scanner, ctx, yymsg); + yyerror (scanner, ctx, scan_ctx, yymsg); } else { - yyerror (scanner, ctx, YY_("syntax error")); + yyerror (scanner, ctx, scan_ctx, YY_("syntax error")); if (yysize != 0) goto yyexhaustedlab; } @@ -1785,7 +1859,7 @@ yyerrlab: if (yyerrstatus == 3) { - /* If just tried and failed to reuse look-ahead token after an + /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) @@ -1797,12 +1871,12 @@ yyerrlab: else { yydestruct ("Error: discarding", - yytoken, &yylval, scanner, ctx); + yytoken, &yylval, scanner, ctx, scan_ctx); yychar = YYEMPTY; } } - /* Else will try to reuse look-ahead token after shifting the error + /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; @@ -1853,15 +1927,12 @@ yyerrlab1: yydestruct ("Error: popping", - yystos[yystate], yyvsp, scanner, ctx); + yystos[yystate], yyvsp, scanner, ctx, scan_ctx); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } - if (yyn == YYFINAL) - YYACCEPT; - *++yyvsp = yylval; @@ -1886,20 +1957,20 @@ yyabortlab: yyresult = 1; goto yyreturn; -#ifndef yyoverflow +#if !defined(yyoverflow) || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: - yyerror (scanner, ctx, YY_("memory exhausted")); + yyerror (scanner, ctx, scan_ctx, YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) + if (yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval, scanner, ctx); + yytoken, &yylval, scanner, ctx, scan_ctx); /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); @@ -1907,7 +1978,7 @@ yyreturn: while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp, scanner, ctx); + yystos[*yyssp], yyvsp, scanner, ctx, scan_ctx); YYPOPSTACK (1); } #ifndef yyoverflow @@ -1923,6 +1994,8 @@ yyreturn: } -#line 372 "grammar.y" + +/* Line 1675 of yacc.c */ +#line 395 "grammar.y" |