1 /* A Bison parser, made by GNU Bison 3.0.4. */
2
3 /* Bison implementation for Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 /* As a special exception, you may create a larger work that contains
21 part or all of the Bison parser skeleton and distribute that work
22 under terms of your choice, so long as that work isn't itself a
23 parser generator using the skeleton or a modified version thereof
24 as a parser skeleton. Alternatively, if you modify or redistribute
25 the parser skeleton itself, you may (at your option) remove this
26 special exception, which will cause the skeleton and the resulting
27 Bison output files to be licensed under the GNU General Public
28 License without this special exception.
29
30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */
32
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34 simplifying the original so-called "semantic" parser. */
35
36 /* All symbols defined below should begin with yy or YY, to avoid
37 infringing on user name space. This should be done even for local
38 variables, as they might otherwise be expanded by user macros.
39 There are some unavoidable exceptions within include files to
40 define necessary library symbols; they are noted "INFRINGES ON
41 USER NAME SPACE" below. */
42
43 /* Identify Bison output. */
44 #define YYBISON 1
45
46 /* Bison version. */
47 #define YYBISON_VERSION "3.0.4"
48
49 /* Skeleton name. */
50 #define YYSKELETON_NAME "yacc.c"
51
52 /* Pure parsers. */
53 #define YYPURE 0
54
55 /* Push parsers. */
56 #define YYPUSH 0
57
58 /* Pull parsers. */
59 #define YYPULL 1
60
61
62
63
64 /* Copy the first part of user declarations. */
65
66
67 /*
68 * R : A Computer Language for Statistical Data Analysis
69 * Copyright (C) 1995, 1996, 1997 Robert Gentleman and Ross Ihaka
70 * Copyright (C) 1997--2019 The R Core Team
71 * Copyright (C) 2010 Duncan Murdoch
72 *
73 * This program is free software; you can redistribute it and/or modify
74 * it under the terms of the GNU General Public License as published by
75 * the Free Software Foundation; either version 2 of the License, or
76 * (at your option) any later version.
77 *
78 * This program is distributed in the hope that it will be useful,
79 * but WITHOUT ANY WARRANTY; without even the implied warranty of
80 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
81 * GNU General Public License for more details.
82 *
83 * You should have received a copy of the GNU General Public License
84 * along with this program; if not, a copy is available at
85 * https://www.R-project.org/Licenses/
86 */
87
88 #ifdef HAVE_CONFIG_H
89 #include <config.h>
90 #endif
91
92 #define R_USE_SIGNALS 1
93 #include <Defn.h>
94 #include <Parse.h>
95 #define STRICT_R_HEADERS
96 #include <R_ext/RS.h> /* for R_chk_* allocation */
97 #include <ctype.h>
98 #include <R_ext/Print.h>
99 #undef _
100 #ifdef ENABLE_NLS
101 #include <libintl.h>
102 #define _(String) dgettext ("tools", String)
103 #else
104 #define _(String) (String)
105 #endif
106
107 /* bison creates a non-static symbol yylloc (and other) in both gramLatex.o
108 and gramRd.o, so remap */
109
110 #define yylloc yyllocL
111 #undef yynerrs /* from Defn.h */
112 #define yynerrs yynerrsL
113 #undef yychar /* from Defn.h */
114 #define yychar yycharL
115 #undef yylval /* from Defn.h */
116 #define yylval yylvalL
117
118 #define DEBUGVALS 0 /* 1 causes detailed internal state output to R console */
119 #define DEBUGMODE 0 /* 1 causes Bison output of parse state, to stdout or stderr */
120
121 #define YYERROR_VERBOSE 1
122
123 static void yyerror(const char *);
124 static int yylex();
125 static int yyparse(void);
126
127 #define yyconst const
128
129 typedef struct yyltype
130 {
131 int first_line;
132 int first_column;
133 int first_byte;
134
135 int last_line;
136 int last_column;
137 int last_byte;
138 } yyltype;
139
140 # define YYLTYPE yyltype
141 # define YYLLOC_DEFAULT(Current, Rhs, N) \
142 do \
143 if (N) \
144 { \
145 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
146 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
147 (Current).first_byte = YYRHSLOC (Rhs, 1).first_byte; \
148 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
149 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
150 (Current).last_byte = YYRHSLOC (Rhs, N).last_byte; \
151 } \
152 else \
153 { \
154 (Current).first_line = (Current).last_line = \
155 YYRHSLOC (Rhs, 0).last_line; \
156 (Current).first_column = (Current).last_column = \
157 YYRHSLOC (Rhs, 0).last_column; \
158 (Current).first_byte = (Current).last_byte = \
159 YYRHSLOC (Rhs, 0).last_byte; \
160 } \
161 while (0)
162
163 /* Useful defines so editors don't get confused ... */
164
165 #define LBRACE '{'
166 #define RBRACE '}'
167
168 /* Functions used in the parsing process */
169
170 static void GrowList(SEXP, SEXP);
171 static int KeywordLookup(const char *);
172 static SEXP NewList(void);
173 static SEXP makeSrcref(YYLTYPE *, SEXP);
174 static int xxgetc();
175 static int xxungetc(int);
176
177 /* Internal lexer / parser state variables */
178
179
180 static char const yyunknown[] = "unknown macro"; /* our message, not bison's */
181
182 typedef struct ParseState ParseState;
183 struct ParseState {
184 int xxlineno, xxbyteno, xxcolno;
185 int xxDebugTokens; /* non-zero causes debug output to R console */
186 SEXP Value;
187 int xxinitvalue;
188 SEXP xxInVerbEnv; /* Are we currently in a verbatim environment? If
189 so, this is the string to end it. If not,
190 this is NULL */
191 SEXP xxVerbatimList;/* A STRSXP containing all the verbatim environment names */
192
193 SEXP SrcFile; /* parseLatex will *always* supply a srcfile */
194 SEXP mset; /* precious mset for protecting parser semantic values */
195 ParseState *prevState;
196 };
197
198 static Rboolean busy = FALSE;
199 static ParseState parseState;
200
201 #define PRESERVE_SV(x) R_PreserveInMSet((x), parseState.mset)
202 #define RELEASE_SV(x) R_ReleaseFromMSet((x), parseState.mset)
203
204 /* Routines used to build the parse tree */
205
206 static SEXP xxnewlist(SEXP);
207 static SEXP xxlist(SEXP, SEXP);
208 static void xxsavevalue(SEXP, YYLTYPE *);
209 static SEXP xxtag(SEXP, int, YYLTYPE *);
210 static SEXP xxenv(SEXP, SEXP, SEXP, YYLTYPE *);
211 static SEXP xxmath(SEXP, YYLTYPE *);
212 static SEXP xxblock(SEXP, YYLTYPE *);
213 static void xxSetInVerbEnv(SEXP);
214
215 static int mkMarkup(int);
216 static int mkText(int);
217 static int mkComment(int);
218 static int mkVerb(int);
219 static int mkVerbEnv();
220
221 static SEXP R_LatexTagSymbol = NULL;
222
223 #define YYSTYPE SEXP
224
225
226
227
228 # ifndef YY_NULLPTR
229 # if defined __cplusplus && 201103L <= __cplusplus
230 # define YY_NULLPTR nullptr
231 # else
232 # define YY_NULLPTR 0
233 # endif
234 # endif
235
236 /* Enabling verbose error messages. */
237 #ifdef YYERROR_VERBOSE
238 # undef YYERROR_VERBOSE
239 # define YYERROR_VERBOSE 1
240 #else
241 # define YYERROR_VERBOSE 0
242 #endif
243
244
245 /* Debug traces. */
246 #ifndef YYDEBUG
247 # define YYDEBUG 0
248 #endif
249 #if YYDEBUG
250 extern int yydebug;
251 #endif
252
253 /* Token type. */
254 #ifndef YYTOKENTYPE
255 # define YYTOKENTYPE
256 enum yytokentype
257 {
258 END_OF_INPUT = 258,
259 ERROR = 259,
260 MACRO = 260,
261 TEXT = 261,
262 COMMENT = 262,
263 BEGIN = 263,
264 END = 264,
265 VERB = 265
266 };
267 #endif
268 /* Tokens. */
269 #define END_OF_INPUT 258
270 #define ERROR 259
271 #define MACRO 260
272 #define TEXT 261
273 #define COMMENT 262
274 #define BEGIN 263
275 #define END 264
276 #define VERB 265
277
278 /* Value type. */
279 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
280 typedef int YYSTYPE;
281 # define YYSTYPE_IS_TRIVIAL 1
282 # define YYSTYPE_IS_DECLARED 1
283 #endif
284
285 /* Location type. */
286 #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
287 typedef struct YYLTYPE YYLTYPE;
288 struct YYLTYPE
289 {
290 int first_line;
291 int first_column;
292 int last_line;
293 int last_column;
294 };
295 # define YYLTYPE_IS_DECLARED 1
296 # define YYLTYPE_IS_TRIVIAL 1
297 #endif
298
299
300 extern YYSTYPE yylval;
301 extern YYLTYPE yylloc;
302 int yyparse (void);
303
304
305
306 /* Copy the second part of user declarations. */
307
308
309
310 #ifdef short
311 # undef short
312 #endif
313
314 #ifdef YYTYPE_UINT8
315 typedef YYTYPE_UINT8 yytype_uint8;
316 #else
317 typedef unsigned char yytype_uint8;
318 #endif
319
320 #ifdef YYTYPE_INT8
321 typedef YYTYPE_INT8 yytype_int8;
322 #else
323 typedef signed char yytype_int8;
324 #endif
325
326 #ifdef YYTYPE_UINT16
327 typedef YYTYPE_UINT16 yytype_uint16;
328 #else
329 typedef unsigned short int yytype_uint16;
330 #endif
331
332 #ifdef YYTYPE_INT16
333 typedef YYTYPE_INT16 yytype_int16;
334 #else
335 typedef short int yytype_int16;
336 #endif
337
338 #ifndef YYSIZE_T
339 # ifdef __SIZE_TYPE__
340 # define YYSIZE_T __SIZE_TYPE__
341 # elif defined size_t
342 # define YYSIZE_T size_t
343 # elif ! defined YYSIZE_T
344 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
345 # define YYSIZE_T size_t
346 # else
347 # define YYSIZE_T unsigned int
348 # endif
349 #endif
350
351 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
352
353 #ifndef YY_
354 # if defined YYENABLE_NLS && YYENABLE_NLS
355 # if ENABLE_NLS
356 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
357 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
358 # endif
359 # endif
360 # ifndef YY_
361 # define YY_(Msgid) Msgid
362 # endif
363 #endif
364
365 #ifndef YY_ATTRIBUTE
366 # if (defined __GNUC__ \
367 && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
368 || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
369 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
370 # else
371 # define YY_ATTRIBUTE(Spec) /* empty */
372 # endif
373 #endif
374
375 #ifndef YY_ATTRIBUTE_PURE
376 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
377 #endif
378
379 #ifndef YY_ATTRIBUTE_UNUSED
380 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
381 #endif
382
383 #if !defined _Noreturn \
384 && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
385 # if defined _MSC_VER && 1200 <= _MSC_VER
386 # define _Noreturn __declspec (noreturn)
387 # else
388 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
389 # endif
390 #endif
391
392 /* Suppress unused-variable warnings by "using" E. */
393 #if ! defined lint || defined __GNUC__
394 # define YYUSE(E) ((void) (E))
395 #else
396 # define YYUSE(E) /* empty */
397 #endif
398
399 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
400 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
401 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
402 _Pragma ("GCC diagnostic push") \
403 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
404 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
405 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
406 _Pragma ("GCC diagnostic pop")
407 #else
408 # define YY_INITIAL_VALUE(Value) Value
409 #endif
410 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
411 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
412 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
413 #endif
414 #ifndef YY_INITIAL_VALUE
415 # define YY_INITIAL_VALUE(Value) /* Nothing. */
416 #endif
417
418
419 #if ! defined yyoverflow || YYERROR_VERBOSE
420
421 /* The parser invokes alloca or malloc; define the necessary symbols. */
422
423 # ifdef YYSTACK_USE_ALLOCA
424 # if YYSTACK_USE_ALLOCA
425 # ifdef __GNUC__
426 # define YYSTACK_ALLOC __builtin_alloca
427 # elif defined __BUILTIN_VA_ARG_INCR
428 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
429 # elif defined _AIX
430 # define YYSTACK_ALLOC __alloca
431 # elif defined _MSC_VER
432 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
433 # define alloca _alloca
434 # else
435 # define YYSTACK_ALLOC alloca
436 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
437 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
438 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
439 # ifndef EXIT_SUCCESS
440 # define EXIT_SUCCESS 0
441 # endif
442 # endif
443 # endif
444 # endif
445 # endif
446
447 # ifdef YYSTACK_ALLOC
448 /* Pacify GCC's 'empty if-body' warning. */
449 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
450 # ifndef YYSTACK_ALLOC_MAXIMUM
451 /* The OS might guarantee only one guard page at the bottom of the stack,
452 and a page size can be as small as 4096 bytes. So we cannot safely
453 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
454 to allow for a few compiler-allocated temporary stack slots. */
455 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
456 # endif
457 # else
458 # define YYSTACK_ALLOC YYMALLOC
459 # define YYSTACK_FREE YYFREE
460 # ifndef YYSTACK_ALLOC_MAXIMUM
461 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
462 # endif
463 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
464 && ! ((defined YYMALLOC || defined malloc) \
465 && (defined YYFREE || defined free)))
466 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
467 # ifndef EXIT_SUCCESS
468 # define EXIT_SUCCESS 0
469 # endif
470 # endif
471 # ifndef YYMALLOC
472 # define YYMALLOC malloc
473 # if ! defined malloc && ! defined EXIT_SUCCESS
474 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
475 # endif
476 # endif
477 # ifndef YYFREE
478 # define YYFREE free
479 # if ! defined free && ! defined EXIT_SUCCESS
480 void free (void *); /* INFRINGES ON USER NAME SPACE */
481 # endif
482 # endif
483 # endif
484 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
485
486
487 #if (! defined yyoverflow \
488 && (! defined __cplusplus \
489 || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
490 && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
491
492 /* A type that is properly aligned for any stack member. */
493 union yyalloc
494 {
495 yytype_int16 yyss_alloc;
496 YYSTYPE yyvs_alloc;
497 YYLTYPE yyls_alloc;
498 };
499
500 /* The size of the maximum gap between one aligned stack and the next. */
501 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
502
503 /* The size of an array large to enough to hold all stacks, each with
504 N elements. */
505 # define YYSTACK_BYTES(N) \
506 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
507 + 2 * YYSTACK_GAP_MAXIMUM)
508
509 # define YYCOPY_NEEDED 1
510
511 /* Relocate STACK from its old location to the new one. The
512 local variables YYSIZE and YYSTACKSIZE give the old and new number of
513 elements in the stack, and YYPTR gives the new location of the
514 stack. Advance YYPTR to a properly aligned location for the next
515 stack. */
516 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
517 do \
518 { \
519 YYSIZE_T yynewbytes; \
520 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
521 Stack = &yyptr->Stack_alloc; \
522 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
523 yyptr += yynewbytes / sizeof (*yyptr); \
524 } \
525 while (0)
526
527 #endif
528
529 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
530 /* Copy COUNT objects from SRC to DST. The source and destination do
531 not overlap. */
532 # ifndef YYCOPY
533 # if defined __GNUC__ && 1 < __GNUC__
534 # define YYCOPY(Dst, Src, Count) \
535 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
536 # else
537 # define YYCOPY(Dst, Src, Count) \
538 do \
539 { \
540 YYSIZE_T yyi; \
541 for (yyi = 0; yyi < (Count); yyi++) \
542 (Dst)[yyi] = (Src)[yyi]; \
543 } \
544 while (0)
545 # endif
546 # endif
547 #endif /* !YYCOPY_NEEDED */
548
549 /* YYFINAL -- State number of the termination state. */
550 #define YYFINAL 21
551 /* YYLAST -- Last index in YYTABLE. */
552 #define YYLAST 88
553
554 /* YYNTOKENS -- Number of terminals. */
555 #define YYNTOKENS 14
556 /* YYNNTS -- Number of nonterminals. */
557 #define YYNNTS 9
558 /* YYNRULES -- Number of rules. */
559 #define YYNRULES 21
560 /* YYNSTATES -- Number of states. */
561 #define YYNSTATES 36
562
563 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
564 by yylex, with out-of-bounds checking. */
565 #define YYUNDEFTOK 2
566 #define YYMAXUTOK 265
567
568 #define YYTRANSLATE(YYX) \
569 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
570
571 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
572 as returned by yylex, without out-of-bounds checking. */
573 static const yytype_uint8 yytranslate[] =
574 {
575 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
576 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
577 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
578 2, 2, 2, 2, 2, 2, 13, 2, 2, 2,
579 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
580 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
581 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
582 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
583 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
584 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
585 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
586 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
587 2, 2, 2, 11, 2, 12, 2, 2, 2, 2,
588 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
589 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
590 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
591 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
592 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
593 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
594 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
595 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
596 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
597 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
598 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
599 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
600 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
601 5, 6, 7, 8, 9, 10
602 };
603
604 #if YYDEBUG
605 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
606 static const yytype_uint8 yyrline[] =
607 {
608 0, 177, 177, 178, 179, 182, 183, 184, 185, 187,
609 188, 190, 191, 192, 193, 194, 195, 197, 197, 201,
610 203, 204
611 };
612 #endif
613
614 #if YYDEBUG || YYERROR_VERBOSE || 0
615 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
616 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
617 static const char *const yytname[] =
618 {
619 "$end", "error", "$undefined", "END_OF_INPUT", "ERROR", "MACRO", "TEXT",
620 "COMMENT", "BEGIN", "END", "VERB", "'{'", "'}'", "'$'", "$accept",
621 "Init", "Items", "nonMath", "Item", "environment", "$@1", "math",
622 "block", YY_NULLPTR
623 };
624 #endif
625
626 # ifdef YYPRINT
627 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
628 (internal) symbol number NUM (which must be that of a token). */
629 static const yytype_uint16 yytoknum[] =
630 {
631 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
632 265, 123, 125, 36
633 };
634 # endif
635
636 #define YYPACT_NINF -10
637
638 #define yypact_value_is_default(Yystate) \
639 (!!((Yystate) == (-10)))
640
641 #define YYTABLE_NINF -1
642
643 #define yytable_value_is_error(Yytable_value) \
644 0
645
646 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
647 STATE-NUM. */
648 static const yytype_int8 yypact[] =
649 {
650 23, -10, -10, -10, -10, -10, -8, -10, 32, 77,
651 4, 8, -10, -10, -10, -10, 0, -10, 41, 59,
652 -10, -10, -10, -10, -10, -5, -10, -10, -10, -10,
653 68, 50, -3, 11, 15, -10
654 };
655
656 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
657 Performed when YYTABLE does not specify something else to do. Zero
658 means the default is an error. */
659 static const yytype_uint8 yydefact[] =
660 {
661 0, 4, 3, 13, 11, 12, 0, 14, 0, 0,
662 0, 0, 5, 15, 6, 16, 0, 21, 0, 0,
663 9, 1, 2, 7, 8, 0, 20, 19, 10, 17,
664 0, 0, 0, 0, 0, 18
665 };
666
667 /* YYPGOTO[NTERM-NUM]. */
668 static const yytype_int8 yypgoto[] =
669 {
670 -10, -10, -7, -10, -9, -10, -10, -6, -10
671 };
672
673 /* YYDEFGOTO[NTERM-NUM]. */
674 static const yytype_int8 yydefgoto[] =
675 {
676 -1, 10, 11, 19, 12, 13, 30, 14, 15
677 };
678
679 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
680 positive, shift that token. If negative, reduce the rule whose
681 number is the opposite. If YYTABLE_NINF, syntax error. */
682 static const yytype_uint8 yytable[] =
683 {
684 20, 18, 23, 16, 21, 24, 25, 29, 33, 23,
685 28, 22, 24, 3, 4, 5, 6, 34, 7, 8,
686 0, 9, 23, 31, 1, 24, 2, 35, 3, 4,
687 5, 6, 0, 7, 8, 0, 9, 3, 4, 5,
688 6, 0, 7, 8, 17, 9, 3, 4, 5, 6,
689 0, 7, 8, 26, 9, 3, 4, 5, 6, 32,
690 7, 8, 0, 9, 3, 4, 5, 6, 0, 7,
691 8, 0, 27, 3, 4, 5, 6, 0, 7, 8,
692 0, 9, 3, 4, 5, 6, 0, 7, 8
693 };
694
695 static const yytype_int8 yycheck[] =
696 {
697 9, 8, 11, 11, 0, 11, 6, 12, 11, 18,
698 19, 3, 18, 5, 6, 7, 8, 6, 10, 11,
699 -1, 13, 31, 30, 1, 31, 3, 12, 5, 6,
700 7, 8, -1, 10, 11, -1, 13, 5, 6, 7,
701 8, -1, 10, 11, 12, 13, 5, 6, 7, 8,
702 -1, 10, 11, 12, 13, 5, 6, 7, 8, 9,
703 10, 11, -1, 13, 5, 6, 7, 8, -1, 10,
704 11, -1, 13, 5, 6, 7, 8, -1, 10, 11,
705 -1, 13, 5, 6, 7, 8, -1, 10, 11
706 };
707
708 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
709 symbol of state STATE-NUM. */
710 static const yytype_uint8 yystos[] =
711 {
712 0, 1, 3, 5, 6, 7, 8, 10, 11, 13,
713 15, 16, 18, 19, 21, 22, 11, 12, 16, 17,
714 18, 0, 3, 18, 21, 6, 12, 13, 18, 12,
715 20, 16, 9, 11, 6, 12
716 };
717
718 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
719 static const yytype_uint8 yyr1[] =
720 {
721 0, 14, 15, 15, 15, 16, 16, 16, 16, 17,
722 17, 18, 18, 18, 18, 18, 18, 20, 19, 21,
723 22, 22
724 };
725
726 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
727 static const yytype_uint8 yyr2[] =
728 {
729 0, 2, 2, 1, 1, 1, 1, 2, 2, 1,
730 2, 1, 1, 1, 1, 1, 1, 0, 10, 3,
731 3, 2
732 };
733
734
735 #define yyerrok (yyerrstatus = 0)
736 #define yyclearin (yychar = YYEMPTY)
737 #define YYEMPTY (-2)
738 #define YYEOF 0
739
740 #define YYACCEPT goto yyacceptlab
741 #define YYABORT goto yyabortlab
742 #define YYERROR goto yyerrorlab
743
744
745 #define YYRECOVERING() (!!yyerrstatus)
746
747 #define YYBACKUP(Token, Value) \
748 do \
749 if (yychar == YYEMPTY) \
750 { \
751 yychar = (Token); \
752 yylval = (Value); \
753 YYPOPSTACK (yylen); \
754 yystate = *yyssp; \
755 goto yybackup; \
756 } \
757 else \
758 { \
759 yyerror (YY_("syntax error: cannot back up")); \
760 YYERROR; \
761 } \
762 while (0)
763
764 /* Error token number */
765 #define YYTERROR 1
766 #define YYERRCODE 256
767
768
769 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
770 If N is 0, then set CURRENT to the empty location which ends
771 the previous symbol: RHS[0] (always defined). */
772
773 #ifndef YYLLOC_DEFAULT
774 # define YYLLOC_DEFAULT(Current, Rhs, N) \
775 do \
776 if (N) \
777 { \
778 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
779 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
780 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
781 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
782 } \
783 else \
784 { \
785 (Current).first_line = (Current).last_line = \
786 YYRHSLOC (Rhs, 0).last_line; \
787 (Current).first_column = (Current).last_column = \
788 YYRHSLOC (Rhs, 0).last_column; \
789 } \
790 while (0)
791 #endif
792
793 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
794
795
796 /* Enable debugging if requested. */
797 #if YYDEBUG
798
799 # ifndef YYFPRINTF
800 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
801 # define YYFPRINTF fprintf
802 # endif
803
804 # define YYDPRINTF(Args) \
805 do { \
806 if (yydebug) \
807 YYFPRINTF Args; \
808 } while (0)
809
810
811 /* YY_LOCATION_PRINT -- Print the location on the stream.
812 This macro was not mandated originally: define only if we know
813 we won't break user code: when these are the locations we know. */
814
815 #ifndef YY_LOCATION_PRINT
816 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
817
818 /* Print *YYLOCP on YYO. Private, do not rely on its existence. */
819
820 YY_ATTRIBUTE_UNUSED
821 static unsigned
yy_location_print_(FILE * yyo,YYLTYPE const * const yylocp)822 yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
823 {
824 unsigned res = 0;
825 int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
826 if (0 <= yylocp->first_line)
827 {
828 res += YYFPRINTF (yyo, "%d", yylocp->first_line);
829 if (0 <= yylocp->first_column)
830 res += YYFPRINTF (yyo, ".%d", yylocp->first_column);
831 }
832 if (0 <= yylocp->last_line)
833 {
834 if (yylocp->first_line < yylocp->last_line)
835 {
836 res += YYFPRINTF (yyo, "-%d", yylocp->last_line);
837 if (0 <= end_col)
838 res += YYFPRINTF (yyo, ".%d", end_col);
839 }
840 else if (0 <= end_col && yylocp->first_column < end_col)
841 res += YYFPRINTF (yyo, "-%d", end_col);
842 }
843 return res;
844 }
845
846 # define YY_LOCATION_PRINT(File, Loc) \
847 yy_location_print_ (File, &(Loc))
848
849 # else
850 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
851 # endif
852 #endif
853
854
855 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
856 do { \
857 if (yydebug) \
858 { \
859 YYFPRINTF (stderr, "%s ", Title); \
860 yy_symbol_print (stderr, \
861 Type, Value, Location); \
862 YYFPRINTF (stderr, "\n"); \
863 } \
864 } while (0)
865
866
867 /*----------------------------------------.
868 | Print this symbol's value on YYOUTPUT. |
869 `----------------------------------------*/
870
871 static void
yy_symbol_value_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep,YYLTYPE const * const yylocationp)872 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
873 {
874 FILE *yyo = yyoutput;
875 YYUSE (yyo);
876 YYUSE (yylocationp);
877 if (!yyvaluep)
878 return;
879 # ifdef YYPRINT
880 if (yytype < YYNTOKENS)
881 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
882 # endif
883 YYUSE (yytype);
884 }
885
886
887 /*--------------------------------.
888 | Print this symbol on YYOUTPUT. |
889 `--------------------------------*/
890
891 static void
yy_symbol_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep,YYLTYPE const * const yylocationp)892 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
893 {
894 YYFPRINTF (yyoutput, "%s %s (",
895 yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
896
897 YY_LOCATION_PRINT (yyoutput, *yylocationp);
898 YYFPRINTF (yyoutput, ": ");
899 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp);
900 YYFPRINTF (yyoutput, ")");
901 }
902
903 /*------------------------------------------------------------------.
904 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
905 | TOP (included). |
906 `------------------------------------------------------------------*/
907
908 static void
yy_stack_print(yytype_int16 * yybottom,yytype_int16 * yytop)909 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
910 {
911 YYFPRINTF (stderr, "Stack now");
912 for (; yybottom <= yytop; yybottom++)
913 {
914 int yybot = *yybottom;
915 YYFPRINTF (stderr, " %d", yybot);
916 }
917 YYFPRINTF (stderr, "\n");
918 }
919
920 # define YY_STACK_PRINT(Bottom, Top) \
921 do { \
922 if (yydebug) \
923 yy_stack_print ((Bottom), (Top)); \
924 } while (0)
925
926
927 /*------------------------------------------------.
928 | Report that the YYRULE is going to be reduced. |
929 `------------------------------------------------*/
930
931 static void
yy_reduce_print(yytype_int16 * yyssp,YYSTYPE * yyvsp,YYLTYPE * yylsp,int yyrule)932 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule)
933 {
934 unsigned long int yylno = yyrline[yyrule];
935 int yynrhs = yyr2[yyrule];
936 int yyi;
937 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
938 yyrule - 1, yylno);
939 /* The symbols being reduced. */
940 for (yyi = 0; yyi < yynrhs; yyi++)
941 {
942 YYFPRINTF (stderr, " $%d = ", yyi + 1);
943 yy_symbol_print (stderr,
944 yystos[yyssp[yyi + 1 - yynrhs]],
945 &(yyvsp[(yyi + 1) - (yynrhs)])
946 , &(yylsp[(yyi + 1) - (yynrhs)]) );
947 YYFPRINTF (stderr, "\n");
948 }
949 }
950
951 # define YY_REDUCE_PRINT(Rule) \
952 do { \
953 if (yydebug) \
954 yy_reduce_print (yyssp, yyvsp, yylsp, Rule); \
955 } while (0)
956
957 /* Nonzero means print parse trace. It is left uninitialized so that
958 multiple parsers can coexist. */
959 int yydebug;
960 #else /* !YYDEBUG */
961 # define YYDPRINTF(Args)
962 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
963 # define YY_STACK_PRINT(Bottom, Top)
964 # define YY_REDUCE_PRINT(Rule)
965 #endif /* !YYDEBUG */
966
967
968 /* YYINITDEPTH -- initial size of the parser's stacks. */
969 #ifndef YYINITDEPTH
970 # define YYINITDEPTH 200
971 #endif
972
973 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
974 if the built-in stack extension method is used).
975
976 Do not make this value too large; the results are undefined if
977 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
978 evaluated with infinite-precision integer arithmetic. */
979
980 #ifndef YYMAXDEPTH
981 # define YYMAXDEPTH 10000
982 #endif
983
984
985 #if YYERROR_VERBOSE
986
987 # ifndef yystrlen
988 # if defined __GLIBC__ && defined _STRING_H
989 # define yystrlen strlen
990 # else
991 /* Return the length of YYSTR. */
992 static YYSIZE_T
yystrlen(const char * yystr)993 yystrlen (const char *yystr)
994 {
995 YYSIZE_T yylen;
996 for (yylen = 0; yystr[yylen]; yylen++)
997 continue;
998 return yylen;
999 }
1000 # endif
1001 # endif
1002
1003 # ifndef yystpcpy
1004 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1005 # define yystpcpy stpcpy
1006 # else
1007 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1008 YYDEST. */
1009 static char *
yystpcpy(char * yydest,const char * yysrc)1010 yystpcpy (char *yydest, const char *yysrc)
1011 {
1012 char *yyd = yydest;
1013 const char *yys = yysrc;
1014
1015 while ((*yyd++ = *yys++) != '\0')
1016 continue;
1017
1018 return yyd - 1;
1019 }
1020 # endif
1021 # endif
1022
1023 # ifndef yytnamerr
1024 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1025 quotes and backslashes, so that it's suitable for yyerror. The
1026 heuristic is that double-quoting is unnecessary unless the string
1027 contains an apostrophe, a comma, or backslash (other than
1028 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1029 null, do not copy; instead, return the length of what the result
1030 would have been. */
1031 static YYSIZE_T
yytnamerr(char * yyres,const char * yystr)1032 yytnamerr (char *yyres, const char *yystr)
1033 {
1034 if (*yystr == '"')
1035 {
1036 YYSIZE_T yyn = 0;
1037 char const *yyp = yystr;
1038
1039 for (;;)
1040 switch (*++yyp)
1041 {
1042 case '\'':
1043 case ',':
1044 goto do_not_strip_quotes;
1045
1046 case '\\':
1047 if (*++yyp != '\\')
1048 goto do_not_strip_quotes;
1049 /* Fall through. */
1050 default:
1051 if (yyres)
1052 yyres[yyn] = *yyp;
1053 yyn++;
1054 break;
1055
1056 case '"':
1057 if (yyres)
1058 yyres[yyn] = '\0';
1059 return yyn;
1060 }
1061 do_not_strip_quotes: ;
1062 }
1063
1064 if (! yyres)
1065 return yystrlen (yystr);
1066
1067 return yystpcpy (yyres, yystr) - yyres;
1068 }
1069 # endif
1070
1071 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1072 about the unexpected token YYTOKEN for the state stack whose top is
1073 YYSSP.
1074
1075 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1076 not large enough to hold the message. In that case, also set
1077 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1078 required number of bytes is too large to store. */
1079 static int
yysyntax_error(YYSIZE_T * yymsg_alloc,char ** yymsg,yytype_int16 * yyssp,int yytoken)1080 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1081 yytype_int16 *yyssp, int yytoken)
1082 {
1083 YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
1084 YYSIZE_T yysize = yysize0;
1085 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1086 /* Internationalized format string. */
1087 const char *yyformat = YY_NULLPTR;
1088 /* Arguments of yyformat. */
1089 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1090 /* Number of reported tokens (one for the "unexpected", one per
1091 "expected"). */
1092 int yycount = 0;
1093
1094 /* There are many possibilities here to consider:
1095 - If this state is a consistent state with a default action, then
1096 the only way this function was invoked is if the default action
1097 is an error action. In that case, don't check for expected
1098 tokens because there are none.
1099 - The only way there can be no lookahead present (in yychar) is if
1100 this state is a consistent state with a default action. Thus,
1101 detecting the absence of a lookahead is sufficient to determine
1102 that there is no unexpected or expected token to report. In that
1103 case, just report a simple "syntax error".
1104 - Don't assume there isn't a lookahead just because this state is a
1105 consistent state with a default action. There might have been a
1106 previous inconsistent state, consistent state with a non-default
1107 action, or user semantic action that manipulated yychar.
1108 - Of course, the expected token list depends on states to have
1109 correct lookahead information, and it depends on the parser not
1110 to perform extra reductions after fetching a lookahead from the
1111 scanner and before detecting a syntax error. Thus, state merging
1112 (from LALR or IELR) and default reductions corrupt the expected
1113 token list. However, the list is correct for canonical LR with
1114 one exception: it will still contain any token that will not be
1115 accepted due to an error action in a later state.
1116 */
1117 if (yytoken != YYEMPTY)
1118 {
1119 int yyn = yypact[*yyssp];
1120 yyarg[yycount++] = yytname[yytoken];
1121 if (!yypact_value_is_default (yyn))
1122 {
1123 /* Start YYX at -YYN if negative to avoid negative indexes in
1124 YYCHECK. In other words, skip the first -YYN actions for
1125 this state because they are default actions. */
1126 int yyxbegin = yyn < 0 ? -yyn : 0;
1127 /* Stay within bounds of both yycheck and yytname. */
1128 int yychecklim = YYLAST - yyn + 1;
1129 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1130 int yyx;
1131
1132 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1133 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1134 && !yytable_value_is_error (yytable[yyx + yyn]))
1135 {
1136 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1137 {
1138 yycount = 1;
1139 yysize = yysize0;
1140 break;
1141 }
1142 yyarg[yycount++] = yytname[yyx];
1143 {
1144 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
1145 if (! (yysize <= yysize1
1146 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1147 return 2;
1148 yysize = yysize1;
1149 }
1150 }
1151 }
1152 }
1153
1154 switch (yycount)
1155 {
1156 # define YYCASE_(N, S) \
1157 case N: \
1158 yyformat = S; \
1159 break
1160 YYCASE_(0, YY_("syntax error"));
1161 YYCASE_(1, YY_("syntax error, unexpected %s"));
1162 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1163 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1164 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1165 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1166 # undef YYCASE_
1167 }
1168
1169 {
1170 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1171 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1172 return 2;
1173 yysize = yysize1;
1174 }
1175
1176 if (*yymsg_alloc < yysize)
1177 {
1178 *yymsg_alloc = 2 * yysize;
1179 if (! (yysize <= *yymsg_alloc
1180 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1181 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1182 return 1;
1183 }
1184
1185 /* Avoid sprintf, as that infringes on the user's name space.
1186 Don't have undefined behavior even if the translation
1187 produced a string with the wrong number of "%s"s. */
1188 {
1189 char *yyp = *yymsg;
1190 int yyi = 0;
1191 while ((*yyp = *yyformat) != '\0')
1192 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1193 {
1194 yyp += yytnamerr (yyp, yyarg[yyi++]);
1195 yyformat += 2;
1196 }
1197 else
1198 {
1199 yyp++;
1200 yyformat++;
1201 }
1202 }
1203 return 0;
1204 }
1205 #endif /* YYERROR_VERBOSE */
1206
1207 /*-----------------------------------------------.
1208 | Release the memory associated to this symbol. |
1209 `-----------------------------------------------*/
1210
1211 static void
yydestruct(const char * yymsg,int yytype,YYSTYPE * yyvaluep,YYLTYPE * yylocationp)1212 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
1213 {
1214 YYUSE (yyvaluep);
1215 YYUSE (yylocationp);
1216 if (!yymsg)
1217 yymsg = "Deleting";
1218 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1219
1220 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1221 switch (yytype)
1222 {
1223 case 5: /* MACRO */
1224
1225 { RELEASE_SV(((*yyvaluep))); }
1226
1227 break;
1228
1229 case 6: /* TEXT */
1230
1231 { RELEASE_SV(((*yyvaluep))); }
1232
1233 break;
1234
1235 case 7: /* COMMENT */
1236
1237 { RELEASE_SV(((*yyvaluep))); }
1238
1239 break;
1240
1241 case 8: /* BEGIN */
1242
1243 { RELEASE_SV(((*yyvaluep))); }
1244
1245 break;
1246
1247 case 9: /* END */
1248
1249 { RELEASE_SV(((*yyvaluep))); }
1250
1251 break;
1252
1253
1254 default:
1255 break;
1256 }
1257 YY_IGNORE_MAYBE_UNINITIALIZED_END
1258 }
1259
1260
1261
1262
1263 /* The lookahead symbol. */
1264 int yychar;
1265
1266 /* The semantic value of the lookahead symbol. */
1267 YYSTYPE yylval;
1268 /* Location data for the lookahead symbol. */
1269 YYLTYPE yylloc
1270 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1271 = { 1, 1, 1, 1 }
1272 # endif
1273 ;
1274 /* Number of syntax errors so far. */
1275 int yynerrs;
1276
1277
1278 /*----------.
1279 | yyparse. |
1280 `----------*/
1281
1282 int
yyparse(void)1283 yyparse (void)
1284 {
1285 int yystate;
1286 /* Number of tokens to shift before error messages enabled. */
1287 int yyerrstatus;
1288
1289 /* The stacks and their tools:
1290 'yyss': related to states.
1291 'yyvs': related to semantic values.
1292 'yyls': related to locations.
1293
1294 Refer to the stacks through separate pointers, to allow yyoverflow
1295 to reallocate them elsewhere. */
1296
1297 /* The state stack. */
1298 yytype_int16 yyssa[YYINITDEPTH];
1299 yytype_int16 *yyss;
1300 yytype_int16 *yyssp;
1301
1302 /* The semantic value stack. */
1303 YYSTYPE yyvsa[YYINITDEPTH];
1304 YYSTYPE *yyvs;
1305 YYSTYPE *yyvsp;
1306
1307 /* The location stack. */
1308 YYLTYPE yylsa[YYINITDEPTH];
1309 YYLTYPE *yyls;
1310 YYLTYPE *yylsp;
1311
1312 /* The locations where the error started and ended. */
1313 YYLTYPE yyerror_range[3];
1314
1315 YYSIZE_T yystacksize;
1316
1317 int yyn;
1318 int yyresult;
1319 /* Lookahead token as an internal (translated) token number. */
1320 int yytoken = 0;
1321 /* The variables used to return semantic value and location from the
1322 action routines. */
1323 YYSTYPE yyval;
1324 YYLTYPE yyloc;
1325
1326 #if YYERROR_VERBOSE
1327 /* Buffer for error messages, and its allocated size. */
1328 char yymsgbuf[128];
1329 char *yymsg = yymsgbuf;
1330 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1331 #endif
1332
1333 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
1334
1335 /* The number of symbols on the RHS of the reduced rule.
1336 Keep to zero when no symbol should be popped. */
1337 int yylen = 0;
1338
1339 yyssp = yyss = yyssa;
1340 yyvsp = yyvs = yyvsa;
1341 yylsp = yyls = yylsa;
1342 yystacksize = YYINITDEPTH;
1343
1344 YYDPRINTF ((stderr, "Starting parse\n"));
1345
1346 yystate = 0;
1347 yyerrstatus = 0;
1348 yynerrs = 0;
1349 yychar = YYEMPTY; /* Cause a token to be read. */
1350 yylsp[0] = yylloc;
1351 goto yysetstate;
1352
1353 /*------------------------------------------------------------.
1354 | yynewstate -- Push a new state, which is found in yystate. |
1355 `------------------------------------------------------------*/
1356 yynewstate:
1357 /* In all cases, when you get here, the value and location stacks
1358 have just been pushed. So pushing a state here evens the stacks. */
1359 yyssp++;
1360
1361 yysetstate:
1362 *yyssp = yystate;
1363
1364 if (yyss + yystacksize - 1 <= yyssp)
1365 {
1366 /* Get the current used size of the three stacks, in elements. */
1367 YYSIZE_T yysize = yyssp - yyss + 1;
1368
1369 #ifdef yyoverflow
1370 {
1371 /* Give user a chance to reallocate the stack. Use copies of
1372 these so that the &'s don't force the real ones into
1373 memory. */
1374 YYSTYPE *yyvs1 = yyvs;
1375 yytype_int16 *yyss1 = yyss;
1376 YYLTYPE *yyls1 = yyls;
1377
1378 /* Each stack pointer address is followed by the size of the
1379 data in use in that stack, in bytes. This used to be a
1380 conditional around just the two extra args, but that might
1381 be undefined if yyoverflow is a macro. */
1382 yyoverflow (YY_("memory exhausted"),
1383 &yyss1, yysize * sizeof (*yyssp),
1384 &yyvs1, yysize * sizeof (*yyvsp),
1385 &yyls1, yysize * sizeof (*yylsp),
1386 &yystacksize);
1387
1388 yyls = yyls1;
1389 yyss = yyss1;
1390 yyvs = yyvs1;
1391 }
1392 #else /* no yyoverflow */
1393 # ifndef YYSTACK_RELOCATE
1394 goto yyexhaustedlab;
1395 # else
1396 /* Extend the stack our own way. */
1397 if (YYMAXDEPTH <= yystacksize)
1398 goto yyexhaustedlab;
1399 yystacksize *= 2;
1400 if (YYMAXDEPTH < yystacksize)
1401 yystacksize = YYMAXDEPTH;
1402
1403 {
1404 yytype_int16 *yyss1 = yyss;
1405 union yyalloc *yyptr =
1406 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1407 if (! yyptr)
1408 goto yyexhaustedlab;
1409 YYSTACK_RELOCATE (yyss_alloc, yyss);
1410 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1411 YYSTACK_RELOCATE (yyls_alloc, yyls);
1412 # undef YYSTACK_RELOCATE
1413 if (yyss1 != yyssa)
1414 YYSTACK_FREE (yyss1);
1415 }
1416 # endif
1417 #endif /* no yyoverflow */
1418
1419 yyssp = yyss + yysize - 1;
1420 yyvsp = yyvs + yysize - 1;
1421 yylsp = yyls + yysize - 1;
1422
1423 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1424 (unsigned long int) yystacksize));
1425
1426 if (yyss + yystacksize - 1 <= yyssp)
1427 YYABORT;
1428 }
1429
1430 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1431
1432 if (yystate == YYFINAL)
1433 YYACCEPT;
1434
1435 goto yybackup;
1436
1437 /*-----------.
1438 | yybackup. |
1439 `-----------*/
1440 yybackup:
1441
1442 /* Do appropriate processing given the current state. Read a
1443 lookahead token if we need one and don't already have one. */
1444
1445 /* First try to decide what to do without reference to lookahead token. */
1446 yyn = yypact[yystate];
1447 if (yypact_value_is_default (yyn))
1448 goto yydefault;
1449
1450 /* Not known => get a lookahead token if don't already have one. */
1451
1452 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1453 if (yychar == YYEMPTY)
1454 {
1455 YYDPRINTF ((stderr, "Reading a token: "));
1456 yychar = yylex ();
1457 }
1458
1459 if (yychar <= YYEOF)
1460 {
1461 yychar = yytoken = YYEOF;
1462 YYDPRINTF ((stderr, "Now at end of input.\n"));
1463 }
1464 else
1465 {
1466 yytoken = YYTRANSLATE (yychar);
1467 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1468 }
1469
1470 /* If the proper action on seeing token YYTOKEN is to reduce or to
1471 detect an error, take that action. */
1472 yyn += yytoken;
1473 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1474 goto yydefault;
1475 yyn = yytable[yyn];
1476 if (yyn <= 0)
1477 {
1478 if (yytable_value_is_error (yyn))
1479 goto yyerrlab;
1480 yyn = -yyn;
1481 goto yyreduce;
1482 }
1483
1484 /* Count tokens shifted since error; after three, turn off error
1485 status. */
1486 if (yyerrstatus)
1487 yyerrstatus--;
1488
1489 /* Shift the lookahead token. */
1490 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1491
1492 /* Discard the shifted token. */
1493 yychar = YYEMPTY;
1494
1495 yystate = yyn;
1496 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1497 *++yyvsp = yylval;
1498 YY_IGNORE_MAYBE_UNINITIALIZED_END
1499 *++yylsp = yylloc;
1500 goto yynewstate;
1501
1502
1503 /*-----------------------------------------------------------.
1504 | yydefault -- do the default action for the current state. |
1505 `-----------------------------------------------------------*/
1506 yydefault:
1507 yyn = yydefact[yystate];
1508 if (yyn == 0)
1509 goto yyerrlab;
1510 goto yyreduce;
1511
1512
1513 /*-----------------------------.
1514 | yyreduce -- Do a reduction. |
1515 `-----------------------------*/
1516 yyreduce:
1517 /* yyn is the number of a rule to reduce with. */
1518 yylen = yyr2[yyn];
1519
1520 /* If YYLEN is nonzero, implement the default value of the action:
1521 '$$ = $1'.
1522
1523 Otherwise, the following line sets YYVAL to garbage.
1524 This behavior is undocumented and Bison
1525 users should not rely upon it. Assigning to YYVAL
1526 unconditionally makes the parser a bit smaller, and it avoids a
1527 GCC warning that YYVAL may be used uninitialized. */
1528 yyval = yyvsp[1-yylen];
1529
1530 /* Default location. */
1531 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1532 YY_REDUCE_PRINT (yyn);
1533 switch (yyn)
1534 {
1535 case 2:
1536
1537 { xxsavevalue((yyvsp[-1]), &(yyloc)); YYACCEPT; }
1538
1539 break;
1540
1541 case 3:
1542
1543 { xxsavevalue(NULL, &(yyloc)); YYACCEPT; }
1544
1545 break;
1546
1547 case 4:
1548
1549 { PRESERVE_SV(parseState.Value = R_NilValue); YYABORT; }
1550
1551 break;
1552
1553 case 5:
1554
1555 { (yyval) = xxnewlist((yyvsp[0])); }
1556
1557 break;
1558
1559 case 6:
1560
1561 { (yyval) = xxnewlist((yyvsp[0])); }
1562
1563 break;
1564
1565 case 7:
1566
1567 { (yyval) = xxlist((yyvsp[-1]), (yyvsp[0])); }
1568
1569 break;
1570
1571 case 8:
1572
1573 { (yyval) = xxlist((yyvsp[-1]), (yyvsp[0])); }
1574
1575 break;
1576
1577 case 9:
1578
1579 { (yyval) = xxnewlist((yyvsp[0])); }
1580
1581 break;
1582
1583 case 10:
1584
1585 { (yyval) = xxlist((yyvsp[-1]), (yyvsp[0])); }
1586
1587 break;
1588
1589 case 11:
1590
1591 { (yyval) = xxtag((yyvsp[0]), TEXT, &(yyloc)); }
1592
1593 break;
1594
1595 case 12:
1596
1597 { (yyval) = xxtag((yyvsp[0]), COMMENT, &(yyloc)); }
1598
1599 break;
1600
1601 case 13:
1602
1603 { (yyval) = xxtag((yyvsp[0]), MACRO, &(yyloc)); }
1604
1605 break;
1606
1607 case 14:
1608
1609 { (yyval) = xxtag((yyvsp[0]), VERB, &(yyloc)); }
1610
1611 break;
1612
1613 case 15:
1614
1615 { (yyval) = (yyvsp[0]); }
1616
1617 break;
1618
1619 case 16:
1620
1621 { (yyval) = (yyvsp[0]); }
1622
1623 break;
1624
1625 case 17:
1626
1627 { xxSetInVerbEnv((yyvsp[-1])); }
1628
1629 break;
1630
1631 case 18:
1632
1633 { (yyval) = xxenv((yyvsp[-7]), (yyvsp[-4]), (yyvsp[-1]), &(yyloc));
1634 RELEASE_SV((yyvsp[-9])); RELEASE_SV((yyvsp[-3])); }
1635
1636 break;
1637
1638 case 19:
1639
1640 { (yyval) = xxmath((yyvsp[-1]), &(yyloc)); }
1641
1642 break;
1643
1644 case 20:
1645
1646 { (yyval) = xxblock((yyvsp[-1]), &(yyloc)); }
1647
1648 break;
1649
1650 case 21:
1651
1652 { (yyval) = xxblock(NULL, &(yyloc)); }
1653
1654 break;
1655
1656
1657
1658 default: break;
1659 }
1660 /* User semantic actions sometimes alter yychar, and that requires
1661 that yytoken be updated with the new translation. We take the
1662 approach of translating immediately before every use of yytoken.
1663 One alternative is translating here after every semantic action,
1664 but that translation would be missed if the semantic action invokes
1665 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1666 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1667 incorrect destructor might then be invoked immediately. In the
1668 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1669 to an incorrect destructor call or verbose syntax error message
1670 before the lookahead is translated. */
1671 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1672
1673 YYPOPSTACK (yylen);
1674 yylen = 0;
1675 YY_STACK_PRINT (yyss, yyssp);
1676
1677 *++yyvsp = yyval;
1678 *++yylsp = yyloc;
1679
1680 /* Now 'shift' the result of the reduction. Determine what state
1681 that goes to, based on the state we popped back to and the rule
1682 number reduced by. */
1683
1684 yyn = yyr1[yyn];
1685
1686 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1687 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1688 yystate = yytable[yystate];
1689 else
1690 yystate = yydefgoto[yyn - YYNTOKENS];
1691
1692 goto yynewstate;
1693
1694
1695 /*--------------------------------------.
1696 | yyerrlab -- here on detecting error. |
1697 `--------------------------------------*/
1698 yyerrlab:
1699 /* Make sure we have latest lookahead translation. See comments at
1700 user semantic actions for why this is necessary. */
1701 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1702
1703 /* If not already recovering from an error, report this error. */
1704 if (!yyerrstatus)
1705 {
1706 ++yynerrs;
1707 #if ! YYERROR_VERBOSE
1708 yyerror (YY_("syntax error"));
1709 #else
1710 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1711 yyssp, yytoken)
1712 {
1713 char const *yymsgp = YY_("syntax error");
1714 int yysyntax_error_status;
1715 yysyntax_error_status = YYSYNTAX_ERROR;
1716 if (yysyntax_error_status == 0)
1717 yymsgp = yymsg;
1718 else if (yysyntax_error_status == 1)
1719 {
1720 if (yymsg != yymsgbuf)
1721 YYSTACK_FREE (yymsg);
1722 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1723 if (!yymsg)
1724 {
1725 yymsg = yymsgbuf;
1726 yymsg_alloc = sizeof yymsgbuf;
1727 yysyntax_error_status = 2;
1728 }
1729 else
1730 {
1731 yysyntax_error_status = YYSYNTAX_ERROR;
1732 yymsgp = yymsg;
1733 }
1734 }
1735 yyerror (yymsgp);
1736 if (yysyntax_error_status == 2)
1737 goto yyexhaustedlab;
1738 }
1739 # undef YYSYNTAX_ERROR
1740 #endif
1741 }
1742
1743 yyerror_range[1] = yylloc;
1744
1745 if (yyerrstatus == 3)
1746 {
1747 /* If just tried and failed to reuse lookahead token after an
1748 error, discard it. */
1749
1750 if (yychar <= YYEOF)
1751 {
1752 /* Return failure if at end of input. */
1753 if (yychar == YYEOF)
1754 YYABORT;
1755 }
1756 else
1757 {
1758 yydestruct ("Error: discarding",
1759 yytoken, &yylval, &yylloc);
1760 yychar = YYEMPTY;
1761 }
1762 }
1763
1764 /* Else will try to reuse lookahead token after shifting the error
1765 token. */
1766 goto yyerrlab1;
1767
1768
1769 /*---------------------------------------------------.
1770 | yyerrorlab -- error raised explicitly by YYERROR. |
1771 `---------------------------------------------------*/
1772 yyerrorlab:
1773
1774 /* Pacify compilers like GCC when the user code never invokes
1775 YYERROR and the label yyerrorlab therefore never appears in user
1776 code. */
1777 if (/*CONSTCOND*/ 0)
1778 goto yyerrorlab;
1779
1780 yyerror_range[1] = yylsp[1-yylen];
1781 /* Do not reclaim the symbols of the rule whose action triggered
1782 this YYERROR. */
1783 YYPOPSTACK (yylen);
1784 yylen = 0;
1785 YY_STACK_PRINT (yyss, yyssp);
1786 yystate = *yyssp;
1787 goto yyerrlab1;
1788
1789
1790 /*-------------------------------------------------------------.
1791 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1792 `-------------------------------------------------------------*/
1793 yyerrlab1:
1794 yyerrstatus = 3; /* Each real token shifted decrements this. */
1795
1796 for (;;)
1797 {
1798 yyn = yypact[yystate];
1799 if (!yypact_value_is_default (yyn))
1800 {
1801 yyn += YYTERROR;
1802 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1803 {
1804 yyn = yytable[yyn];
1805 if (0 < yyn)
1806 break;
1807 }
1808 }
1809
1810 /* Pop the current state because it cannot handle the error token. */
1811 if (yyssp == yyss)
1812 YYABORT;
1813
1814 yyerror_range[1] = *yylsp;
1815 yydestruct ("Error: popping",
1816 yystos[yystate], yyvsp, yylsp);
1817 YYPOPSTACK (1);
1818 yystate = *yyssp;
1819 YY_STACK_PRINT (yyss, yyssp);
1820 }
1821
1822 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1823 *++yyvsp = yylval;
1824 YY_IGNORE_MAYBE_UNINITIALIZED_END
1825
1826 yyerror_range[2] = yylloc;
1827 /* Using YYLLOC is tempting, but would change the location of
1828 the lookahead. YYLOC is available though. */
1829 YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
1830 *++yylsp = yyloc;
1831
1832 /* Shift the error token. */
1833 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1834
1835 yystate = yyn;
1836 goto yynewstate;
1837
1838
1839 /*-------------------------------------.
1840 | yyacceptlab -- YYACCEPT comes here. |
1841 `-------------------------------------*/
1842 yyacceptlab:
1843 yyresult = 0;
1844 goto yyreturn;
1845
1846 /*-----------------------------------.
1847 | yyabortlab -- YYABORT comes here. |
1848 `-----------------------------------*/
1849 yyabortlab:
1850 yyresult = 1;
1851 goto yyreturn;
1852
1853 #if !defined yyoverflow || YYERROR_VERBOSE
1854 /*-------------------------------------------------.
1855 | yyexhaustedlab -- memory exhaustion comes here. |
1856 `-------------------------------------------------*/
1857 yyexhaustedlab:
1858 yyerror (YY_("memory exhausted"));
1859 yyresult = 2;
1860 /* Fall through. */
1861 #endif
1862
1863 yyreturn:
1864 if (yychar != YYEMPTY)
1865 {
1866 /* Make sure we have latest lookahead translation. See comments at
1867 user semantic actions for why this is necessary. */
1868 yytoken = YYTRANSLATE (yychar);
1869 yydestruct ("Cleanup: discarding lookahead",
1870 yytoken, &yylval, &yylloc);
1871 }
1872 /* Do not reclaim the symbols of the rule whose action triggered
1873 this YYABORT or YYACCEPT. */
1874 YYPOPSTACK (yylen);
1875 YY_STACK_PRINT (yyss, yyssp);
1876 while (yyssp != yyss)
1877 {
1878 yydestruct ("Cleanup: popping",
1879 yystos[*yyssp], yyvsp, yylsp);
1880 YYPOPSTACK (1);
1881 }
1882 #ifndef yyoverflow
1883 if (yyss != yyssa)
1884 YYSTACK_FREE (yyss);
1885 #endif
1886 #if YYERROR_VERBOSE
1887 if (yymsg != yymsgbuf)
1888 YYSTACK_FREE (yymsg);
1889 #endif
1890 return yyresult;
1891 }
1892
1893
1894
xxnewlist(SEXP item)1895 static SEXP xxnewlist(SEXP item)
1896 {
1897 SEXP ans;
1898 #if DEBUGVALS
1899 Rprintf("xxnewlist(item=%p)", item);
1900 #endif
1901 PRESERVE_SV(ans = NewList());
1902 if (item) {
1903 GrowList(ans, item);
1904 RELEASE_SV(item);
1905 }
1906 #if DEBUGVALS
1907 Rprintf(" result: %p is length %d\n", ans, length(ans));
1908 #endif
1909 return ans;
1910 }
1911
xxlist(SEXP list,SEXP item)1912 static SEXP xxlist(SEXP list, SEXP item)
1913 {
1914 #if DEBUGVALS
1915 Rprintf("xxlist(list=%p, item=%p)", list, item);
1916 #endif
1917 GrowList(list, item);
1918 RELEASE_SV(item);
1919 #if DEBUGVALS
1920 Rprintf(" result: %p is length %d\n", list, length(list));
1921 #endif
1922 return list;
1923 }
1924
xxenv(SEXP begin,SEXP body,SEXP end,YYLTYPE * lloc)1925 static SEXP xxenv(SEXP begin, SEXP body, SEXP end, YYLTYPE *lloc)
1926 {
1927 SEXP ans;
1928 #if DEBUGVALS
1929 Rprintf("xxenv(begin=%p, body=%p, end=%p)", begin, body, end);
1930 #endif
1931 PRESERVE_SV(ans = allocVector(VECSXP, 2));
1932 SET_VECTOR_ELT(ans, 0, begin);
1933 RELEASE_SV(begin);
1934 if (!isNull(body)) {
1935 SET_VECTOR_ELT(ans, 1, PairToVectorList(CDR(body)));
1936 RELEASE_SV(body);
1937 }
1938 /* FIXME: check that begin and end match */
1939 setAttrib(ans, R_SrcrefSymbol, makeSrcref(lloc, parseState.SrcFile));
1940 setAttrib(ans, R_LatexTagSymbol, mkString("ENVIRONMENT"));
1941 if (!isNull(end))
1942 RELEASE_SV(end);
1943 #if DEBUGVALS
1944 Rprintf(" result: %p\n", ans);
1945 #endif
1946 return ans;
1947 }
1948
xxmath(SEXP body,YYLTYPE * lloc)1949 static SEXP xxmath(SEXP body, YYLTYPE *lloc)
1950 {
1951 SEXP ans;
1952 #if DEBUGVALS
1953 Rprintf("xxmath(body=%p)", body);
1954 #endif
1955 PRESERVE_SV(ans = PairToVectorList(CDR(body)));
1956 RELEASE_SV(body);
1957 setAttrib(ans, R_SrcrefSymbol, makeSrcref(lloc, parseState.SrcFile));
1958 setAttrib(ans, R_LatexTagSymbol, mkString("MATH"));
1959 #if DEBUGVALS
1960 Rprintf(" result: %p\n", ans);
1961 #endif
1962 return ans;
1963 }
1964
xxblock(SEXP body,YYLTYPE * lloc)1965 static SEXP xxblock(SEXP body, YYLTYPE *lloc)
1966 {
1967 SEXP ans;
1968 #if DEBUGVALS
1969 Rprintf("xxblock(body=%p)", body);
1970 #endif
1971 if (!body)
1972 PRESERVE_SV(ans = allocVector(VECSXP, 0));
1973 else {
1974 PRESERVE_SV(ans = PairToVectorList(CDR(body)));
1975 RELEASE_SV(body);
1976 }
1977 setAttrib(ans, R_SrcrefSymbol, makeSrcref(lloc, parseState.SrcFile));
1978 setAttrib(ans, R_LatexTagSymbol, mkString("BLOCK"));
1979
1980 #if DEBUGVALS
1981 Rprintf(" result: %p\n", ans);
1982 #endif
1983 return ans;
1984 }
1985
VerbatimLookup(const char * s)1986 static int VerbatimLookup(const char *s)
1987 {
1988 int i;
1989 for (i = 0; i < length(parseState.xxVerbatimList); i++) {
1990 if (strcmp(s, CHAR(STRING_ELT(parseState.xxVerbatimList, i))) == 0)
1991 return TRUE;
1992 }
1993 return FALSE;
1994 }
1995
xxSetInVerbEnv(SEXP envname)1996 static void xxSetInVerbEnv(SEXP envname)
1997 {
1998 char buffer[256];
1999 if (VerbatimLookup(CHAR(STRING_ELT(envname, 0)))) {
2000 snprintf(buffer, sizeof(buffer), "\\end{%s}", CHAR(STRING_ELT(envname, 0)));
2001 PRESERVE_SV(parseState.xxInVerbEnv = ScalarString(mkChar(buffer)));
2002 } else parseState.xxInVerbEnv = NULL;
2003 }
2004
xxsavevalue(SEXP items,YYLTYPE * lloc)2005 static void xxsavevalue(SEXP items, YYLTYPE *lloc)
2006 {
2007 if (items) {
2008 PRESERVE_SV(parseState.Value = PairToVectorList(CDR(items)));
2009 RELEASE_SV(items);
2010 } else {
2011 PRESERVE_SV(parseState.Value = allocVector(VECSXP, 1));
2012 SET_VECTOR_ELT(parseState.Value, 0, ScalarString(mkChar("")));
2013 setAttrib(VECTOR_ELT(parseState.Value, 0), R_LatexTagSymbol, mkString("TEXT"));
2014 }
2015 if (!isNull(parseState.Value)) {
2016 setAttrib(parseState.Value, R_ClassSymbol, mkString("LaTeX"));
2017 setAttrib(parseState.Value, R_SrcrefSymbol, makeSrcref(lloc, parseState.SrcFile));
2018 }
2019 }
2020
xxtag(SEXP item,int type,YYLTYPE * lloc)2021 static SEXP xxtag(SEXP item, int type, YYLTYPE *lloc)
2022 {
2023 setAttrib(item, R_LatexTagSymbol, mkString(yytname[YYTRANSLATE(type)]));
2024 setAttrib(item, R_SrcrefSymbol, makeSrcref(lloc, parseState.SrcFile));
2025 return item;
2026 }
2027
2028 /*----------------------------------------------------------------------------*/
2029
2030
2031 static int (*ptr_getc)(void);
2032
2033 /* Private pushback, since file ungetc only guarantees one byte.
2034 We need up to one MBCS-worth */
2035
2036 #define PUSHBACK_BUFSIZE 30
2037
2038 static int pushback[PUSHBACK_BUFSIZE];
2039 static unsigned int npush = 0;
2040
2041 static int prevpos = 0;
2042 static int prevlines[PUSHBACK_BUFSIZE];
2043 static int prevcols[PUSHBACK_BUFSIZE];
2044 static int prevbytes[PUSHBACK_BUFSIZE];
2045
xxgetc(void)2046 static int xxgetc(void)
2047 {
2048 int c, oldpos;
2049
2050 if(npush) c = pushback[--npush]; else c = ptr_getc();
2051
2052 oldpos = prevpos;
2053 prevpos = (prevpos + 1) % PUSHBACK_BUFSIZE;
2054 prevbytes[prevpos] = parseState.xxbyteno;
2055 prevlines[prevpos] = parseState.xxlineno;
2056 /* We only advance the column for the 1st byte in UTF-8, so handle later bytes specially */
2057 if (0x80 <= (unsigned char)c && (unsigned char)c <= 0xBF) {
2058 parseState.xxcolno--;
2059 prevcols[prevpos] = prevcols[oldpos];
2060 } else
2061 prevcols[prevpos] = parseState.xxcolno;
2062
2063 if (c == EOF) return R_EOF;
2064
2065 R_ParseContextLast = (R_ParseContextLast + 1) % PARSE_CONTEXT_SIZE;
2066 R_ParseContext[R_ParseContextLast] = (char) c;
2067
2068 if (c == '\n') {
2069 parseState.xxlineno += 1;
2070 parseState.xxcolno = 1;
2071 parseState.xxbyteno = 1;
2072 } else {
2073 parseState.xxcolno++;
2074 parseState.xxbyteno++;
2075 }
2076
2077 if (c == '\t') parseState.xxcolno = ((parseState.xxcolno + 6) & ~7) + 1;
2078
2079 R_ParseContextLine = parseState.xxlineno;
2080
2081 return c;
2082 }
2083
xxungetc(int c)2084 static int xxungetc(int c)
2085 {
2086 /* this assumes that c was the result of xxgetc; if not, some edits will be needed */
2087 parseState.xxlineno = prevlines[prevpos];
2088 parseState.xxbyteno = prevbytes[prevpos];
2089 parseState.xxcolno = prevcols[prevpos];
2090 prevpos = (prevpos + PUSHBACK_BUFSIZE - 1) % PUSHBACK_BUFSIZE;
2091
2092 R_ParseContextLine = parseState.xxlineno;
2093
2094 R_ParseContext[R_ParseContextLast] = '\0';
2095 /* macOS requires us to keep this non-negative */
2096 R_ParseContextLast = (R_ParseContextLast + PARSE_CONTEXT_SIZE - 1)
2097 % PARSE_CONTEXT_SIZE;
2098 if(npush >= PUSHBACK_BUFSIZE - 2) return R_EOF;
2099 pushback[npush++] = c;
2100 return c;
2101 }
2102
makeSrcref(YYLTYPE * lloc,SEXP srcfile)2103 static SEXP makeSrcref(YYLTYPE *lloc, SEXP srcfile)
2104 {
2105 SEXP val;
2106
2107 PROTECT(val = allocVector(INTSXP, 6));
2108 INTEGER(val)[0] = lloc->first_line;
2109 INTEGER(val)[1] = lloc->first_byte;
2110 INTEGER(val)[2] = lloc->last_line;
2111 INTEGER(val)[3] = lloc->last_byte;
2112 INTEGER(val)[4] = lloc->first_column;
2113 INTEGER(val)[5] = lloc->last_column;
2114 setAttrib(val, R_SrcfileSymbol, srcfile);
2115 setAttrib(val, R_ClassSymbol, mkString("srcref"));
2116 UNPROTECT(1); /* val */
2117 return val;
2118 }
2119
mkString2(const char * s,size_t len)2120 static SEXP mkString2(const char *s, size_t len)
2121 {
2122 SEXP t;
2123 cetype_t enc = CE_UTF8;
2124
2125 PROTECT(t = allocVector(STRSXP, 1));
2126 SET_STRING_ELT(t, 0, mkCharLenCE(s, (int) len, enc));
2127 UNPROTECT(1); /* t */
2128 return t;
2129 }
2130
2131
2132 /* Stretchy List Structures : Lists are created and grown using a special */
2133 /* dotted pair. The CAR of the list points to the last cons-cell in the */
2134 /* list and the CDR points to the first. The list can be extracted from */
2135 /* the pair by taking its CDR, while the CAR gives fast access to the end */
2136 /* of the list. */
2137
2138
2139 /* Create a stretchy-list dotted pair */
2140
NewList(void)2141 static SEXP NewList(void)
2142 {
2143 SEXP s = CONS(R_NilValue, R_NilValue);
2144 SETCAR(s, s);
2145 return s;
2146 }
2147
2148 /* Add a new element at the end of a stretchy list */
2149
GrowList(SEXP l,SEXP s)2150 static void GrowList(SEXP l, SEXP s)
2151 {
2152 SEXP tmp;
2153 tmp = CONS(s, R_NilValue);
2154 SETCDR(CAR(l), tmp);
2155 SETCAR(l, tmp);
2156 }
2157
2158 /*--------------------------------------------------------------------------*/
2159
PutState(ParseState * state)2160 static void PutState(ParseState *state) {
2161 state->xxlineno = parseState.xxlineno;
2162 state->xxbyteno = parseState.xxbyteno;
2163 state->xxcolno = parseState.xxcolno;
2164 state->xxDebugTokens = parseState.xxDebugTokens;
2165 state->Value = parseState.Value;
2166 state->xxinitvalue = parseState.xxinitvalue;
2167 state->xxInVerbEnv = parseState.xxInVerbEnv;
2168 state->xxVerbatimList = parseState.xxVerbatimList;
2169 state->SrcFile = parseState.SrcFile;
2170 state->prevState = parseState.prevState;
2171 }
2172
UseState(ParseState * state)2173 static void UseState(ParseState *state) {
2174 parseState.xxlineno = state->xxlineno;
2175 parseState.xxbyteno = state->xxbyteno;
2176 parseState.xxcolno = state->xxcolno;
2177 parseState.xxDebugTokens = state->xxDebugTokens;
2178 parseState.Value = state->Value;
2179 parseState.xxinitvalue = state->xxinitvalue;
2180 parseState.xxInVerbEnv = state->xxInVerbEnv;
2181 parseState.xxVerbatimList = state->xxVerbatimList;
2182 parseState.SrcFile = state->SrcFile;
2183 parseState.prevState = state->prevState;
2184 }
2185
InitSymbols(void)2186 static void InitSymbols(void)
2187 {
2188 if (!R_LatexTagSymbol)
2189 R_LatexTagSymbol = install("latex_tag");
2190 }
2191
ParseLatex(ParseStatus * status,SEXP srcfile)2192 static SEXP ParseLatex(ParseStatus *status, SEXP srcfile)
2193 {
2194 InitSymbols();
2195
2196 R_ParseContextLast = 0;
2197 R_ParseContext[0] = '\0';
2198
2199 parseState.xxInVerbEnv = NULL;
2200
2201 parseState.xxlineno = 1;
2202 parseState.xxcolno = 1;
2203 parseState.xxbyteno = 1;
2204
2205 parseState.SrcFile = srcfile;
2206
2207 PROTECT(parseState.mset = R_NewPreciousMSet(50));
2208
2209 npush = 0;
2210
2211 parseState.Value = R_NilValue;
2212
2213 if (yyparse()) *status = PARSE_ERROR;
2214 else *status = PARSE_OK;
2215
2216 #if DEBUGVALS
2217 Rprintf("ParseRd result: %p\n", parseState.Value);
2218 #endif
2219
2220 RELEASE_SV(parseState.Value);
2221 UNPROTECT(1); /* parseState.mset */
2222
2223 return parseState.Value;
2224 }
2225
2226 static const char * nextchar_parse;
2227
2228 /* need to handle incomplete last line */
char_getc(void)2229 static int char_getc(void)
2230 {
2231 int c;
2232
2233 c = *nextchar_parse++;
2234 if (!c) {
2235 c = R_EOF;
2236 nextchar_parse--;
2237 }
2238 return (c);
2239 }
2240
2241 static
R_ParseLatex(SEXP text,ParseStatus * status,SEXP srcfile)2242 SEXP R_ParseLatex(SEXP text, ParseStatus *status, SEXP srcfile)
2243 {
2244 nextchar_parse = translateCharUTF8(STRING_ELT(text, 0));
2245 ptr_getc = char_getc;
2246 return ParseLatex(status, srcfile);
2247 }
2248
2249 /*----------------------------------------------------------------------------
2250 *
2251 * The Lexical Analyzer:
2252 *
2253 * Basic lexical analysis is performed by the following
2254 * routines.
2255 *
2256 * The function yylex() scans the input, breaking it into
2257 * tokens which are then passed to the parser.
2258 *
2259 */
2260
2261
2262 /* Special Symbols */
2263 /* Section and R code headers */
2264
2265 struct {
2266 char *name;
2267 int token;
2268 }
2269 static keywords[] = {
2270 /* These sections contain Latex-like text */
2271
2272 { "\\begin", BEGIN },
2273 { "\\end", END },
2274 { "\\verb", VERB },
2275 { 0, 0 }
2276 /* All other markup macros are rejected. */
2277 };
2278
2279 /* Record the longest # directive here */
2280 #define DIRECTIVE_LEN 7
2281
KeywordLookup(const char * s)2282 static int KeywordLookup(const char *s)
2283 {
2284 int i;
2285 for (i = 0; keywords[i].name; i++) {
2286 if (strcmp(keywords[i].name, s) == 0)
2287 return keywords[i].token;
2288 }
2289 return MACRO;
2290 }
2291
yyerror(const char * s)2292 static void yyerror(const char *s)
2293 {
2294 static const char *const yytname_translations[] =
2295 {
2296 /* the left column are strings coming from bison, the right
2297 column are translations for users.
2298 The first YYENGLISH from the right column are English to be translated,
2299 the rest are to be copied literally. The #if 0 block below allows xgettext
2300 to see these.
2301 */
2302 #define YYENGLISH 3
2303 "$undefined", "input",
2304 "LATEXMACRO", "macro",
2305 "ESCAPE", "macro",
2306 0, 0
2307 };
2308 static char const yyunexpected[] = "syntax error, unexpected ";
2309 static char const yyexpecting[] = ", expecting ";
2310 static char const yyshortunexpected[] = "unexpected %s";
2311 static char const yylongunexpected[] = "unexpected %s '%s'";
2312 char *expecting;
2313 char ParseErrorMsg[PARSE_ERROR_SIZE];
2314 SEXP filename;
2315 char ParseErrorFilename[PARSE_ERROR_SIZE];
2316
2317 if (!strncmp(s, yyunexpected, sizeof yyunexpected -1)) {
2318 int i, translated = FALSE;
2319 /* Edit the error message */
2320 expecting = strstr(s + sizeof yyunexpected -1, yyexpecting);
2321 if (expecting) *expecting = '\0';
2322 for (i = 0; yytname_translations[i]; i += 2) {
2323 if (!strcmp(s + sizeof yyunexpected - 1, yytname_translations[i])) {
2324 if (yychar < 256)
2325 snprintf(ParseErrorMsg, PARSE_ERROR_SIZE,
2326 _(yyshortunexpected),
2327 i/2 < YYENGLISH ? _(yytname_translations[i+1])
2328 : yytname_translations[i+1]);
2329 else
2330 snprintf(ParseErrorMsg, PARSE_ERROR_SIZE,
2331 _(yylongunexpected),
2332 i/2 < YYENGLISH ? _(yytname_translations[i+1])
2333 : yytname_translations[i+1],
2334 CHAR(STRING_ELT(yylval, 0)));
2335 translated = TRUE;
2336 break;
2337 }
2338 }
2339 if (!translated) {
2340 if (yychar < 256)
2341 snprintf(ParseErrorMsg, PARSE_ERROR_SIZE,
2342 _(yyshortunexpected),
2343 s + sizeof yyunexpected - 1);
2344 else
2345 snprintf(ParseErrorMsg, PARSE_ERROR_SIZE,
2346 _(yylongunexpected),
2347 s + sizeof yyunexpected - 1, CHAR(STRING_ELT(yylval, 0)));
2348 }
2349 if (expecting) {
2350 translated = FALSE;
2351 for (i = 0; yytname_translations[i]; i += 2) {
2352 if (!strcmp(expecting + sizeof yyexpecting - 1, yytname_translations[i])) {
2353 strcat(ParseErrorMsg, _(yyexpecting));
2354 strcat(ParseErrorMsg, i/2 < YYENGLISH ? _(yytname_translations[i+1])
2355 : yytname_translations[i+1]);
2356 translated = TRUE;
2357 break;
2358 }
2359 }
2360 if (!translated) {
2361 strcat(ParseErrorMsg, _(yyexpecting));
2362 strcat(ParseErrorMsg, expecting + sizeof yyexpecting - 1);
2363 }
2364 }
2365 } else if (!strncmp(s, yyunknown, sizeof yyunknown-1)) {
2366 snprintf(ParseErrorMsg, PARSE_ERROR_SIZE,
2367 "%s '%s'", s, CHAR(STRING_ELT(yylval, 0)));
2368 } else {
2369 snprintf(ParseErrorMsg, PARSE_ERROR_SIZE,"%s", s);
2370 }
2371 filename = findVar(install("filename"), parseState.SrcFile);
2372 if (isString(filename) && LENGTH(filename))
2373 strncpy(ParseErrorFilename, CHAR(STRING_ELT(filename, 0)), PARSE_ERROR_SIZE - 1);
2374 else
2375 ParseErrorFilename[0] = '\0';
2376 if (yylloc.first_line != yylloc.last_line)
2377 warning("%s:%d-%d: %s",
2378 ParseErrorFilename, yylloc.first_line, yylloc.last_line, ParseErrorMsg);
2379 else
2380 warning("%s:%d: %s",
2381 ParseErrorFilename, yylloc.first_line, ParseErrorMsg);
2382 }
2383
2384 #define TEXT_PUSH(c) do { \
2385 size_t nc = bp - stext; \
2386 if (nc >= nstext - 1) { \
2387 char *old = stext; \
2388 nstext *= 2; \
2389 stext = malloc(nstext); \
2390 if(!stext) error(_("unable to allocate buffer for long string at line %d"), parseState.xxlineno);\
2391 memmove(stext, old, nc); \
2392 if(old != st0) free(old); \
2393 bp = stext+nc; } \
2394 *bp++ = ((char)c); \
2395 } while(0)
2396
setfirstloc(void)2397 static void setfirstloc(void)
2398 {
2399 yylloc.first_line = parseState.xxlineno;
2400 yylloc.first_column = parseState.xxcolno;
2401 yylloc.first_byte = parseState.xxbyteno;
2402 }
2403
setlastloc(void)2404 static void setlastloc(void)
2405 {
2406 yylloc.last_line = prevlines[prevpos];
2407 yylloc.last_column = prevcols[prevpos];
2408 yylloc.last_byte = prevbytes[prevpos];
2409 }
2410
2411 /* Split the input stream into tokens. */
2412 /* This is the lowest of the parsing levels. */
2413
token(void)2414 static int token(void)
2415 {
2416 int c;
2417
2418 if (parseState.xxinitvalue) {
2419 yylloc.first_line = 0;
2420 yylloc.first_column = 0;
2421 yylloc.first_byte = 0;
2422 yylloc.last_line = 0;
2423 yylloc.last_column = 0;
2424 yylloc.last_byte = 0;
2425 PRESERVE_SV(yylval = mkString(""));
2426 c = parseState.xxinitvalue;
2427 parseState.xxinitvalue = 0;
2428 return(c);
2429 }
2430
2431 setfirstloc();
2432
2433 if (parseState.xxInVerbEnv)
2434 return mkVerbEnv();
2435
2436 c = xxgetc();
2437
2438 switch (c) {
2439 case '%': return mkComment(c);
2440 case '\\':return mkMarkup(c);
2441 case R_EOF:return END_OF_INPUT;
2442 case LBRACE:return c;
2443 case RBRACE:return c;
2444 case '$': return c;
2445 }
2446 return mkText(c);
2447 }
2448
2449 #define INITBUFSIZE 128
2450
mkText(int c)2451 static int mkText(int c)
2452 {
2453 char st0[INITBUFSIZE];
2454 unsigned int nstext = INITBUFSIZE;
2455 char *stext = st0, *bp = st0;
2456
2457 while(1) {
2458 switch (c) {
2459 case '\\':
2460 case '%':
2461 case LBRACE:
2462 case RBRACE:
2463 case '$':
2464 case R_EOF:
2465 goto stop;
2466 }
2467 TEXT_PUSH(c);
2468 c = xxgetc();
2469 };
2470 stop:
2471 xxungetc(c);
2472 PRESERVE_SV(yylval = mkString2(stext, bp - stext));
2473 if(stext != st0) free(stext);
2474 return TEXT;
2475 }
2476
mkComment(int c)2477 static int mkComment(int c)
2478 {
2479 char st0[INITBUFSIZE];
2480 unsigned int nstext = INITBUFSIZE;
2481 char *stext = st0, *bp = st0;
2482
2483 do TEXT_PUSH(c);
2484 while ((c = xxgetc()) != '\n' && c != R_EOF);
2485
2486 if (c == R_EOF) xxungetc(c);
2487 else TEXT_PUSH(c);
2488
2489 PRESERVE_SV(yylval = mkString2(stext, bp - stext));
2490 if(stext != st0) free(stext);
2491 return COMMENT;
2492 }
2493
mkMarkup(int c)2494 static int mkMarkup(int c)
2495 {
2496 char st0[INITBUFSIZE];
2497 unsigned int nstext = INITBUFSIZE;
2498 char *stext = st0, *bp = st0;
2499 int retval = 0;
2500
2501 TEXT_PUSH(c);
2502 while (isalpha((c = xxgetc()))) TEXT_PUSH(c);
2503
2504 /* One non-alpha allowed */
2505 if (bp - stext == 1) {
2506 TEXT_PUSH(c);
2507 TEXT_PUSH('\0');
2508 retval = MACRO;
2509 } else {
2510 TEXT_PUSH('\0');
2511 retval = KeywordLookup(stext);
2512 if (retval == VERB)
2513 retval = mkVerb(c); /* This makes the yylval */
2514 else if (c != ' ') /* Eat a space, but keep other terminators */
2515 xxungetc(c);
2516 }
2517 if (retval != VERB)
2518 PRESERVE_SV(yylval = mkString(stext));
2519 if(stext != st0) free(stext);
2520 return retval;
2521 }
2522
mkVerb(int c)2523 static int mkVerb(int c)
2524 {
2525 char st0[INITBUFSIZE];
2526 unsigned int nstext = INITBUFSIZE;
2527 char *stext = st0, *bp = st0;
2528 int delim = c;
2529
2530 TEXT_PUSH('\\'); TEXT_PUSH('v'); TEXT_PUSH('e'); TEXT_PUSH('r'); TEXT_PUSH('b');
2531 TEXT_PUSH(c);
2532 while ((c = xxgetc()) != delim) TEXT_PUSH(c);
2533 TEXT_PUSH(c);
2534
2535 PRESERVE_SV(yylval = mkString2(stext, bp - stext));
2536 if(stext != st0) free(stext);
2537 return VERB;
2538 }
2539
mkVerbEnv()2540 static int mkVerbEnv()
2541 {
2542 char st0[INITBUFSIZE];
2543 unsigned int nstext = INITBUFSIZE;
2544 char *stext = st0, *bp = st0;
2545 int matched = 0, i;
2546 int c;
2547
2548 while ((c = xxgetc()) != R_EOF && CHAR(STRING_ELT(parseState.xxInVerbEnv, 0))[matched]) {
2549 TEXT_PUSH(c);
2550 if (c == CHAR(STRING_ELT(parseState.xxInVerbEnv, 0))[matched])
2551 matched++;
2552 else
2553 matched = 0;
2554 }
2555 if ( !CHAR(STRING_ELT(parseState.xxInVerbEnv, 0))[matched] ) {
2556 for (i = matched-1; i >= 0; i--)
2557 xxungetc(*(--bp));
2558 RELEASE_SV(parseState.xxInVerbEnv);
2559 parseState.xxInVerbEnv = NULL;
2560 }
2561
2562 PRESERVE_SV(yylval = mkString2(stext, bp - stext));
2563 if (stext != st0) free(stext);
2564 return VERB;
2565 }
2566
yylex(void)2567 static int yylex(void)
2568 {
2569 int tok = token();
2570
2571 if (parseState.xxDebugTokens) {
2572 Rprintf("%d:%d: %s", yylloc.first_line, yylloc.first_column, yytname[YYTRANSLATE(tok)]);
2573 if (tok > 255 && tok != END_OF_INPUT)
2574 Rprintf(": %s", CHAR(STRING_ELT(yylval, 0)));
2575 Rprintf("\n");
2576 }
2577 setlastloc();
2578 return tok;
2579 }
2580
PushState()2581 static void PushState() {
2582 if (busy) {
2583 ParseState *prev = malloc(sizeof(ParseState));
2584 if (prev == NULL) error("unable to allocate in PushState");
2585 PutState(prev);
2586 parseState.prevState = prev;
2587 } else
2588 parseState.prevState = NULL;
2589 busy = TRUE;
2590 }
2591
PopState()2592 static void PopState() {
2593 if (parseState.prevState) {
2594 ParseState *prev = parseState.prevState;
2595 UseState(prev);
2596 free(prev);
2597 } else
2598 busy = FALSE;
2599 }
2600
2601 /* "do_parseLatex"
2602
2603 .External2("parseLatex", file, srcfile, verbose, basename, warningCalls)
2604 If there is text then that is read and the other arguments are ignored.
2605 */
2606
parseLatex(SEXP call,SEXP op,SEXP args,SEXP env)2607 SEXP parseLatex(SEXP call, SEXP op, SEXP args, SEXP env)
2608 {
2609 args = CDR(args);
2610
2611 SEXP s = R_NilValue, source, text;
2612 ParseStatus status;
2613
2614 #if DEBUGMODE
2615 yydebug = 1;
2616 #endif
2617
2618 R_ParseError = 0;
2619 R_ParseErrorMsg[0] = '\0';
2620
2621 PushState();
2622
2623 text = CAR(args); args = CDR(args);
2624
2625 source = CAR(args); args = CDR(args);
2626 if(!isLogical(CAR(args)) || LENGTH(CAR(args)) != 1)
2627 error(_("invalid '%s' value"), "verbose");
2628 parseState.xxDebugTokens = asInteger(CAR(args)); args = CDR(args);
2629 parseState.xxVerbatimList = CAR(args); args = CDR(args);
2630
2631 s = R_ParseLatex(text, &status, source);
2632
2633 PopState();
2634
2635 if (status != PARSE_OK) parseError(call, R_ParseError);
2636 return s;
2637 }
2638