1 bff58270 2022-09-19 op /* A Bison parser, made by GNU Bison 3.7.6. */
3 bff58270 2022-09-19 op /* Bison implementation for Yacc-like parsers in C
5 bff58270 2022-09-19 op Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
8 bff58270 2022-09-19 op This program is free software: you can redistribute it and/or modify
9 bff58270 2022-09-19 op it under the terms of the GNU General Public License as published by
10 bff58270 2022-09-19 op the Free Software Foundation, either version 3 of the License, or
11 bff58270 2022-09-19 op (at your option) any later version.
13 bff58270 2022-09-19 op This program is distributed in the hope that it will be useful,
14 bff58270 2022-09-19 op but WITHOUT ANY WARRANTY; without even the implied warranty of
15 bff58270 2022-09-19 op MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 bff58270 2022-09-19 op GNU General Public License for more details.
18 bff58270 2022-09-19 op You should have received a copy of the GNU General Public License
19 bff58270 2022-09-19 op along with this program. If not, see <https://www.gnu.org/licenses/>. */
21 bff58270 2022-09-19 op /* As a special exception, you may create a larger work that contains
22 bff58270 2022-09-19 op part or all of the Bison parser skeleton and distribute that work
23 bff58270 2022-09-19 op under terms of your choice, so long as that work isn't itself a
24 bff58270 2022-09-19 op parser generator using the skeleton or a modified version thereof
25 bff58270 2022-09-19 op as a parser skeleton. Alternatively, if you modify or redistribute
26 bff58270 2022-09-19 op the parser skeleton itself, you may (at your option) remove this
27 bff58270 2022-09-19 op special exception, which will cause the skeleton and the resulting
28 bff58270 2022-09-19 op Bison output files to be licensed under the GNU General Public
29 bff58270 2022-09-19 op License without this special exception.
31 bff58270 2022-09-19 op This special exception was added by the Free Software Foundation in
32 bff58270 2022-09-19 op version 2.2 of Bison. */
34 bff58270 2022-09-19 op /* C LALR(1) parser skeleton written by Richard Stallman, by
35 bff58270 2022-09-19 op simplifying the original so-called "semantic" parser. */
37 bff58270 2022-09-19 op /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
38 bff58270 2022-09-19 op especially those whose name start with YY_ or yy_. They are
39 bff58270 2022-09-19 op private implementation details that can be changed or removed. */
41 bff58270 2022-09-19 op /* All symbols defined below should begin with yy or YY, to avoid
42 bff58270 2022-09-19 op infringing on user name space. This should be done even for local
43 bff58270 2022-09-19 op variables, as they might otherwise be expanded by user macros.
44 bff58270 2022-09-19 op There are some unavoidable exceptions within include files to
45 bff58270 2022-09-19 op define necessary library symbols; they are noted "INFRINGES ON
46 bff58270 2022-09-19 op USER NAME SPACE" below. */
48 bff58270 2022-09-19 op /* Identify Bison output, and Bison version. */
49 bff58270 2022-09-19 op #define YYBISON 30706
51 bff58270 2022-09-19 op /* Bison version string. */
52 bff58270 2022-09-19 op #define YYBISON_VERSION "3.7.6"
54 bff58270 2022-09-19 op /* Skeleton name. */
55 bff58270 2022-09-19 op #define YYSKELETON_NAME "yacc.c"
57 bff58270 2022-09-19 op /* Pure parsers. */
58 bff58270 2022-09-19 op #define YYPURE 0
60 bff58270 2022-09-19 op /* Push parsers. */
61 bff58270 2022-09-19 op #define YYPUSH 0
63 bff58270 2022-09-19 op /* Pull parsers. */
64 bff58270 2022-09-19 op #define YYPULL 1
69 bff58270 2022-09-19 op /* First part of user prologue. */
70 bff58270 2022-09-19 op #line 24 "parse.y"
73 bff58270 2022-09-19 op #include <sys/queue.h>
75 bff58270 2022-09-19 op #include <ctype.h>
76 bff58270 2022-09-19 op #include <err.h>
77 bff58270 2022-09-19 op #include <stdio.h>
78 bff58270 2022-09-19 op #include <stdlib.h>
79 bff58270 2022-09-19 op #include <stdarg.h>
80 bff58270 2022-09-19 op #include <stdint.h>
81 bff58270 2022-09-19 op #include <string.h>
82 bff58270 2022-09-19 op #include <unistd.h>
84 bff58270 2022-09-19 op #ifndef nitems
85 bff58270 2022-09-19 op #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
88 bff58270 2022-09-19 op TAILQ_HEAD(files, file) files = TAILQ_HEAD_INITIALIZER(files);
89 bff58270 2022-09-19 op static struct file {
90 bff58270 2022-09-19 op TAILQ_ENTRY(file) entry;
93 bff58270 2022-09-19 op size_t ungetpos;
94 bff58270 2022-09-19 op size_t ungetsize;
95 bff58270 2022-09-19 op u_char *ungetbuf;
96 bff58270 2022-09-19 op int eof_reached;
99 bff58270 2022-09-19 op } *file, *topfile;
100 bff58270 2022-09-19 op int parse(const char *);
101 bff58270 2022-09-19 op struct file *pushfile(const char *, int);
102 bff58270 2022-09-19 op int popfile(void);
103 bff58270 2022-09-19 op int yyparse(void);
104 bff58270 2022-09-19 op int yylex(void);
105 bff58270 2022-09-19 op int yyerror(const char *, ...)
106 bff58270 2022-09-19 op __attribute__((__format__ (printf, 1, 2)))
107 bff58270 2022-09-19 op __attribute__((__nonnull__ (1)));
108 bff58270 2022-09-19 op int kw_cmp(const void *, const void *);
109 bff58270 2022-09-19 op int lookup(char *);
110 bff58270 2022-09-19 op int igetc(void);
111 bff58270 2022-09-19 op int lgetc(int);
112 bff58270 2022-09-19 op void lungetc(int);
113 bff58270 2022-09-19 op int findeol(void);
115 bff58270 2022-09-19 op void dbg(void);
116 bff58270 2022-09-19 op void printq(const char *);
118 bff58270 2022-09-19 op extern int nodebug;
120 bff58270 2022-09-19 op static int block;
121 bff58270 2022-09-19 op static int in_define;
122 bff58270 2022-09-19 op static int errors;
123 bff58270 2022-09-19 op static char lerr[32];
125 bff58270 2022-09-19 op typedef struct {
127 bff58270 2022-09-19 op char *string;
133 bff58270 2022-09-19 op #line 134 "y.tab.c"
135 bff58270 2022-09-19 op # ifndef YY_CAST
136 bff58270 2022-09-19 op # ifdef __cplusplus
137 bff58270 2022-09-19 op # define YY_CAST(Type, Val) static_cast<Type> (Val)
138 bff58270 2022-09-19 op # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
140 bff58270 2022-09-19 op # define YY_CAST(Type, Val) ((Type) (Val))
141 bff58270 2022-09-19 op # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
144 bff58270 2022-09-19 op # ifndef YY_NULLPTR
145 bff58270 2022-09-19 op # if defined __cplusplus
146 bff58270 2022-09-19 op # if 201103L <= __cplusplus
147 bff58270 2022-09-19 op # define YY_NULLPTR nullptr
149 bff58270 2022-09-19 op # define YY_NULLPTR 0
152 bff58270 2022-09-19 op # define YY_NULLPTR ((void*)0)
157 bff58270 2022-09-19 op /* Debug traces. */
158 bff58270 2022-09-19 op #ifndef YYDEBUG
159 bff58270 2022-09-19 op # define YYDEBUG 0
162 bff58270 2022-09-19 op extern int yydebug;
165 bff58270 2022-09-19 op /* Token kinds. */
166 bff58270 2022-09-19 op #ifndef YYTOKENTYPE
167 bff58270 2022-09-19 op # define YYTOKENTYPE
168 bff58270 2022-09-19 op enum yytokentype
170 bff58270 2022-09-19 op YYEMPTY = -2,
171 bff58270 2022-09-19 op YYEOF = 0, /* "end of file" */
172 bff58270 2022-09-19 op YYerror = 256, /* error */
173 bff58270 2022-09-19 op YYUNDEF = 257, /* "invalid token" */
174 bff58270 2022-09-19 op DEFINE = 258, /* DEFINE */
175 bff58270 2022-09-19 op ELSE = 259, /* ELSE */
176 bff58270 2022-09-19 op END = 260, /* END */
177 bff58270 2022-09-19 op ERROR = 261, /* ERROR */
178 bff58270 2022-09-19 op FINALLY = 262, /* FINALLY */
179 bff58270 2022-09-19 op IF = 263, /* IF */
180 bff58270 2022-09-19 op INCLUDE = 264, /* INCLUDE */
181 bff58270 2022-09-19 op RENDER = 265, /* RENDER */
182 bff58270 2022-09-19 op TQFOREACH = 266, /* TQFOREACH */
183 bff58270 2022-09-19 op STRING = 267 /* STRING */
185 bff58270 2022-09-19 op typedef enum yytokentype yytoken_kind_t;
187 bff58270 2022-09-19 op /* Token kinds. */
188 bff58270 2022-09-19 op #define YYEMPTY -2
189 bff58270 2022-09-19 op #define YYEOF 0
190 bff58270 2022-09-19 op #define YYerror 256
191 bff58270 2022-09-19 op #define YYUNDEF 257
192 bff58270 2022-09-19 op #define DEFINE 258
193 bff58270 2022-09-19 op #define ELSE 259
194 bff58270 2022-09-19 op #define END 260
195 bff58270 2022-09-19 op #define ERROR 261
196 bff58270 2022-09-19 op #define FINALLY 262
197 bff58270 2022-09-19 op #define IF 263
198 bff58270 2022-09-19 op #define INCLUDE 264
199 bff58270 2022-09-19 op #define RENDER 265
200 bff58270 2022-09-19 op #define TQFOREACH 266
201 bff58270 2022-09-19 op #define STRING 267
203 bff58270 2022-09-19 op /* Value type. */
206 bff58270 2022-09-19 op extern YYSTYPE yylval;
208 bff58270 2022-09-19 op int yyparse (void);
211 bff58270 2022-09-19 op /* Symbol kind. */
212 bff58270 2022-09-19 op enum yysymbol_kind_t
214 bff58270 2022-09-19 op YYSYMBOL_YYEMPTY = -2,
215 bff58270 2022-09-19 op YYSYMBOL_YYEOF = 0, /* "end of file" */
216 bff58270 2022-09-19 op YYSYMBOL_YYerror = 1, /* error */
217 bff58270 2022-09-19 op YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
218 bff58270 2022-09-19 op YYSYMBOL_DEFINE = 3, /* DEFINE */
219 bff58270 2022-09-19 op YYSYMBOL_ELSE = 4, /* ELSE */
220 bff58270 2022-09-19 op YYSYMBOL_END = 5, /* END */
221 bff58270 2022-09-19 op YYSYMBOL_ERROR = 6, /* ERROR */
222 bff58270 2022-09-19 op YYSYMBOL_FINALLY = 7, /* FINALLY */
223 bff58270 2022-09-19 op YYSYMBOL_IF = 8, /* IF */
224 bff58270 2022-09-19 op YYSYMBOL_INCLUDE = 9, /* INCLUDE */
225 bff58270 2022-09-19 op YYSYMBOL_RENDER = 10, /* RENDER */
226 bff58270 2022-09-19 op YYSYMBOL_TQFOREACH = 11, /* TQFOREACH */
227 bff58270 2022-09-19 op YYSYMBOL_STRING = 12, /* STRING */
228 bff58270 2022-09-19 op YYSYMBOL_13_ = 13, /* '!' */
229 bff58270 2022-09-19 op YYSYMBOL_14_ = 14, /* '{' */
230 bff58270 2022-09-19 op YYSYMBOL_15_ = 15, /* '}' */
231 bff58270 2022-09-19 op YYSYMBOL_YYACCEPT = 16, /* $accept */
232 bff58270 2022-09-19 op YYSYMBOL_grammar = 17, /* grammar */
233 bff58270 2022-09-19 op YYSYMBOL_include = 18, /* include */
234 bff58270 2022-09-19 op YYSYMBOL_verbatim = 19, /* verbatim */
235 bff58270 2022-09-19 op YYSYMBOL_verbatim1 = 20, /* verbatim1 */
236 bff58270 2022-09-19 op YYSYMBOL_verbatims = 21, /* verbatims */
237 bff58270 2022-09-19 op YYSYMBOL_raw = 22, /* raw */
238 bff58270 2022-09-19 op YYSYMBOL_block = 23, /* block */
239 bff58270 2022-09-19 op YYSYMBOL_define = 24, /* define */
240 bff58270 2022-09-19 op YYSYMBOL_body = 25, /* body */
241 bff58270 2022-09-19 op YYSYMBOL_special = 26, /* special */
242 bff58270 2022-09-19 op YYSYMBOL_if = 27, /* if */
243 bff58270 2022-09-19 op YYSYMBOL_endif = 28, /* endif */
244 bff58270 2022-09-19 op YYSYMBOL_elsif = 29, /* elsif */
245 bff58270 2022-09-19 op YYSYMBOL_else = 30, /* else */
246 bff58270 2022-09-19 op YYSYMBOL_loop = 31, /* loop */
247 bff58270 2022-09-19 op YYSYMBOL_32_1 = 32, /* $@1 */
248 bff58270 2022-09-19 op YYSYMBOL_end = 33, /* end */
249 bff58270 2022-09-19 op YYSYMBOL_finally = 34, /* finally */
250 bff58270 2022-09-19 op YYSYMBOL_35_2 = 35, /* $@2 */
251 bff58270 2022-09-19 op YYSYMBOL_string = 36 /* string */
253 bff58270 2022-09-19 op typedef enum yysymbol_kind_t yysymbol_kind_t;
259 bff58270 2022-09-19 op # undef short
262 bff58270 2022-09-19 op /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
263 bff58270 2022-09-19 op <limits.h> and (if available) <stdint.h> are included
264 bff58270 2022-09-19 op so that the code can choose integer types of a good width. */
266 bff58270 2022-09-19 op #ifndef __PTRDIFF_MAX__
267 bff58270 2022-09-19 op # include <limits.h> /* INFRINGES ON USER NAME SPACE */
268 bff58270 2022-09-19 op # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
269 bff58270 2022-09-19 op # include <stdint.h> /* INFRINGES ON USER NAME SPACE */
270 bff58270 2022-09-19 op # define YY_STDINT_H
274 bff58270 2022-09-19 op /* Narrow types that promote to a signed type and that can represent a
275 bff58270 2022-09-19 op signed or unsigned integer of at least N bits. In tables they can
276 bff58270 2022-09-19 op save space and decrease cache pressure. Promoting to a signed type
277 bff58270 2022-09-19 op helps avoid bugs in integer arithmetic. */
279 bff58270 2022-09-19 op #ifdef __INT_LEAST8_MAX__
280 bff58270 2022-09-19 op typedef __INT_LEAST8_TYPE__ yytype_int8;
281 bff58270 2022-09-19 op #elif defined YY_STDINT_H
282 bff58270 2022-09-19 op typedef int_least8_t yytype_int8;
284 bff58270 2022-09-19 op typedef signed char yytype_int8;
287 bff58270 2022-09-19 op #ifdef __INT_LEAST16_MAX__
288 bff58270 2022-09-19 op typedef __INT_LEAST16_TYPE__ yytype_int16;
289 bff58270 2022-09-19 op #elif defined YY_STDINT_H
290 bff58270 2022-09-19 op typedef int_least16_t yytype_int16;
292 bff58270 2022-09-19 op typedef short yytype_int16;
295 bff58270 2022-09-19 op /* Work around bug in HP-UX 11.23, which defines these macros
296 bff58270 2022-09-19 op incorrectly for preprocessor constants. This workaround can likely
297 bff58270 2022-09-19 op be removed in 2023, as HPE has promised support for HP-UX 11.23
298 bff58270 2022-09-19 op (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
299 bff58270 2022-09-19 op <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
300 bff58270 2022-09-19 op #ifdef __hpux
301 bff58270 2022-09-19 op # undef UINT_LEAST8_MAX
302 bff58270 2022-09-19 op # undef UINT_LEAST16_MAX
303 bff58270 2022-09-19 op # define UINT_LEAST8_MAX 255
304 bff58270 2022-09-19 op # define UINT_LEAST16_MAX 65535
307 bff58270 2022-09-19 op #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
308 bff58270 2022-09-19 op typedef __UINT_LEAST8_TYPE__ yytype_uint8;
309 bff58270 2022-09-19 op #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
310 bff58270 2022-09-19 op && UINT_LEAST8_MAX <= INT_MAX)
311 bff58270 2022-09-19 op typedef uint_least8_t yytype_uint8;
312 bff58270 2022-09-19 op #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
313 bff58270 2022-09-19 op typedef unsigned char yytype_uint8;
315 bff58270 2022-09-19 op typedef short yytype_uint8;
318 bff58270 2022-09-19 op #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
319 bff58270 2022-09-19 op typedef __UINT_LEAST16_TYPE__ yytype_uint16;
320 bff58270 2022-09-19 op #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
321 bff58270 2022-09-19 op && UINT_LEAST16_MAX <= INT_MAX)
322 bff58270 2022-09-19 op typedef uint_least16_t yytype_uint16;
323 bff58270 2022-09-19 op #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
324 bff58270 2022-09-19 op typedef unsigned short yytype_uint16;
326 bff58270 2022-09-19 op typedef int yytype_uint16;
329 bff58270 2022-09-19 op #ifndef YYPTRDIFF_T
330 bff58270 2022-09-19 op # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
331 bff58270 2022-09-19 op # define YYPTRDIFF_T __PTRDIFF_TYPE__
332 bff58270 2022-09-19 op # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
333 bff58270 2022-09-19 op # elif defined PTRDIFF_MAX
334 bff58270 2022-09-19 op # ifndef ptrdiff_t
335 bff58270 2022-09-19 op # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
337 bff58270 2022-09-19 op # define YYPTRDIFF_T ptrdiff_t
338 bff58270 2022-09-19 op # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
340 bff58270 2022-09-19 op # define YYPTRDIFF_T long
341 bff58270 2022-09-19 op # define YYPTRDIFF_MAXIMUM LONG_MAX
345 bff58270 2022-09-19 op #ifndef YYSIZE_T
346 bff58270 2022-09-19 op # ifdef __SIZE_TYPE__
347 bff58270 2022-09-19 op # define YYSIZE_T __SIZE_TYPE__
348 bff58270 2022-09-19 op # elif defined size_t
349 bff58270 2022-09-19 op # define YYSIZE_T size_t
350 bff58270 2022-09-19 op # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
351 bff58270 2022-09-19 op # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
352 bff58270 2022-09-19 op # define YYSIZE_T size_t
354 bff58270 2022-09-19 op # define YYSIZE_T unsigned
358 bff58270 2022-09-19 op #define YYSIZE_MAXIMUM \
359 bff58270 2022-09-19 op YY_CAST (YYPTRDIFF_T, \
360 bff58270 2022-09-19 op (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
361 bff58270 2022-09-19 op ? YYPTRDIFF_MAXIMUM \
362 bff58270 2022-09-19 op : YY_CAST (YYSIZE_T, -1)))
364 bff58270 2022-09-19 op #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
367 bff58270 2022-09-19 op /* Stored state numbers (used for stacks). */
368 bff58270 2022-09-19 op typedef yytype_int8 yy_state_t;
370 bff58270 2022-09-19 op /* State numbers in computations. */
371 bff58270 2022-09-19 op typedef int yy_state_fast_t;
374 bff58270 2022-09-19 op # if defined YYENABLE_NLS && YYENABLE_NLS
375 bff58270 2022-09-19 op # if ENABLE_NLS
376 bff58270 2022-09-19 op # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
377 bff58270 2022-09-19 op # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
381 bff58270 2022-09-19 op # define YY_(Msgid) Msgid
386 bff58270 2022-09-19 op #ifndef YY_ATTRIBUTE_PURE
387 bff58270 2022-09-19 op # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
388 bff58270 2022-09-19 op # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
390 bff58270 2022-09-19 op # define YY_ATTRIBUTE_PURE
394 bff58270 2022-09-19 op #ifndef YY_ATTRIBUTE_UNUSED
395 bff58270 2022-09-19 op # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
396 bff58270 2022-09-19 op # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
398 bff58270 2022-09-19 op # define YY_ATTRIBUTE_UNUSED
402 bff58270 2022-09-19 op /* Suppress unused-variable warnings by "using" E. */
403 bff58270 2022-09-19 op #if ! defined lint || defined __GNUC__
404 bff58270 2022-09-19 op # define YY_USE(E) ((void) (E))
406 bff58270 2022-09-19 op # define YY_USE(E) /* empty */
409 bff58270 2022-09-19 op #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
410 bff58270 2022-09-19 op /* Suppress an incorrect diagnostic about yylval being uninitialized. */
411 bff58270 2022-09-19 op # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
412 bff58270 2022-09-19 op _Pragma ("GCC diagnostic push") \
413 bff58270 2022-09-19 op _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
414 bff58270 2022-09-19 op _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
415 bff58270 2022-09-19 op # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
416 bff58270 2022-09-19 op _Pragma ("GCC diagnostic pop")
418 bff58270 2022-09-19 op # define YY_INITIAL_VALUE(Value) Value
420 bff58270 2022-09-19 op #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
421 bff58270 2022-09-19 op # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
422 bff58270 2022-09-19 op # define YY_IGNORE_MAYBE_UNINITIALIZED_END
424 bff58270 2022-09-19 op #ifndef YY_INITIAL_VALUE
425 bff58270 2022-09-19 op # define YY_INITIAL_VALUE(Value) /* Nothing. */
428 bff58270 2022-09-19 op #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
429 bff58270 2022-09-19 op # define YY_IGNORE_USELESS_CAST_BEGIN \
430 bff58270 2022-09-19 op _Pragma ("GCC diagnostic push") \
431 bff58270 2022-09-19 op _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
432 bff58270 2022-09-19 op # define YY_IGNORE_USELESS_CAST_END \
433 bff58270 2022-09-19 op _Pragma ("GCC diagnostic pop")
435 bff58270 2022-09-19 op #ifndef YY_IGNORE_USELESS_CAST_BEGIN
436 bff58270 2022-09-19 op # define YY_IGNORE_USELESS_CAST_BEGIN
437 bff58270 2022-09-19 op # define YY_IGNORE_USELESS_CAST_END
441 bff58270 2022-09-19 op #define YY_ASSERT(E) ((void) (0 && (E)))
443 bff58270 2022-09-19 op #if !defined yyoverflow
445 bff58270 2022-09-19 op /* The parser invokes alloca or malloc; define the necessary symbols. */
447 bff58270 2022-09-19 op # ifdef YYSTACK_USE_ALLOCA
448 bff58270 2022-09-19 op # if YYSTACK_USE_ALLOCA
449 bff58270 2022-09-19 op # ifdef __GNUC__
450 bff58270 2022-09-19 op # define YYSTACK_ALLOC __builtin_alloca
451 bff58270 2022-09-19 op # elif defined __BUILTIN_VA_ARG_INCR
452 bff58270 2022-09-19 op # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
453 bff58270 2022-09-19 op # elif defined _AIX
454 bff58270 2022-09-19 op # define YYSTACK_ALLOC __alloca
455 bff58270 2022-09-19 op # elif defined _MSC_VER
456 bff58270 2022-09-19 op # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
457 bff58270 2022-09-19 op # define alloca _alloca
459 bff58270 2022-09-19 op # define YYSTACK_ALLOC alloca
460 bff58270 2022-09-19 op # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
461 bff58270 2022-09-19 op # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
462 bff58270 2022-09-19 op /* Use EXIT_SUCCESS as a witness for stdlib.h. */
463 bff58270 2022-09-19 op # ifndef EXIT_SUCCESS
464 bff58270 2022-09-19 op # define EXIT_SUCCESS 0
471 bff58270 2022-09-19 op # ifdef YYSTACK_ALLOC
472 bff58270 2022-09-19 op /* Pacify GCC's 'empty if-body' warning. */
473 bff58270 2022-09-19 op # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
474 bff58270 2022-09-19 op # ifndef YYSTACK_ALLOC_MAXIMUM
475 bff58270 2022-09-19 op /* The OS might guarantee only one guard page at the bottom of the stack,
476 bff58270 2022-09-19 op and a page size can be as small as 4096 bytes. So we cannot safely
477 bff58270 2022-09-19 op invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
478 bff58270 2022-09-19 op to allow for a few compiler-allocated temporary stack slots. */
479 bff58270 2022-09-19 op # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
482 bff58270 2022-09-19 op # define YYSTACK_ALLOC YYMALLOC
483 bff58270 2022-09-19 op # define YYSTACK_FREE YYFREE
484 bff58270 2022-09-19 op # ifndef YYSTACK_ALLOC_MAXIMUM
485 bff58270 2022-09-19 op # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
487 bff58270 2022-09-19 op # if (defined __cplusplus && ! defined EXIT_SUCCESS \
488 bff58270 2022-09-19 op && ! ((defined YYMALLOC || defined malloc) \
489 bff58270 2022-09-19 op && (defined YYFREE || defined free)))
490 bff58270 2022-09-19 op # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
491 bff58270 2022-09-19 op # ifndef EXIT_SUCCESS
492 bff58270 2022-09-19 op # define EXIT_SUCCESS 0
495 bff58270 2022-09-19 op # ifndef YYMALLOC
496 bff58270 2022-09-19 op # define YYMALLOC malloc
497 bff58270 2022-09-19 op # if ! defined malloc && ! defined EXIT_SUCCESS
498 bff58270 2022-09-19 op void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
501 bff58270 2022-09-19 op # ifndef YYFREE
502 bff58270 2022-09-19 op # define YYFREE free
503 bff58270 2022-09-19 op # if ! defined free && ! defined EXIT_SUCCESS
504 bff58270 2022-09-19 op void free (void *); /* INFRINGES ON USER NAME SPACE */
508 bff58270 2022-09-19 op #endif /* !defined yyoverflow */
510 bff58270 2022-09-19 op #if (! defined yyoverflow \
511 bff58270 2022-09-19 op && (! defined __cplusplus \
512 bff58270 2022-09-19 op || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
514 bff58270 2022-09-19 op /* A type that is properly aligned for any stack member. */
515 bff58270 2022-09-19 op union yyalloc
517 bff58270 2022-09-19 op yy_state_t yyss_alloc;
518 bff58270 2022-09-19 op YYSTYPE yyvs_alloc;
521 bff58270 2022-09-19 op /* The size of the maximum gap between one aligned stack and the next. */
522 bff58270 2022-09-19 op # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
524 bff58270 2022-09-19 op /* The size of an array large to enough to hold all stacks, each with
525 bff58270 2022-09-19 op N elements. */
526 bff58270 2022-09-19 op # define YYSTACK_BYTES(N) \
527 bff58270 2022-09-19 op ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
528 bff58270 2022-09-19 op + YYSTACK_GAP_MAXIMUM)
530 bff58270 2022-09-19 op # define YYCOPY_NEEDED 1
532 bff58270 2022-09-19 op /* Relocate STACK from its old location to the new one. The
533 bff58270 2022-09-19 op local variables YYSIZE and YYSTACKSIZE give the old and new number of
534 bff58270 2022-09-19 op elements in the stack, and YYPTR gives the new location of the
535 bff58270 2022-09-19 op stack. Advance YYPTR to a properly aligned location for the next
537 bff58270 2022-09-19 op # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
540 bff58270 2022-09-19 op YYPTRDIFF_T yynewbytes; \
541 bff58270 2022-09-19 op YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
542 bff58270 2022-09-19 op Stack = &yyptr->Stack_alloc; \
543 bff58270 2022-09-19 op yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
544 bff58270 2022-09-19 op yyptr += yynewbytes / YYSIZEOF (*yyptr); \
550 bff58270 2022-09-19 op #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
551 bff58270 2022-09-19 op /* Copy COUNT objects from SRC to DST. The source and destination do
552 bff58270 2022-09-19 op not overlap. */
553 bff58270 2022-09-19 op # ifndef YYCOPY
554 bff58270 2022-09-19 op # if defined __GNUC__ && 1 < __GNUC__
555 bff58270 2022-09-19 op # define YYCOPY(Dst, Src, Count) \
556 bff58270 2022-09-19 op __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
558 bff58270 2022-09-19 op # define YYCOPY(Dst, Src, Count) \
561 bff58270 2022-09-19 op YYPTRDIFF_T yyi; \
562 bff58270 2022-09-19 op for (yyi = 0; yyi < (Count); yyi++) \
563 bff58270 2022-09-19 op (Dst)[yyi] = (Src)[yyi]; \
568 bff58270 2022-09-19 op #endif /* !YYCOPY_NEEDED */
570 bff58270 2022-09-19 op /* YYFINAL -- State number of the termination state. */
571 bff58270 2022-09-19 op #define YYFINAL 2
572 bff58270 2022-09-19 op /* YYLAST -- Last index in YYTABLE. */
573 bff58270 2022-09-19 op #define YYLAST 69
575 bff58270 2022-09-19 op /* YYNTOKENS -- Number of terminals. */
576 bff58270 2022-09-19 op #define YYNTOKENS 16
577 bff58270 2022-09-19 op /* YYNNTS -- Number of nonterminals. */
578 bff58270 2022-09-19 op #define YYNNTS 21
579 bff58270 2022-09-19 op /* YYNRULES -- Number of rules. */
580 bff58270 2022-09-19 op #define YYNRULES 37
581 bff58270 2022-09-19 op /* YYNSTATES -- Number of states. */
582 bff58270 2022-09-19 op #define YYNSTATES 71
584 bff58270 2022-09-19 op /* YYMAXUTOK -- Last valid token kind. */
585 bff58270 2022-09-19 op #define YYMAXUTOK 267
588 bff58270 2022-09-19 op /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
589 bff58270 2022-09-19 op as returned by yylex, with out-of-bounds checking. */
590 bff58270 2022-09-19 op #define YYTRANSLATE(YYX) \
591 bff58270 2022-09-19 op (0 <= (YYX) && (YYX) <= YYMAXUTOK \
592 bff58270 2022-09-19 op ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
593 bff58270 2022-09-19 op : YYSYMBOL_YYUNDEF)
595 bff58270 2022-09-19 op /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
596 bff58270 2022-09-19 op as returned by yylex. */
597 bff58270 2022-09-19 op static const yytype_int8 yytranslate[] =
599 bff58270 2022-09-19 op 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
600 bff58270 2022-09-19 op 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
601 bff58270 2022-09-19 op 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
602 bff58270 2022-09-19 op 2, 2, 2, 13, 2, 2, 2, 2, 2, 2,
603 bff58270 2022-09-19 op 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
604 bff58270 2022-09-19 op 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
605 bff58270 2022-09-19 op 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
606 bff58270 2022-09-19 op 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
607 bff58270 2022-09-19 op 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
608 bff58270 2022-09-19 op 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
609 bff58270 2022-09-19 op 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
610 bff58270 2022-09-19 op 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
611 bff58270 2022-09-19 op 2, 2, 2, 14, 2, 15, 2, 2, 2, 2,
612 bff58270 2022-09-19 op 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
613 bff58270 2022-09-19 op 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
614 bff58270 2022-09-19 op 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
615 bff58270 2022-09-19 op 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
616 bff58270 2022-09-19 op 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
617 bff58270 2022-09-19 op 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
618 bff58270 2022-09-19 op 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
619 bff58270 2022-09-19 op 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
620 bff58270 2022-09-19 op 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
621 bff58270 2022-09-19 op 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
622 bff58270 2022-09-19 op 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
623 bff58270 2022-09-19 op 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
624 bff58270 2022-09-19 op 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
625 bff58270 2022-09-19 op 5, 6, 7, 8, 9, 10, 11, 12
629 bff58270 2022-09-19 op /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
630 bff58270 2022-09-19 op static const yytype_uint8 yyrline[] =
632 bff58270 2022-09-19 op 0, 93, 93, 94, 95, 96, 97, 100, 115, 122,
633 bff58270 2022-09-19 op 123, 132, 133, 136, 146, 152, 159, 171, 172, 173,
634 bff58270 2022-09-19 op 174, 177, 187, 188, 189, 196, 203, 204, 205, 208,
635 bff58270 2022-09-19 op 215, 221, 221, 232, 235, 235, 241, 247
639 bff58270 2022-09-19 op /** Accessing symbol of state STATE. */
640 bff58270 2022-09-19 op #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
642 bff58270 2022-09-19 op #if YYDEBUG || 0
643 bff58270 2022-09-19 op /* The user-facing name of the symbol whose (internal) number is
644 bff58270 2022-09-19 op YYSYMBOL. No bounds checking. */
645 bff58270 2022-09-19 op static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
647 bff58270 2022-09-19 op /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
648 bff58270 2022-09-19 op First, the terminals, then, starting at YYNTOKENS, nonterminals. */
649 bff58270 2022-09-19 op static const char *const yytname[] =
651 bff58270 2022-09-19 op "\"end of file\"", "error", "\"invalid token\"", "DEFINE", "ELSE",
652 bff58270 2022-09-19 op "END", "ERROR", "FINALLY", "IF", "INCLUDE", "RENDER", "TQFOREACH",
653 bff58270 2022-09-19 op "STRING", "'!'", "'{'", "'}'", "$accept", "grammar", "include",
654 bff58270 2022-09-19 op "verbatim", "verbatim1", "verbatims", "raw", "block", "define", "body",
655 bff58270 2022-09-19 op "special", "if", "endif", "elsif", "else", "loop", "$@1", "end",
656 bff58270 2022-09-19 op "finally", "$@2", "string", YY_NULLPTR
659 bff58270 2022-09-19 op static const char *
660 bff58270 2022-09-19 op yysymbol_name (yysymbol_kind_t yysymbol)
662 bff58270 2022-09-19 op return yytname[yysymbol];
666 bff58270 2022-09-19 op #ifdef YYPRINT
667 bff58270 2022-09-19 op /* YYTOKNUM[NUM] -- (External) token number corresponding to the
668 bff58270 2022-09-19 op (internal) symbol number NUM (which must be that of a token). */
669 bff58270 2022-09-19 op static const yytype_int16 yytoknum[] =
671 bff58270 2022-09-19 op 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
672 bff58270 2022-09-19 op 265, 266, 267, 33, 123, 125
676 bff58270 2022-09-19 op #define YYPACT_NINF (-21)
678 bff58270 2022-09-19 op #define yypact_value_is_default(Yyn) \
679 bff58270 2022-09-19 op ((Yyn) == YYPACT_NINF)
681 bff58270 2022-09-19 op #define YYTABLE_NINF (-1)
683 bff58270 2022-09-19 op #define yytable_value_is_error(Yyn) \
686 bff58270 2022-09-19 op /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
687 bff58270 2022-09-19 op STATE-NUM. */
688 bff58270 2022-09-19 op static const yytype_int8 yypact[] =
690 bff58270 2022-09-19 op -21, 5, -21, -21, 4, -21, 14, -21, -21, -21,
691 bff58270 2022-09-19 op -21, -21, 0, 8, -3, -21, -21, 8, 6, -21,
692 bff58270 2022-09-19 op 29, -21, -21, -21, -21, -21, -21, 10, -21, -21,
693 bff58270 2022-09-19 op 15, 20, 8, 8, 26, 27, 41, 38, -21, -21,
694 bff58270 2022-09-19 op -21, 31, 47, 49, -21, 21, -21, -21, -21, -21,
695 bff58270 2022-09-19 op -21, -21, -21, 51, -7, 41, 46, 52, 53, 8,
696 bff58270 2022-09-19 op -21, -21, 40, -21, -21, -21, 54, -21, -21, 46,
700 bff58270 2022-09-19 op /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
701 bff58270 2022-09-19 op Performed when YYTABLE does not specify something else to do. Zero
702 bff58270 2022-09-19 op means the default is an error. */
703 bff58270 2022-09-19 op static const yytype_int8 yydefact[] =
705 bff58270 2022-09-19 op 2, 0, 1, 6, 0, 9, 0, 3, 4, 5,
706 bff58270 2022-09-19 op 17, 7, 0, 0, 0, 10, 8, 37, 0, 13,
707 bff58270 2022-09-19 op 0, 18, 19, 20, 17, 23, 14, 0, 36, 16,
708 bff58270 2022-09-19 op 0, 0, 0, 0, 0, 0, 0, 0, 15, 33,
709 bff58270 2022-09-19 op 34, 0, 0, 0, 24, 0, 22, 17, 17, 26,
710 bff58270 2022-09-19 op 11, 25, 21, 0, 0, 0, 0, 35, 0, 0,
711 bff58270 2022-09-19 op 30, 28, 0, 27, 12, 31, 0, 17, 29, 0,
715 bff58270 2022-09-19 op /* YYPGOTO[NTERM-NUM]. */
716 bff58270 2022-09-19 op static const yytype_int8 yypgoto[] =
718 bff58270 2022-09-19 op -21, -21, -21, -1, -21, -21, -21, -21, -21, -20,
719 bff58270 2022-09-19 op -21, -21, 9, -21, -21, -21, -21, -12, -21, -21,
723 bff58270 2022-09-19 op /* YYDEFGOTO[NTERM-NUM]. */
724 bff58270 2022-09-19 op static const yytype_int8 yydefgoto[] =
726 bff58270 2022-09-19 op 0, 1, 7, 21, 12, 57, 22, 9, 10, 14,
727 bff58270 2022-09-19 op 23, 24, 46, 47, 48, 25, 67, 49, 27, 50,
731 bff58270 2022-09-19 op /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
732 bff58270 2022-09-19 op positive, shift that token. If negative, reduce the rule whose
733 bff58270 2022-09-19 op number is the opposite. If YYTABLE_NINF, syntax error. */
734 bff58270 2022-09-19 op static const yytype_int8 yytable[] =
736 bff58270 2022-09-19 op 8, 59, 26, 18, 36, 2, 3, 28, 60, 19,
737 bff58270 2022-09-19 op 5, 20, 15, 16, 4, 38, 11, 13, 5, 6,
738 bff58270 2022-09-19 op 17, 29, 41, 42, 37, 54, 30, 55, 56, 32,
739 bff58270 2022-09-19 op 39, 33, 34, 17, 30, 40, 31, 32, 43, 33,
740 bff58270 2022-09-19 op 34, 17, 44, 30, 63, 30, 51, 69, 32, 66,
741 bff58270 2022-09-19 op 33, 34, 17, 19, 5, 45, 64, 70, 19, 5,
742 bff58270 2022-09-19 op 62, 53, 52, 58, 61, 5, 0, 0, 65, 68
745 bff58270 2022-09-19 op static const yytype_int8 yycheck[] =
747 bff58270 2022-09-19 op 1, 8, 14, 13, 24, 0, 1, 17, 15, 12,
748 bff58270 2022-09-19 op 13, 14, 12, 13, 9, 27, 12, 3, 13, 14,
749 bff58270 2022-09-19 op 12, 15, 32, 33, 14, 4, 5, 47, 48, 8,
750 bff58270 2022-09-19 op 15, 10, 11, 12, 5, 15, 7, 8, 12, 10,
751 bff58270 2022-09-19 op 11, 12, 15, 5, 56, 5, 15, 67, 8, 59,
752 bff58270 2022-09-19 op 10, 11, 12, 12, 13, 14, 57, 69, 12, 13,
753 bff58270 2022-09-19 op 14, 12, 15, 12, 55, 13, -1, -1, 15, 15
756 bff58270 2022-09-19 op /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
757 bff58270 2022-09-19 op symbol of state STATE-NUM. */
758 bff58270 2022-09-19 op static const yytype_int8 yystos[] =
760 bff58270 2022-09-19 op 0, 17, 0, 1, 9, 13, 14, 18, 19, 23,
761 bff58270 2022-09-19 op 24, 12, 20, 3, 25, 12, 13, 12, 36, 12,
762 bff58270 2022-09-19 op 14, 19, 22, 26, 27, 31, 33, 34, 36, 15,
763 bff58270 2022-09-19 op 5, 7, 8, 10, 11, 36, 25, 14, 33, 15,
764 bff58270 2022-09-19 op 15, 36, 36, 12, 15, 14, 28, 29, 30, 33,
765 bff58270 2022-09-19 op 35, 15, 15, 12, 4, 25, 25, 21, 12, 8,
766 bff58270 2022-09-19 op 15, 28, 14, 33, 19, 15, 36, 32, 15, 25,
770 bff58270 2022-09-19 op /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
771 bff58270 2022-09-19 op static const yytype_int8 yyr1[] =
773 bff58270 2022-09-19 op 0, 16, 17, 17, 17, 17, 17, 18, 19, 20,
774 bff58270 2022-09-19 op 20, 21, 21, 22, 23, 23, 24, 25, 25, 25,
775 bff58270 2022-09-19 op 25, 26, 26, 26, 26, 27, 28, 28, 28, 29,
776 bff58270 2022-09-19 op 30, 32, 31, 33, 35, 34, 36, 36
779 bff58270 2022-09-19 op /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
780 bff58270 2022-09-19 op static const yytype_int8 yyr2[] =
782 bff58270 2022-09-19 op 0, 2, 0, 2, 2, 2, 2, 2, 3, 0,
783 bff58270 2022-09-19 op 2, 0, 2, 1, 3, 4, 4, 0, 2, 2,
784 bff58270 2022-09-19 op 2, 4, 3, 1, 3, 4, 1, 3, 3, 5,
785 bff58270 2022-09-19 op 3, 0, 9, 3, 0, 5, 2, 1
789 bff58270 2022-09-19 op enum { YYENOMEM = -2 };
791 bff58270 2022-09-19 op #define yyerrok (yyerrstatus = 0)
792 bff58270 2022-09-19 op #define yyclearin (yychar = YYEMPTY)
794 bff58270 2022-09-19 op #define YYACCEPT goto yyacceptlab
795 bff58270 2022-09-19 op #define YYABORT goto yyabortlab
796 bff58270 2022-09-19 op #define YYERROR goto yyerrorlab
799 bff58270 2022-09-19 op #define YYRECOVERING() (!!yyerrstatus)
801 bff58270 2022-09-19 op #define YYBACKUP(Token, Value) \
803 bff58270 2022-09-19 op if (yychar == YYEMPTY) \
805 bff58270 2022-09-19 op yychar = (Token); \
806 bff58270 2022-09-19 op yylval = (Value); \
807 bff58270 2022-09-19 op YYPOPSTACK (yylen); \
808 bff58270 2022-09-19 op yystate = *yyssp; \
809 bff58270 2022-09-19 op goto yybackup; \
813 bff58270 2022-09-19 op yyerror (YY_("syntax error: cannot back up")); \
818 bff58270 2022-09-19 op /* Backward compatibility with an undocumented macro.
819 bff58270 2022-09-19 op Use YYerror or YYUNDEF. */
820 bff58270 2022-09-19 op #define YYERRCODE YYUNDEF
823 bff58270 2022-09-19 op /* Enable debugging if requested. */
826 bff58270 2022-09-19 op # ifndef YYFPRINTF
827 bff58270 2022-09-19 op # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
828 bff58270 2022-09-19 op # define YYFPRINTF fprintf
831 bff58270 2022-09-19 op # define YYDPRINTF(Args) \
833 bff58270 2022-09-19 op if (yydebug) \
834 bff58270 2022-09-19 op YYFPRINTF Args; \
837 bff58270 2022-09-19 op /* This macro is provided for backward compatibility. */
838 bff58270 2022-09-19 op # ifndef YY_LOCATION_PRINT
839 bff58270 2022-09-19 op # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
843 bff58270 2022-09-19 op # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
845 bff58270 2022-09-19 op if (yydebug) \
847 bff58270 2022-09-19 op YYFPRINTF (stderr, "%s ", Title); \
848 bff58270 2022-09-19 op yy_symbol_print (stderr, \
849 bff58270 2022-09-19 op Kind, Value); \
850 bff58270 2022-09-19 op YYFPRINTF (stderr, "\n"); \
855 bff58270 2022-09-19 op /*-----------------------------------.
856 bff58270 2022-09-19 op | Print this symbol's value on YYO. |
857 bff58270 2022-09-19 op `-----------------------------------*/
860 bff58270 2022-09-19 op yy_symbol_value_print (FILE *yyo,
861 bff58270 2022-09-19 op yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
863 bff58270 2022-09-19 op FILE *yyoutput = yyo;
864 bff58270 2022-09-19 op YY_USE (yyoutput);
865 bff58270 2022-09-19 op if (!yyvaluep)
867 bff58270 2022-09-19 op # ifdef YYPRINT
868 bff58270 2022-09-19 op if (yykind < YYNTOKENS)
869 bff58270 2022-09-19 op YYPRINT (yyo, yytoknum[yykind], *yyvaluep);
871 bff58270 2022-09-19 op YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
872 bff58270 2022-09-19 op YY_USE (yykind);
873 bff58270 2022-09-19 op YY_IGNORE_MAYBE_UNINITIALIZED_END
877 bff58270 2022-09-19 op /*---------------------------.
878 bff58270 2022-09-19 op | Print this symbol on YYO. |
879 bff58270 2022-09-19 op `---------------------------*/
882 bff58270 2022-09-19 op yy_symbol_print (FILE *yyo,
883 bff58270 2022-09-19 op yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
885 bff58270 2022-09-19 op YYFPRINTF (yyo, "%s %s (",
886 bff58270 2022-09-19 op yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
888 bff58270 2022-09-19 op yy_symbol_value_print (yyo, yykind, yyvaluep);
889 bff58270 2022-09-19 op YYFPRINTF (yyo, ")");
892 bff58270 2022-09-19 op /*------------------------------------------------------------------.
893 bff58270 2022-09-19 op | yy_stack_print -- Print the state stack from its BOTTOM up to its |
894 bff58270 2022-09-19 op | TOP (included). |
895 bff58270 2022-09-19 op `------------------------------------------------------------------*/
898 bff58270 2022-09-19 op yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
900 bff58270 2022-09-19 op YYFPRINTF (stderr, "Stack now");
901 bff58270 2022-09-19 op for (; yybottom <= yytop; yybottom++)
903 bff58270 2022-09-19 op int yybot = *yybottom;
904 bff58270 2022-09-19 op YYFPRINTF (stderr, " %d", yybot);
906 bff58270 2022-09-19 op YYFPRINTF (stderr, "\n");
909 bff58270 2022-09-19 op # define YY_STACK_PRINT(Bottom, Top) \
911 bff58270 2022-09-19 op if (yydebug) \
912 bff58270 2022-09-19 op yy_stack_print ((Bottom), (Top)); \
916 bff58270 2022-09-19 op /*------------------------------------------------.
917 bff58270 2022-09-19 op | Report that the YYRULE is going to be reduced. |
918 bff58270 2022-09-19 op `------------------------------------------------*/
921 bff58270 2022-09-19 op yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
924 bff58270 2022-09-19 op int yylno = yyrline[yyrule];
925 bff58270 2022-09-19 op int yynrhs = yyr2[yyrule];
927 bff58270 2022-09-19 op YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
928 bff58270 2022-09-19 op yyrule - 1, yylno);
929 bff58270 2022-09-19 op /* The symbols being reduced. */
930 bff58270 2022-09-19 op for (yyi = 0; yyi < yynrhs; yyi++)
932 bff58270 2022-09-19 op YYFPRINTF (stderr, " $%d = ", yyi + 1);
933 bff58270 2022-09-19 op yy_symbol_print (stderr,
934 bff58270 2022-09-19 op YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
935 bff58270 2022-09-19 op &yyvsp[(yyi + 1) - (yynrhs)]);
936 bff58270 2022-09-19 op YYFPRINTF (stderr, "\n");
940 bff58270 2022-09-19 op # define YY_REDUCE_PRINT(Rule) \
942 bff58270 2022-09-19 op if (yydebug) \
943 bff58270 2022-09-19 op yy_reduce_print (yyssp, yyvsp, Rule); \
946 bff58270 2022-09-19 op /* Nonzero means print parse trace. It is left uninitialized so that
947 bff58270 2022-09-19 op multiple parsers can coexist. */
949 bff58270 2022-09-19 op #else /* !YYDEBUG */
950 bff58270 2022-09-19 op # define YYDPRINTF(Args) ((void) 0)
951 bff58270 2022-09-19 op # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
952 bff58270 2022-09-19 op # define YY_STACK_PRINT(Bottom, Top)
953 bff58270 2022-09-19 op # define YY_REDUCE_PRINT(Rule)
954 bff58270 2022-09-19 op #endif /* !YYDEBUG */
957 bff58270 2022-09-19 op /* YYINITDEPTH -- initial size of the parser's stacks. */
958 bff58270 2022-09-19 op #ifndef YYINITDEPTH
959 bff58270 2022-09-19 op # define YYINITDEPTH 200
962 bff58270 2022-09-19 op /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
963 bff58270 2022-09-19 op if the built-in stack extension method is used).
965 bff58270 2022-09-19 op Do not make this value too large; the results are undefined if
966 bff58270 2022-09-19 op YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
967 bff58270 2022-09-19 op evaluated with infinite-precision integer arithmetic. */
969 bff58270 2022-09-19 op #ifndef YYMAXDEPTH
970 bff58270 2022-09-19 op # define YYMAXDEPTH 10000
978 bff58270 2022-09-19 op /*-----------------------------------------------.
979 bff58270 2022-09-19 op | Release the memory associated to this symbol. |
980 bff58270 2022-09-19 op `-----------------------------------------------*/
983 bff58270 2022-09-19 op yydestruct (const char *yymsg,
984 bff58270 2022-09-19 op yysymbol_kind_t yykind, YYSTYPE *yyvaluep)
986 bff58270 2022-09-19 op YY_USE (yyvaluep);
988 bff58270 2022-09-19 op yymsg = "Deleting";
989 bff58270 2022-09-19 op YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
991 bff58270 2022-09-19 op YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
992 bff58270 2022-09-19 op YY_USE (yykind);
993 bff58270 2022-09-19 op YY_IGNORE_MAYBE_UNINITIALIZED_END
997 bff58270 2022-09-19 op /* Lookahead token kind. */
1000 bff58270 2022-09-19 op /* The semantic value of the lookahead symbol. */
1001 bff58270 2022-09-19 op YYSTYPE yylval;
1002 bff58270 2022-09-19 op /* Number of syntax errors so far. */
1003 bff58270 2022-09-19 op int yynerrs;
1008 bff58270 2022-09-19 op /*----------.
1009 bff58270 2022-09-19 op | yyparse. |
1010 bff58270 2022-09-19 op `----------*/
1013 bff58270 2022-09-19 op yyparse (void)
1015 bff58270 2022-09-19 op yy_state_fast_t yystate = 0;
1016 bff58270 2022-09-19 op /* Number of tokens to shift before error messages enabled. */
1017 bff58270 2022-09-19 op int yyerrstatus = 0;
1019 bff58270 2022-09-19 op /* Refer to the stacks through separate pointers, to allow yyoverflow
1020 bff58270 2022-09-19 op to reallocate them elsewhere. */
1022 bff58270 2022-09-19 op /* Their size. */
1023 bff58270 2022-09-19 op YYPTRDIFF_T yystacksize = YYINITDEPTH;
1025 bff58270 2022-09-19 op /* The state stack: array, bottom, top. */
1026 bff58270 2022-09-19 op yy_state_t yyssa[YYINITDEPTH];
1027 bff58270 2022-09-19 op yy_state_t *yyss = yyssa;
1028 bff58270 2022-09-19 op yy_state_t *yyssp = yyss;
1030 bff58270 2022-09-19 op /* The semantic value stack: array, bottom, top. */
1031 bff58270 2022-09-19 op YYSTYPE yyvsa[YYINITDEPTH];
1032 bff58270 2022-09-19 op YYSTYPE *yyvs = yyvsa;
1033 bff58270 2022-09-19 op YYSTYPE *yyvsp = yyvs;
1036 bff58270 2022-09-19 op /* The return value of yyparse. */
1037 bff58270 2022-09-19 op int yyresult;
1038 bff58270 2022-09-19 op /* Lookahead symbol kind. */
1039 bff58270 2022-09-19 op yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
1040 bff58270 2022-09-19 op /* The variables used to return semantic value and location from the
1041 bff58270 2022-09-19 op action routines. */
1042 bff58270 2022-09-19 op YYSTYPE yyval;
1046 bff58270 2022-09-19 op #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1048 bff58270 2022-09-19 op /* The number of symbols on the RHS of the reduced rule.
1049 bff58270 2022-09-19 op Keep to zero when no symbol should be popped. */
1050 bff58270 2022-09-19 op int yylen = 0;
1052 bff58270 2022-09-19 op YYDPRINTF ((stderr, "Starting parse\n"));
1054 bff58270 2022-09-19 op yychar = YYEMPTY; /* Cause a token to be read. */
1055 bff58270 2022-09-19 op goto yysetstate;
1058 bff58270 2022-09-19 op /*------------------------------------------------------------.
1059 bff58270 2022-09-19 op | yynewstate -- push a new state, which is found in yystate. |
1060 bff58270 2022-09-19 op `------------------------------------------------------------*/
1062 bff58270 2022-09-19 op /* In all cases, when you get here, the value and location stacks
1063 bff58270 2022-09-19 op have just been pushed. So pushing a state here evens the stacks. */
1067 bff58270 2022-09-19 op /*--------------------------------------------------------------------.
1068 bff58270 2022-09-19 op | yysetstate -- set current state (the top of the stack) to yystate. |
1069 bff58270 2022-09-19 op `--------------------------------------------------------------------*/
1071 bff58270 2022-09-19 op YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1072 bff58270 2022-09-19 op YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1073 bff58270 2022-09-19 op YY_IGNORE_USELESS_CAST_BEGIN
1074 bff58270 2022-09-19 op *yyssp = YY_CAST (yy_state_t, yystate);
1075 bff58270 2022-09-19 op YY_IGNORE_USELESS_CAST_END
1076 bff58270 2022-09-19 op YY_STACK_PRINT (yyss, yyssp);
1078 bff58270 2022-09-19 op if (yyss + yystacksize - 1 <= yyssp)
1079 bff58270 2022-09-19 op #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1080 bff58270 2022-09-19 op goto yyexhaustedlab;
1083 bff58270 2022-09-19 op /* Get the current used size of the three stacks, in elements. */
1084 bff58270 2022-09-19 op YYPTRDIFF_T yysize = yyssp - yyss + 1;
1086 bff58270 2022-09-19 op # if defined yyoverflow
1088 bff58270 2022-09-19 op /* Give user a chance to reallocate the stack. Use copies of
1089 bff58270 2022-09-19 op these so that the &'s don't force the real ones into
1091 bff58270 2022-09-19 op yy_state_t *yyss1 = yyss;
1092 bff58270 2022-09-19 op YYSTYPE *yyvs1 = yyvs;
1094 bff58270 2022-09-19 op /* Each stack pointer address is followed by the size of the
1095 bff58270 2022-09-19 op data in use in that stack, in bytes. This used to be a
1096 bff58270 2022-09-19 op conditional around just the two extra args, but that might
1097 bff58270 2022-09-19 op be undefined if yyoverflow is a macro. */
1098 bff58270 2022-09-19 op yyoverflow (YY_("memory exhausted"),
1099 bff58270 2022-09-19 op &yyss1, yysize * YYSIZEOF (*yyssp),
1100 bff58270 2022-09-19 op &yyvs1, yysize * YYSIZEOF (*yyvsp),
1101 bff58270 2022-09-19 op &yystacksize);
1102 bff58270 2022-09-19 op yyss = yyss1;
1103 bff58270 2022-09-19 op yyvs = yyvs1;
1105 bff58270 2022-09-19 op # else /* defined YYSTACK_RELOCATE */
1106 bff58270 2022-09-19 op /* Extend the stack our own way. */
1107 bff58270 2022-09-19 op if (YYMAXDEPTH <= yystacksize)
1108 bff58270 2022-09-19 op goto yyexhaustedlab;
1109 bff58270 2022-09-19 op yystacksize *= 2;
1110 bff58270 2022-09-19 op if (YYMAXDEPTH < yystacksize)
1111 bff58270 2022-09-19 op yystacksize = YYMAXDEPTH;
1114 bff58270 2022-09-19 op yy_state_t *yyss1 = yyss;
1115 bff58270 2022-09-19 op union yyalloc *yyptr =
1116 bff58270 2022-09-19 op YY_CAST (union yyalloc *,
1117 bff58270 2022-09-19 op YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
1118 bff58270 2022-09-19 op if (! yyptr)
1119 bff58270 2022-09-19 op goto yyexhaustedlab;
1120 bff58270 2022-09-19 op YYSTACK_RELOCATE (yyss_alloc, yyss);
1121 bff58270 2022-09-19 op YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1122 bff58270 2022-09-19 op # undef YYSTACK_RELOCATE
1123 bff58270 2022-09-19 op if (yyss1 != yyssa)
1124 bff58270 2022-09-19 op YYSTACK_FREE (yyss1);
1128 bff58270 2022-09-19 op yyssp = yyss + yysize - 1;
1129 bff58270 2022-09-19 op yyvsp = yyvs + yysize - 1;
1131 bff58270 2022-09-19 op YY_IGNORE_USELESS_CAST_BEGIN
1132 bff58270 2022-09-19 op YYDPRINTF ((stderr, "Stack size increased to %ld\n",
1133 bff58270 2022-09-19 op YY_CAST (long, yystacksize)));
1134 bff58270 2022-09-19 op YY_IGNORE_USELESS_CAST_END
1136 bff58270 2022-09-19 op if (yyss + yystacksize - 1 <= yyssp)
1139 bff58270 2022-09-19 op #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1141 bff58270 2022-09-19 op if (yystate == YYFINAL)
1144 bff58270 2022-09-19 op goto yybackup;
1147 bff58270 2022-09-19 op /*-----------.
1148 bff58270 2022-09-19 op | yybackup. |
1149 bff58270 2022-09-19 op `-----------*/
1151 bff58270 2022-09-19 op /* Do appropriate processing given the current state. Read a
1152 bff58270 2022-09-19 op lookahead token if we need one and don't already have one. */
1154 bff58270 2022-09-19 op /* First try to decide what to do without reference to lookahead token. */
1155 bff58270 2022-09-19 op yyn = yypact[yystate];
1156 bff58270 2022-09-19 op if (yypact_value_is_default (yyn))
1157 bff58270 2022-09-19 op goto yydefault;
1159 bff58270 2022-09-19 op /* Not known => get a lookahead token if don't already have one. */
1161 bff58270 2022-09-19 op /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1162 bff58270 2022-09-19 op if (yychar == YYEMPTY)
1164 bff58270 2022-09-19 op YYDPRINTF ((stderr, "Reading a token\n"));
1165 bff58270 2022-09-19 op yychar = yylex ();
1168 bff58270 2022-09-19 op if (yychar <= YYEOF)
1170 bff58270 2022-09-19 op yychar = YYEOF;
1171 bff58270 2022-09-19 op yytoken = YYSYMBOL_YYEOF;
1172 bff58270 2022-09-19 op YYDPRINTF ((stderr, "Now at end of input.\n"));
1174 bff58270 2022-09-19 op else if (yychar == YYerror)
1176 bff58270 2022-09-19 op /* The scanner already issued an error message, process directly
1177 bff58270 2022-09-19 op to error recovery. But do not keep the error token as
1178 bff58270 2022-09-19 op lookahead, it is too special and may lead us to an endless
1179 bff58270 2022-09-19 op loop in error recovery. */
1180 bff58270 2022-09-19 op yychar = YYUNDEF;
1181 bff58270 2022-09-19 op yytoken = YYSYMBOL_YYerror;
1182 bff58270 2022-09-19 op goto yyerrlab1;
1186 bff58270 2022-09-19 op yytoken = YYTRANSLATE (yychar);
1187 bff58270 2022-09-19 op YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1190 bff58270 2022-09-19 op /* If the proper action on seeing token YYTOKEN is to reduce or to
1191 bff58270 2022-09-19 op detect an error, take that action. */
1192 bff58270 2022-09-19 op yyn += yytoken;
1193 bff58270 2022-09-19 op if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1194 bff58270 2022-09-19 op goto yydefault;
1195 bff58270 2022-09-19 op yyn = yytable[yyn];
1196 bff58270 2022-09-19 op if (yyn <= 0)
1198 bff58270 2022-09-19 op if (yytable_value_is_error (yyn))
1199 bff58270 2022-09-19 op goto yyerrlab;
1201 bff58270 2022-09-19 op goto yyreduce;
1204 bff58270 2022-09-19 op /* Count tokens shifted since error; after three, turn off error
1206 bff58270 2022-09-19 op if (yyerrstatus)
1207 bff58270 2022-09-19 op yyerrstatus--;
1209 bff58270 2022-09-19 op /* Shift the lookahead token. */
1210 bff58270 2022-09-19 op YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1211 bff58270 2022-09-19 op yystate = yyn;
1212 bff58270 2022-09-19 op YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1213 bff58270 2022-09-19 op *++yyvsp = yylval;
1214 bff58270 2022-09-19 op YY_IGNORE_MAYBE_UNINITIALIZED_END
1216 bff58270 2022-09-19 op /* Discard the shifted token. */
1217 bff58270 2022-09-19 op yychar = YYEMPTY;
1218 bff58270 2022-09-19 op goto yynewstate;
1221 bff58270 2022-09-19 op /*-----------------------------------------------------------.
1222 bff58270 2022-09-19 op | yydefault -- do the default action for the current state. |
1223 bff58270 2022-09-19 op `-----------------------------------------------------------*/
1225 bff58270 2022-09-19 op yyn = yydefact[yystate];
1226 bff58270 2022-09-19 op if (yyn == 0)
1227 bff58270 2022-09-19 op goto yyerrlab;
1228 bff58270 2022-09-19 op goto yyreduce;
1231 bff58270 2022-09-19 op /*-----------------------------.
1232 bff58270 2022-09-19 op | yyreduce -- do a reduction. |
1233 bff58270 2022-09-19 op `-----------------------------*/
1235 bff58270 2022-09-19 op /* yyn is the number of a rule to reduce with. */
1236 bff58270 2022-09-19 op yylen = yyr2[yyn];
1238 bff58270 2022-09-19 op /* If YYLEN is nonzero, implement the default value of the action:
1241 bff58270 2022-09-19 op Otherwise, the following line sets YYVAL to garbage.
1242 bff58270 2022-09-19 op This behavior is undocumented and Bison
1243 bff58270 2022-09-19 op users should not rely upon it. Assigning to YYVAL
1244 bff58270 2022-09-19 op unconditionally makes the parser a bit smaller, and it avoids a
1245 bff58270 2022-09-19 op GCC warning that YYVAL may be used uninitialized. */
1246 bff58270 2022-09-19 op yyval = yyvsp[1-yylen];
1249 bff58270 2022-09-19 op YY_REDUCE_PRINT (yyn);
1250 bff58270 2022-09-19 op switch (yyn)
1252 bff58270 2022-09-19 op case 6: /* grammar: grammar error */
1253 bff58270 2022-09-19 op #line 97 "parse.y"
1254 bff58270 2022-09-19 op { file->errors++; }
1255 bff58270 2022-09-19 op #line 1256 "y.tab.c"
1258 bff58270 2022-09-19 op case 7: /* include: INCLUDE STRING */
1259 bff58270 2022-09-19 op #line 100 "parse.y"
1261 bff58270 2022-09-19 op struct file *nfile;
1263 bff58270 2022-09-19 op if ((nfile = pushfile((yyvsp[0].v.string), 0)) == NULL) {
1264 bff58270 2022-09-19 op yyerror("failed to include file %s", (yyvsp[0].v.string));
1265 bff58270 2022-09-19 op free((yyvsp[0].v.string));
1268 bff58270 2022-09-19 op free((yyvsp[0].v.string));
1270 bff58270 2022-09-19 op file = nfile;
1271 bff58270 2022-09-19 op lungetc('\n');
1273 bff58270 2022-09-19 op #line 1274 "y.tab.c"
1276 bff58270 2022-09-19 op case 8: /* verbatim: '!' verbatim1 '!' */
1277 bff58270 2022-09-19 op #line 115 "parse.y"
1279 bff58270 2022-09-19 op if (in_define) {
1280 bff58270 2022-09-19 op /* TODO: check template status and exit in case */
1283 bff58270 2022-09-19 op #line 1284 "y.tab.c"
1286 bff58270 2022-09-19 op case 10: /* verbatim1: verbatim1 STRING */
1287 bff58270 2022-09-19 op #line 123 "parse.y"
1289 bff58270 2022-09-19 op if (*(yyvsp[0].v.string) != '\0') {
1291 bff58270 2022-09-19 op puts((yyvsp[0].v.string));
1293 bff58270 2022-09-19 op free((yyvsp[0].v.string));
1295 bff58270 2022-09-19 op #line 1296 "y.tab.c"
1298 bff58270 2022-09-19 op case 13: /* raw: STRING */
1299 bff58270 2022-09-19 op #line 136 "parse.y"
1302 bff58270 2022-09-19 op printf("if (tp->tp_puts(tp, ");
1303 bff58270 2022-09-19 op printq((yyvsp[0].v.string));
1304 bff58270 2022-09-19 op printf(") == -1) goto %s;\n", lerr);
1306 bff58270 2022-09-19 op free((yyvsp[0].v.string));
1308 bff58270 2022-09-19 op #line 1309 "y.tab.c"
1311 bff58270 2022-09-19 op case 14: /* block: define body end */
1312 bff58270 2022-09-19 op #line 146 "parse.y"
1314 bff58270 2022-09-19 op printf("%s:\n", lerr);
1315 bff58270 2022-09-19 op puts("return tp->tp_ret;");
1317 bff58270 2022-09-19 op in_define = 0;
1319 bff58270 2022-09-19 op #line 1320 "y.tab.c"
1322 bff58270 2022-09-19 op case 15: /* block: define body finally end */
1323 bff58270 2022-09-19 op #line 152 "parse.y"
1325 bff58270 2022-09-19 op puts("return tp->tp_ret;");
1327 bff58270 2022-09-19 op in_define = 0;
1329 bff58270 2022-09-19 op #line 1330 "y.tab.c"
1332 bff58270 2022-09-19 op case 16: /* define: '{' DEFINE string '}' */
1333 bff58270 2022-09-19 op #line 159 "parse.y"
1335 bff58270 2022-09-19 op in_define = 1;
1336 bff58270 2022-09-19 op (void)snprintf(lerr, sizeof(lerr), "err%llu",
1337 bff58270 2022-09-19 op (unsigned long long)arc4random());
1340 bff58270 2022-09-19 op printf("int\n%s\n{\n", (yyvsp[-1].v.string));
1342 bff58270 2022-09-19 op free((yyvsp[-1].v.string));
1344 bff58270 2022-09-19 op #line 1345 "y.tab.c"
1347 bff58270 2022-09-19 op case 21: /* special: '{' RENDER string '}' */
1348 bff58270 2022-09-19 op #line 177 "parse.y"
1351 bff58270 2022-09-19 op if (strrchr((yyvsp[-1].v.string), ')') != NULL)
1352 bff58270 2022-09-19 op printf("if (%s == -1) goto %s;\n",
1353 bff58270 2022-09-19 op (yyvsp[-1].v.string), lerr);
1355 bff58270 2022-09-19 op printf("if (%s != NULL && %s(tp) == -1) "
1356 bff58270 2022-09-19 op "goto %s;\n", (yyvsp[-1].v.string), (yyvsp[-1].v.string), lerr);
1357 bff58270 2022-09-19 op free((yyvsp[-1].v.string));
1359 bff58270 2022-09-19 op #line 1360 "y.tab.c"
1362 bff58270 2022-09-19 op case 22: /* special: if body endif */
1363 bff58270 2022-09-19 op #line 187 "parse.y"
1364 bff58270 2022-09-19 op { puts("}"); }
1365 bff58270 2022-09-19 op #line 1366 "y.tab.c"
1368 bff58270 2022-09-19 op case 24: /* special: '{' string '}' */
1369 bff58270 2022-09-19 op #line 189 "parse.y"
1372 bff58270 2022-09-19 op printf("if (tp->tp_escape(tp, %s) == -1) goto %s;\n",
1373 bff58270 2022-09-19 op (yyvsp[-1].v.string), lerr);
1375 bff58270 2022-09-19 op #line 1376 "y.tab.c"
1378 bff58270 2022-09-19 op case 25: /* if: '{' IF string '}' */
1379 bff58270 2022-09-19 op #line 196 "parse.y"
1382 bff58270 2022-09-19 op printf("if (%s) {\n", (yyvsp[-1].v.string));
1383 bff58270 2022-09-19 op free((yyvsp[-1].v.string));
1385 bff58270 2022-09-19 op #line 1386 "y.tab.c"
1388 bff58270 2022-09-19 op case 29: /* elsif: '{' ELSE IF string '}' */
1389 bff58270 2022-09-19 op #line 208 "parse.y"
1392 bff58270 2022-09-19 op printf("} else if (%s) {\n", (yyvsp[-1].v.string));
1393 bff58270 2022-09-19 op free((yyvsp[-1].v.string));
1395 bff58270 2022-09-19 op #line 1396 "y.tab.c"
1398 bff58270 2022-09-19 op case 30: /* else: '{' ELSE '}' */
1399 bff58270 2022-09-19 op #line 215 "parse.y"
1402 bff58270 2022-09-19 op puts("} else {");
1404 bff58270 2022-09-19 op #line 1405 "y.tab.c"
1407 bff58270 2022-09-19 op case 31: /* $@1: %empty */
1408 bff58270 2022-09-19 op #line 221 "parse.y"
1410 bff58270 2022-09-19 op printf("TAILQ_FOREACH(%s, %s, %s) {\n",
1411 bff58270 2022-09-19 op (yyvsp[-3].v.string), (yyvsp[-2].v.string), (yyvsp[-1].v.string));
1412 bff58270 2022-09-19 op free((yyvsp[-3].v.string));
1413 bff58270 2022-09-19 op free((yyvsp[-2].v.string));
1414 bff58270 2022-09-19 op free((yyvsp[-1].v.string));
1416 bff58270 2022-09-19 op #line 1417 "y.tab.c"
1419 bff58270 2022-09-19 op case 32: /* loop: '{' TQFOREACH STRING STRING STRING '}' $@1 body end */
1420 bff58270 2022-09-19 op #line 227 "parse.y"
1424 bff58270 2022-09-19 op #line 1425 "y.tab.c"
1427 bff58270 2022-09-19 op case 34: /* $@2: %empty */
1428 bff58270 2022-09-19 op #line 235 "parse.y"
1431 bff58270 2022-09-19 op printf("%s:\n", lerr);
1433 bff58270 2022-09-19 op #line 1434 "y.tab.c"
1436 bff58270 2022-09-19 op case 36: /* string: STRING string */
1437 bff58270 2022-09-19 op #line 241 "parse.y"
1439 bff58270 2022-09-19 op if (asprintf(&(yyval.v.string), "%s %s", (yyvsp[-1].v.string), (yyvsp[0].v.string)) == -1)
1440 bff58270 2022-09-19 op err(1, "asprintf");
1441 bff58270 2022-09-19 op free((yyvsp[-1].v.string));
1442 bff58270 2022-09-19 op free((yyvsp[0].v.string));
1444 bff58270 2022-09-19 op #line 1445 "y.tab.c"
1448 bff58270 2022-09-19 op #line 1449 "y.tab.c"
1450 bff58270 2022-09-19 op default: break;
1452 bff58270 2022-09-19 op /* User semantic actions sometimes alter yychar, and that requires
1453 bff58270 2022-09-19 op that yytoken be updated with the new translation. We take the
1454 bff58270 2022-09-19 op approach of translating immediately before every use of yytoken.
1455 bff58270 2022-09-19 op One alternative is translating here after every semantic action,
1456 bff58270 2022-09-19 op but that translation would be missed if the semantic action invokes
1457 bff58270 2022-09-19 op YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1458 bff58270 2022-09-19 op if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1459 bff58270 2022-09-19 op incorrect destructor might then be invoked immediately. In the
1460 bff58270 2022-09-19 op case of YYERROR or YYBACKUP, subsequent parser actions might lead
1461 bff58270 2022-09-19 op to an incorrect destructor call or verbose syntax error message
1462 bff58270 2022-09-19 op before the lookahead is translated. */
1463 bff58270 2022-09-19 op YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
1465 bff58270 2022-09-19 op YYPOPSTACK (yylen);
1468 bff58270 2022-09-19 op *++yyvsp = yyval;
1470 bff58270 2022-09-19 op /* Now 'shift' the result of the reduction. Determine what state
1471 bff58270 2022-09-19 op that goes to, based on the state we popped back to and the rule
1472 bff58270 2022-09-19 op number reduced by. */
1474 bff58270 2022-09-19 op const int yylhs = yyr1[yyn] - YYNTOKENS;
1475 bff58270 2022-09-19 op const int yyi = yypgoto[yylhs] + *yyssp;
1476 bff58270 2022-09-19 op yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
1477 bff58270 2022-09-19 op ? yytable[yyi]
1478 bff58270 2022-09-19 op : yydefgoto[yylhs]);
1481 bff58270 2022-09-19 op goto yynewstate;
1484 bff58270 2022-09-19 op /*--------------------------------------.
1485 bff58270 2022-09-19 op | yyerrlab -- here on detecting error. |
1486 bff58270 2022-09-19 op `--------------------------------------*/
1488 bff58270 2022-09-19 op /* Make sure we have latest lookahead translation. See comments at
1489 bff58270 2022-09-19 op user semantic actions for why this is necessary. */
1490 bff58270 2022-09-19 op yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
1491 bff58270 2022-09-19 op /* If not already recovering from an error, report this error. */
1492 bff58270 2022-09-19 op if (!yyerrstatus)
1495 bff58270 2022-09-19 op yyerror (YY_("syntax error"));
1498 bff58270 2022-09-19 op if (yyerrstatus == 3)
1500 bff58270 2022-09-19 op /* If just tried and failed to reuse lookahead token after an
1501 bff58270 2022-09-19 op error, discard it. */
1503 bff58270 2022-09-19 op if (yychar <= YYEOF)
1505 bff58270 2022-09-19 op /* Return failure if at end of input. */
1506 bff58270 2022-09-19 op if (yychar == YYEOF)
1511 bff58270 2022-09-19 op yydestruct ("Error: discarding",
1512 bff58270 2022-09-19 op yytoken, &yylval);
1513 bff58270 2022-09-19 op yychar = YYEMPTY;
1517 bff58270 2022-09-19 op /* Else will try to reuse lookahead token after shifting the error
1519 bff58270 2022-09-19 op goto yyerrlab1;
1522 bff58270 2022-09-19 op /*---------------------------------------------------.
1523 bff58270 2022-09-19 op | yyerrorlab -- error raised explicitly by YYERROR. |
1524 bff58270 2022-09-19 op `---------------------------------------------------*/
1526 bff58270 2022-09-19 op /* Pacify compilers when the user code never invokes YYERROR and the
1527 bff58270 2022-09-19 op label yyerrorlab therefore never appears in user code. */
1531 bff58270 2022-09-19 op /* Do not reclaim the symbols of the rule whose action triggered
1532 bff58270 2022-09-19 op this YYERROR. */
1533 bff58270 2022-09-19 op YYPOPSTACK (yylen);
1535 bff58270 2022-09-19 op YY_STACK_PRINT (yyss, yyssp);
1536 bff58270 2022-09-19 op yystate = *yyssp;
1537 bff58270 2022-09-19 op goto yyerrlab1;
1540 bff58270 2022-09-19 op /*-------------------------------------------------------------.
1541 bff58270 2022-09-19 op | yyerrlab1 -- common code for both syntax error and YYERROR. |
1542 bff58270 2022-09-19 op `-------------------------------------------------------------*/
1544 bff58270 2022-09-19 op yyerrstatus = 3; /* Each real token shifted decrements this. */
1546 bff58270 2022-09-19 op /* Pop stack until we find a state that shifts the error token. */
1549 bff58270 2022-09-19 op yyn = yypact[yystate];
1550 bff58270 2022-09-19 op if (!yypact_value_is_default (yyn))
1552 bff58270 2022-09-19 op yyn += YYSYMBOL_YYerror;
1553 bff58270 2022-09-19 op if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
1555 bff58270 2022-09-19 op yyn = yytable[yyn];
1556 bff58270 2022-09-19 op if (0 < yyn)
1561 bff58270 2022-09-19 op /* Pop the current state because it cannot handle the error token. */
1562 bff58270 2022-09-19 op if (yyssp == yyss)
1566 bff58270 2022-09-19 op yydestruct ("Error: popping",
1567 bff58270 2022-09-19 op YY_ACCESSING_SYMBOL (yystate), yyvsp);
1568 bff58270 2022-09-19 op YYPOPSTACK (1);
1569 bff58270 2022-09-19 op yystate = *yyssp;
1570 bff58270 2022-09-19 op YY_STACK_PRINT (yyss, yyssp);
1573 bff58270 2022-09-19 op YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1574 bff58270 2022-09-19 op *++yyvsp = yylval;
1575 bff58270 2022-09-19 op YY_IGNORE_MAYBE_UNINITIALIZED_END
1578 bff58270 2022-09-19 op /* Shift the error token. */
1579 bff58270 2022-09-19 op YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
1581 bff58270 2022-09-19 op yystate = yyn;
1582 bff58270 2022-09-19 op goto yynewstate;
1585 bff58270 2022-09-19 op /*-------------------------------------.
1586 bff58270 2022-09-19 op | yyacceptlab -- YYACCEPT comes here. |
1587 bff58270 2022-09-19 op `-------------------------------------*/
1588 bff58270 2022-09-19 op yyacceptlab:
1589 bff58270 2022-09-19 op yyresult = 0;
1590 bff58270 2022-09-19 op goto yyreturn;
1593 bff58270 2022-09-19 op /*-----------------------------------.
1594 bff58270 2022-09-19 op | yyabortlab -- YYABORT comes here. |
1595 bff58270 2022-09-19 op `-----------------------------------*/
1597 bff58270 2022-09-19 op yyresult = 1;
1598 bff58270 2022-09-19 op goto yyreturn;
1601 bff58270 2022-09-19 op #if !defined yyoverflow
1602 bff58270 2022-09-19 op /*-------------------------------------------------.
1603 bff58270 2022-09-19 op | yyexhaustedlab -- memory exhaustion comes here. |
1604 bff58270 2022-09-19 op `-------------------------------------------------*/
1605 bff58270 2022-09-19 op yyexhaustedlab:
1606 bff58270 2022-09-19 op yyerror (YY_("memory exhausted"));
1607 bff58270 2022-09-19 op yyresult = 2;
1608 bff58270 2022-09-19 op goto yyreturn;
1612 bff58270 2022-09-19 op /*-------------------------------------------------------.
1613 bff58270 2022-09-19 op | yyreturn -- parsing is finished, clean up and return. |
1614 bff58270 2022-09-19 op `-------------------------------------------------------*/
1616 bff58270 2022-09-19 op if (yychar != YYEMPTY)
1618 bff58270 2022-09-19 op /* Make sure we have latest lookahead translation. See comments at
1619 bff58270 2022-09-19 op user semantic actions for why this is necessary. */
1620 bff58270 2022-09-19 op yytoken = YYTRANSLATE (yychar);
1621 bff58270 2022-09-19 op yydestruct ("Cleanup: discarding lookahead",
1622 bff58270 2022-09-19 op yytoken, &yylval);
1624 bff58270 2022-09-19 op /* Do not reclaim the symbols of the rule whose action triggered
1625 bff58270 2022-09-19 op this YYABORT or YYACCEPT. */
1626 bff58270 2022-09-19 op YYPOPSTACK (yylen);
1627 bff58270 2022-09-19 op YY_STACK_PRINT (yyss, yyssp);
1628 bff58270 2022-09-19 op while (yyssp != yyss)
1630 bff58270 2022-09-19 op yydestruct ("Cleanup: popping",
1631 bff58270 2022-09-19 op YY_ACCESSING_SYMBOL (+*yyssp), yyvsp);
1632 bff58270 2022-09-19 op YYPOPSTACK (1);
1634 bff58270 2022-09-19 op #ifndef yyoverflow
1635 bff58270 2022-09-19 op if (yyss != yyssa)
1636 bff58270 2022-09-19 op YYSTACK_FREE (yyss);
1639 bff58270 2022-09-19 op return yyresult;
1642 bff58270 2022-09-19 op #line 250 "parse.y"
1645 bff58270 2022-09-19 op struct keywords {
1646 bff58270 2022-09-19 op const char *k_name;
1651 bff58270 2022-09-19 op yyerror(const char *fmt, ...)
1656 bff58270 2022-09-19 op file->errors++;
1657 bff58270 2022-09-19 op va_start(ap, fmt);
1658 bff58270 2022-09-19 op if (vasprintf(&msg, fmt, ap) == -1)
1659 bff58270 2022-09-19 op err(1, "yyerror vasprintf");
1661 bff58270 2022-09-19 op fprintf(stderr, "%s:%d: %s\n", file->name, yylval.lineno, msg);
1667 bff58270 2022-09-19 op kw_cmp(const void *k, const void *e)
1669 bff58270 2022-09-19 op return (strcmp(k, ((const struct keywords *)e)->k_name));
1673 bff58270 2022-09-19 op lookup(char *s)
1675 bff58270 2022-09-19 op /* this has to be sorted always */
1676 bff58270 2022-09-19 op static const struct keywords keywords[] = {
1677 bff58270 2022-09-19 op { "define", DEFINE },
1678 bff58270 2022-09-19 op { "else", ELSE },
1679 bff58270 2022-09-19 op { "end", END },
1680 bff58270 2022-09-19 op { "finally", FINALLY },
1681 bff58270 2022-09-19 op { "if", IF },
1682 bff58270 2022-09-19 op { "include", INCLUDE },
1683 bff58270 2022-09-19 op { "render", RENDER },
1684 bff58270 2022-09-19 op { "tailq-foreach", TQFOREACH },
1686 bff58270 2022-09-19 op const struct keywords *p;
1688 bff58270 2022-09-19 op p = bsearch(s, keywords, nitems(keywords), sizeof(keywords[0]),
1692 bff58270 2022-09-19 op return (p->k_val);
1694 bff58270 2022-09-19 op return (STRING);
1697 bff58270 2022-09-19 op #define START_EXPAND 1
1698 bff58270 2022-09-19 op #define DONE_EXPAND 2
1700 bff58270 2022-09-19 op static int expanding;
1708 bff58270 2022-09-19 op if (file->ungetpos > 0)
1709 bff58270 2022-09-19 op c = file->ungetbuf[--file->ungetpos];
1711 bff58270 2022-09-19 op c = getc(file->stream);
1713 bff58270 2022-09-19 op if (c == START_EXPAND)
1714 bff58270 2022-09-19 op expanding = 1;
1715 bff58270 2022-09-19 op else if (c == DONE_EXPAND)
1716 bff58270 2022-09-19 op expanding = 0;
1724 bff58270 2022-09-19 op lgetc(int quotec)
1726 bff58270 2022-09-19 op int c, next;
1728 bff58270 2022-09-19 op if (quotec) {
1729 bff58270 2022-09-19 op if ((c = igetc()) == EOF) {
1730 bff58270 2022-09-19 op yyerror("reached end of filewhile parsing "
1731 bff58270 2022-09-19 op "quoted string");
1732 bff58270 2022-09-19 op if (file == topfile || popfile() == EOF)
1733 bff58270 2022-09-19 op return (EOF);
1734 bff58270 2022-09-19 op return (quotec);
1739 bff58270 2022-09-19 op while ((c = igetc()) == '\\') {
1740 bff58270 2022-09-19 op next = igetc();
1741 bff58270 2022-09-19 op if (next != '\n') {
1745 bff58270 2022-09-19 op yylval.lineno = file->lineno;
1746 bff58270 2022-09-19 op file->lineno++;
1748 bff58270 2022-09-19 op if (c == '\t' || c == ' ') {
1749 bff58270 2022-09-19 op /* Compress blanks to a sigle space. */
1751 bff58270 2022-09-19 op c = getc(file->stream);
1752 bff58270 2022-09-19 op } while (c == '\t' || c == ' ');
1753 bff58270 2022-09-19 op ungetc(c, file->stream);
1757 bff58270 2022-09-19 op if (c == EOF) {
1759 bff58270 2022-09-19 op * Fake EOL when hit EOF for the first time. This gets line
1760 bff58270 2022-09-19 op * count rigchtif last line included file is syntactically
1761 bff58270 2022-09-19 op * invalid and has no newline.
1763 bff58270 2022-09-19 op if (file->eof_reached == 0) {
1764 bff58270 2022-09-19 op file->eof_reached = 1;
1765 bff58270 2022-09-19 op return ('\n');
1767 bff58270 2022-09-19 op while (c == EOF) {
1768 bff58270 2022-09-19 op if (file == topfile || popfile() == EOF)
1769 bff58270 2022-09-19 op return (EOF);
1770 bff58270 2022-09-19 op c = igetc();
1777 bff58270 2022-09-19 op lungetc(int c)
1779 bff58270 2022-09-19 op if (c == EOF)
1782 bff58270 2022-09-19 op if (file->ungetpos >= file->ungetsize) {
1783 bff58270 2022-09-19 op void *p = reallocarray(file->ungetbuf, file->ungetsize, 2);
1784 bff58270 2022-09-19 op if (p == NULL)
1785 bff58270 2022-09-19 op err(1, "reallocarray");
1786 bff58270 2022-09-19 op file->ungetbuf = p;
1787 bff58270 2022-09-19 op file->ungetsize *= 2;
1789 bff58270 2022-09-19 op file->ungetbuf[file->ungetpos++] = c;
1793 bff58270 2022-09-19 op findeol(void)
1797 bff58270 2022-09-19 op /* skip to either EOF or the first real EOL */
1799 bff58270 2022-09-19 op c = lgetc(0);
1800 bff58270 2022-09-19 op if (c == '\n') {
1801 bff58270 2022-09-19 op file->lineno++;
1804 bff58270 2022-09-19 op if (c == EOF)
1807 bff58270 2022-09-19 op return (ERROR);
1813 bff58270 2022-09-19 op char buf[8096];
1814 bff58270 2022-09-19 op char *p = buf;
1817 bff58270 2022-09-19 op int starting = 0;
1818 bff58270 2022-09-19 op int ending = 0;
1820 bff58270 2022-09-19 op if (!in_define && block == 0) {
1821 bff58270 2022-09-19 op while ((c = lgetc(0)) != '{' && c != EOF) {
1822 bff58270 2022-09-19 op if (c == '\n')
1823 bff58270 2022-09-19 op file->lineno++;
1826 bff58270 2022-09-19 op if (c == EOF)
1830 bff58270 2022-09-19 op c = lgetc(0);
1831 bff58270 2022-09-19 op if (c == '{' || c == '!') {
1832 bff58270 2022-09-19 op if (c == '{')
1833 bff58270 2022-09-19 op block = '}';
1838 bff58270 2022-09-19 op if (c == '\n')
1839 bff58270 2022-09-19 op file->lineno++;
1842 bff58270 2022-09-19 op while ((c = lgetc(0)) == ' ' || c == '\t' || c == '\n') {
1843 bff58270 2022-09-19 op if (c == '\n')
1844 bff58270 2022-09-19 op file->lineno++;
1847 bff58270 2022-09-19 op if (c == EOF) {
1848 bff58270 2022-09-19 op yyerror("unterminated block");
1852 bff58270 2022-09-19 op yylval.lineno = file->lineno;
1854 bff58270 2022-09-19 op if (block != 0 && c == block) {
1855 bff58270 2022-09-19 op if ((c = lgetc(0)) == '}') {
1856 bff58270 2022-09-19 op if (block == '!') {
1858 bff58270 2022-09-19 op return ('!');
1861 bff58270 2022-09-19 op return ('}');
1867 bff58270 2022-09-19 op if (in_define && block == 0) {
1868 bff58270 2022-09-19 op if (c == '{')
1869 bff58270 2022-09-19 op goto newblock;
1872 bff58270 2022-09-19 op if (starting) {
1873 bff58270 2022-09-19 op if (c == '!' || c == '{') {
1874 bff58270 2022-09-19 op lungetc('{');
1878 bff58270 2022-09-19 op starting = 0;
1881 bff58270 2022-09-19 op } else if (c == '{') {
1882 bff58270 2022-09-19 op starting = 1;
1887 bff58270 2022-09-19 op if ((size_t)(p - buf) >= sizeof(buf)) {
1888 bff58270 2022-09-19 op yyerror("string too long");
1889 bff58270 2022-09-19 op return (findeol());
1891 bff58270 2022-09-19 op } while ((c = lgetc(0)) != EOF && c != '\n');
1893 bff58270 2022-09-19 op if (c == EOF) {
1894 bff58270 2022-09-19 op yyerror("unterminated block");
1897 bff58270 2022-09-19 op if (c == '\n')
1898 bff58270 2022-09-19 op file->lineno++;
1899 bff58270 2022-09-19 op if ((yylval.v.string = strdup(buf)) == NULL)
1900 bff58270 2022-09-19 op err(1, "strdup");
1901 bff58270 2022-09-19 op return (STRING);
1904 bff58270 2022-09-19 op if (block == '!') {
1906 bff58270 2022-09-19 op if (ending) {
1907 bff58270 2022-09-19 op if (c == '}') {
1909 bff58270 2022-09-19 op lungetc(block);
1915 bff58270 2022-09-19 op } else if (c == '!') {
1921 bff58270 2022-09-19 op if ((size_t)(p - buf) >= sizeof(buf)) {
1922 bff58270 2022-09-19 op yyerror("line too long");
1923 bff58270 2022-09-19 op return (findeol());
1925 bff58270 2022-09-19 op } while ((c = lgetc(0)) != EOF && c != '\n');
1928 bff58270 2022-09-19 op if (c == EOF) {
1929 bff58270 2022-09-19 op yyerror("unterminated block");
1932 bff58270 2022-09-19 op if (c == '\n')
1933 bff58270 2022-09-19 op file->lineno++;
1935 bff58270 2022-09-19 op if ((yylval.v.string = strdup(buf)) == NULL)
1936 bff58270 2022-09-19 op err(1, "strdup");
1937 bff58270 2022-09-19 op return (STRING);
1941 bff58270 2022-09-19 op if (ending) {
1942 bff58270 2022-09-19 op if (c == '}') {
1944 bff58270 2022-09-19 op lungetc('}');
1950 bff58270 2022-09-19 op } else if (c == '}') {
1956 bff58270 2022-09-19 op if ((size_t)(p - buf) >= sizeof(buf)) {
1957 bff58270 2022-09-19 op yyerror("string too long");
1958 bff58270 2022-09-19 op return (findeol());
1960 bff58270 2022-09-19 op } while ((c = lgetc(0)) != EOF && !isspace((unsigned char)c));
1963 bff58270 2022-09-19 op if (c == EOF) {
1964 bff58270 2022-09-19 op yyerror("unterminated block");
1967 bff58270 2022-09-19 op if (c == '\n')
1968 bff58270 2022-09-19 op file->lineno++;
1969 bff58270 2022-09-19 op if ((token = lookup(buf)) == STRING)
1970 bff58270 2022-09-19 op if ((yylval.v.string = strdup(buf)) == NULL)
1971 bff58270 2022-09-19 op err(1, "strdup");
1972 bff58270 2022-09-19 op return (token);
1975 bff58270 2022-09-19 op struct file *
1976 bff58270 2022-09-19 op pushfile(const char *name, int secret)
1978 bff58270 2022-09-19 op struct file *nfile;
1980 bff58270 2022-09-19 op if ((nfile = calloc(1, sizeof(*nfile))) == NULL)
1981 bff58270 2022-09-19 op err(1, "calloc");
1982 bff58270 2022-09-19 op if ((nfile->name = strdup(name)) == NULL)
1983 bff58270 2022-09-19 op err(1, "strdup");
1984 bff58270 2022-09-19 op if ((nfile->stream = fopen(nfile->name, "r")) == NULL) {
1985 bff58270 2022-09-19 op warn("can't open %s", nfile->name);
1986 bff58270 2022-09-19 op free(nfile->name);
1987 bff58270 2022-09-19 op free(nfile);
1988 bff58270 2022-09-19 op return (NULL);
1990 bff58270 2022-09-19 op nfile->lineno = TAILQ_EMPTY(&files) ? 1 : 0;
1991 bff58270 2022-09-19 op nfile->ungetsize = 16;
1992 bff58270 2022-09-19 op nfile->ungetbuf = malloc(nfile->ungetsize);
1993 bff58270 2022-09-19 op if (nfile->ungetbuf == NULL)
1994 bff58270 2022-09-19 op err(1, "malloc");
1995 bff58270 2022-09-19 op TAILQ_INSERT_TAIL(&files, nfile, entry);
1996 bff58270 2022-09-19 op return (nfile);
2000 bff58270 2022-09-19 op popfile(void)
2002 bff58270 2022-09-19 op struct file *prev;
2004 bff58270 2022-09-19 op if ((prev = TAILQ_PREV(file, files, entry)) != NULL)
2005 bff58270 2022-09-19 op prev->errors += file->errors;
2007 bff58270 2022-09-19 op TAILQ_REMOVE(&files, file, entry);
2008 bff58270 2022-09-19 op fclose(file->stream);
2009 bff58270 2022-09-19 op free(file->name);
2010 bff58270 2022-09-19 op free(file->ungetbuf);
2012 bff58270 2022-09-19 op file = prev;
2013 bff58270 2022-09-19 op return (file ? 0 : EOF);
2017 bff58270 2022-09-19 op parse(const char *filename)
2019 bff58270 2022-09-19 op if ((file = pushfile(filename, 0)) == 0)
2020 bff58270 2022-09-19 op return (-1);
2021 bff58270 2022-09-19 op topfile = file;
2024 bff58270 2022-09-19 op errors = file->errors;
2027 bff58270 2022-09-19 op return (errors ? -1 : 0);
2033 bff58270 2022-09-19 op if (nodebug)
2036 bff58270 2022-09-19 op printf("#line %d ", yylval.lineno);
2037 bff58270 2022-09-19 op printq(file->name);
2038 bff58270 2022-09-19 op putchar('\n');
2042 bff58270 2022-09-19 op printq(const char *str)
2044 bff58270 2022-09-19 op putchar('"');
2045 bff58270 2022-09-19 op for (; *str; ++str) {
2046 bff58270 2022-09-19 op if (*str == '"')
2047 bff58270 2022-09-19 op putchar('\\');
2048 bff58270 2022-09-19 op putchar(*str);
2050 bff58270 2022-09-19 op putchar('"');