GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
oct-tex-parser.cc
Go to the documentation of this file.
1/* A Bison parser, made by GNU Bison 3.8.2. */
2
3/* Bison implementation for Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
6 Inc.
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <https://www.gnu.org/licenses/>. */
20
21/* As a special exception, you may create a larger work that contains
22 part or all of the Bison parser skeleton and distribute that work
23 under terms of your choice, so long as that work isn't itself a
24 parser generator using the skeleton or a modified version thereof
25 as a parser skeleton. Alternatively, if you modify or redistribute
26 the parser skeleton itself, you may (at your option) remove this
27 special exception, which will cause the skeleton and the resulting
28 Bison output files to be licensed under the GNU General Public
29 License without this special exception.
30
31 This special exception was added by the Free Software Foundation in
32 version 2.2 of Bison. */
33
34/* C LALR(1) parser skeleton written by Richard Stallman, by
35 simplifying the original so-called "semantic" parser. */
36
37/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
38 especially those whose name start with YY_ or yy_. They are
39 private implementation details that can be changed or removed. */
40
41/* All symbols defined below should begin with yy or YY, to avoid
42 infringing on user name space. This should be done even for local
43 variables, as they might otherwise be expanded by user macros.
44 There are some unavoidable exceptions within include files to
45 define necessary library symbols; they are noted "INFRINGES ON
46 USER NAME SPACE" below. */
47
48/* Identify Bison output, and Bison version. */
49#define YYBISON 30802
50
51/* Bison version string. */
52#define YYBISON_VERSION "3.8.2"
53
54/* Skeleton name. */
55#define YYSKELETON_NAME "yacc.c"
56
57/* Pure parsers. */
58#define YYPURE 1
59
60/* Push parsers. */
61#define YYPUSH 1
62
63/* Pull parsers. */
64#define YYPULL 1
65
66/* Substitute the type names. */
67#define YYSTYPE OCTAVE_TEX_STYPE
68/* Substitute the variable and function names. */
69#define yyparse octave_tex_parse
70#define yypush_parse octave_tex_push_parse
71#define yypull_parse octave_tex_pull_parse
72#define yypstate_new octave_tex_pstate_new
73#define yypstate_clear octave_tex_pstate_clear
74#define yypstate_delete octave_tex_pstate_delete
75#define yypstate octave_tex_pstate
76#define yylex octave_tex_lex
77#define yyerror octave_tex_error
78#define yydebug octave_tex_debug
79#define yynerrs octave_tex_nerrs
80
81/* First part of user prologue. */
82#line 26 "../libinterp/corefcn/oct-tex-parser.yy"
83
84
85#define YYDEBUG 1
86
87#if defined (HAVE_CONFIG_H)
88# include "config.h"
89#endif
90
91#include "text-engine.h"
92
93// oct-tex-parser.h must be included after text-engine.h
94#include "oct-tex-parser.h"
95
96extern int octave_tex_lex (YYSTYPE *, void *);
97 static void yyerror (octave::text_parser_tex& parser, const char *s);
98
99#define m_scanner parser.get_scanner ()
100#define yyalloc octave_tex_yyalloc
101
102#if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
103 // Disable this warning for code that is generated by Bison,
104 // including grammar rules. Push the current state so we can
105 // restore the warning state prior to functions we define at
106 // the bottom of the file.
107# pragma GCC diagnostic push
108# pragma GCC diagnostic ignored "-Wold-style-cast"
109#endif
110
111
112#line 113 "libinterp/corefcn/oct-tex-parser.cc"
113
114# ifndef YY_CAST
115# ifdef __cplusplus
116# define YY_CAST(Type, Val) static_cast<Type> (Val)
117# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
118# else
119# define YY_CAST(Type, Val) ((Type) (Val))
120# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
121# endif
122# endif
123# ifndef YY_NULLPTR
124# if defined __cplusplus
125# if 201103L <= __cplusplus
126# define YY_NULLPTR nullptr
127# else
128# define YY_NULLPTR 0
129# endif
130# else
131# define YY_NULLPTR ((void*)0)
132# endif
133# endif
134
135#include "oct-tex-parser.h"
136/* Symbol kind. */
138{
140 YYSYMBOL_YYEOF = 0, /* "end of file" */
141 YYSYMBOL_YYerror = 1, /* error */
142 YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
143 YYSYMBOL_BF = 3, /* BF */
144 YYSYMBOL_IT = 4, /* IT */
145 YYSYMBOL_SL = 5, /* SL */
146 YYSYMBOL_RM = 6, /* RM */
147 YYSYMBOL_FONTNAME = 7, /* FONTNAME */
148 YYSYMBOL_FONTSIZE = 8, /* FONTSIZE */
149 YYSYMBOL_COLOR = 9, /* COLOR */
150 YYSYMBOL_COLOR_RGB = 10, /* COLOR_RGB */
151 YYSYMBOL_START = 11, /* START */
152 YYSYMBOL_END = 12, /* END */
153 YYSYMBOL_SUPER = 13, /* SUPER */
154 YYSYMBOL_SUB = 14, /* SUB */
155 YYSYMBOL_CH = 15, /* CH */
156 YYSYMBOL_NUM = 16, /* NUM */
157 YYSYMBOL_SYM = 17, /* SYM */
158 YYSYMBOL_SCRIPT = 18, /* SCRIPT */
159 YYSYMBOL_STR = 19, /* STR */
160 YYSYMBOL_YYACCEPT = 20, /* $accept */
161 YYSYMBOL_simple_string = 21, /* simple_string */
162 YYSYMBOL_symbol_element = 22, /* symbol_element */
163 YYSYMBOL_font_modifier_element = 23, /* font_modifier_element */
164 YYSYMBOL_fontsize_element = 24, /* fontsize_element */
165 YYSYMBOL_fontname_element = 25, /* fontname_element */
166 YYSYMBOL_color_element = 26, /* color_element */
167 YYSYMBOL_string_element = 27, /* string_element */
168 YYSYMBOL_superscript_element = 28, /* superscript_element */
169 YYSYMBOL_subscript_element = 29, /* subscript_element */
170 YYSYMBOL_combined_script_element = 30, /* combined_script_element */
171 YYSYMBOL_string_element_list = 31, /* string_element_list */
172 YYSYMBOL_scoped_string_element_list = 32, /* scoped_string_element_list */
173 YYSYMBOL_string = 33 /* string */
176
177
178
179
180#ifdef short
181# undef short
182#endif
183
184/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
185 <limits.h> and (if available) <stdint.h> are included
186 so that the code can choose integer types of a good width. */
187
188#ifndef __PTRDIFF_MAX__
189# include <limits.h> /* INFRINGES ON USER NAME SPACE */
190# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
191# include <stdint.h> /* INFRINGES ON USER NAME SPACE */
192# define YY_STDINT_H
193# endif
194#endif
195
196/* Narrow types that promote to a signed type and that can represent a
197 signed or unsigned integer of at least N bits. In tables they can
198 save space and decrease cache pressure. Promoting to a signed type
199 helps avoid bugs in integer arithmetic. */
200
201#ifdef __INT_LEAST8_MAX__
202typedef __INT_LEAST8_TYPE__ yytype_int8;
203#elif defined YY_STDINT_H
204typedef int_least8_t yytype_int8;
205#else
206typedef signed char yytype_int8;
207#endif
208
209#ifdef __INT_LEAST16_MAX__
210typedef __INT_LEAST16_TYPE__ yytype_int16;
211#elif defined YY_STDINT_H
212typedef int_least16_t yytype_int16;
213#else
214typedef short yytype_int16;
215#endif
216
217/* Work around bug in HP-UX 11.23, which defines these macros
218 incorrectly for preprocessor constants. This workaround can likely
219 be removed in 2023, as HPE has promised support for HP-UX 11.23
220 (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
221 <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
222#ifdef __hpux
223# undef UINT_LEAST8_MAX
224# undef UINT_LEAST16_MAX
225# define UINT_LEAST8_MAX 255
226# define UINT_LEAST16_MAX 65535
227#endif
228
229#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
230typedef __UINT_LEAST8_TYPE__ yytype_uint8;
231#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
232 && UINT_LEAST8_MAX <= INT_MAX)
233typedef uint_least8_t yytype_uint8;
234#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
235typedef unsigned char yytype_uint8;
236#else
237typedef short yytype_uint8;
238#endif
239
240#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
241typedef __UINT_LEAST16_TYPE__ yytype_uint16;
242#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
243 && UINT_LEAST16_MAX <= INT_MAX)
244typedef uint_least16_t yytype_uint16;
245#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
246typedef unsigned short yytype_uint16;
247#else
248typedef int yytype_uint16;
249#endif
250
251#ifndef YYPTRDIFF_T
252# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
253# define YYPTRDIFF_T __PTRDIFF_TYPE__
254# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
255# elif defined PTRDIFF_MAX
256# ifndef ptrdiff_t
257# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
258# endif
259# define YYPTRDIFF_T ptrdiff_t
260# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
261# else
262# define YYPTRDIFF_T long
263# define YYPTRDIFF_MAXIMUM LONG_MAX
264# endif
265#endif
266
267#ifndef YYSIZE_T
268# ifdef __SIZE_TYPE__
269# define YYSIZE_T __SIZE_TYPE__
270# elif defined size_t
271# define YYSIZE_T size_t
272# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
273# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
274# define YYSIZE_T size_t
275# else
276# define YYSIZE_T unsigned
277# endif
278#endif
279
280#define YYSIZE_MAXIMUM \
281 YY_CAST (YYPTRDIFF_T, \
282 (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
283 ? YYPTRDIFF_MAXIMUM \
284 : YY_CAST (YYSIZE_T, -1)))
285
286#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
287
288
289/* Stored state numbers (used for stacks). */
291
292/* State numbers in computations. */
293typedef int yy_state_fast_t;
294
295#ifndef YY_
296# if defined YYENABLE_NLS && YYENABLE_NLS
297# if ENABLE_NLS
298# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
299# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
300# endif
301# endif
302# ifndef YY_
303# define YY_(Msgid) Msgid
304# endif
305#endif
306
307
308#ifndef YY_ATTRIBUTE_PURE
309# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
310# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
311# else
312# define YY_ATTRIBUTE_PURE
313# endif
314#endif
315
316#ifndef YY_ATTRIBUTE_UNUSED
317# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
318# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
319# else
320# define YY_ATTRIBUTE_UNUSED
321# endif
322#endif
323
324/* Suppress unused-variable warnings by "using" E. */
325#if ! defined lint || defined __GNUC__
326# define YY_USE(E) ((void) (E))
327#else
328# define YY_USE(E) /* empty */
329#endif
330
331/* Suppress an incorrect diagnostic about yylval being uninitialized. */
332#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
333# if __GNUC__ * 100 + __GNUC_MINOR__ < 407
334# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
335 _Pragma ("GCC diagnostic push") \
336 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
337# else
338# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
339 _Pragma ("GCC diagnostic push") \
340 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
341 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
342# endif
343# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
344 _Pragma ("GCC diagnostic pop")
345#else
346# define YY_INITIAL_VALUE(Value) Value
347#endif
348#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
349# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
350# define YY_IGNORE_MAYBE_UNINITIALIZED_END
351#endif
352#ifndef YY_INITIAL_VALUE
353# define YY_INITIAL_VALUE(Value) /* Nothing. */
354#endif
355
356#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
357# define YY_IGNORE_USELESS_CAST_BEGIN \
358 _Pragma ("GCC diagnostic push") \
359 _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
360# define YY_IGNORE_USELESS_CAST_END \
361 _Pragma ("GCC diagnostic pop")
362#endif
363#ifndef YY_IGNORE_USELESS_CAST_BEGIN
364# define YY_IGNORE_USELESS_CAST_BEGIN
365# define YY_IGNORE_USELESS_CAST_END
366#endif
367
368
369#define YY_ASSERT(E) ((void) (0 && (E)))
370
371#if !defined yyoverflow
372
373/* The parser invokes alloca or malloc; define the necessary symbols. */
374
375# ifdef YYSTACK_ALLOC
376 /* Pacify GCC's 'empty if-body' warning. */
377# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
378# ifndef YYSTACK_ALLOC_MAXIMUM
379 /* The OS might guarantee only one guard page at the bottom of the stack,
380 and a page size can be as small as 4096 bytes. So we cannot safely
381 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
382 to allow for a few compiler-allocated temporary stack slots. */
383# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
384# endif
385# else
386# define YYSTACK_ALLOC YYMALLOC
387# define YYSTACK_FREE YYFREE
388# ifndef YYSTACK_ALLOC_MAXIMUM
389# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
390# endif
391# if (defined __cplusplus && ! defined EXIT_SUCCESS \
392 && ! ((defined YYMALLOC || defined malloc) \
393 && (defined YYFREE || defined free)))
394# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
395# ifndef EXIT_SUCCESS
396# define EXIT_SUCCESS 0
397# endif
398# endif
399# ifndef YYMALLOC
400# define YYMALLOC malloc
401# if ! defined malloc && ! defined EXIT_SUCCESS
402void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
403# endif
404# endif
405# ifndef YYFREE
406# define YYFREE free
407# if ! defined free && ! defined EXIT_SUCCESS
408void free (void *); /* INFRINGES ON USER NAME SPACE */
409# endif
410# endif
411# endif
412#endif /* !defined yyoverflow */
413
414#if (! defined yyoverflow \
415 && (! defined __cplusplus \
416 || (defined OCTAVE_TEX_STYPE_IS_TRIVIAL && OCTAVE_TEX_STYPE_IS_TRIVIAL)))
417
418/* A type that is properly aligned for any stack member. */
419union yyalloc
420{
421 yy_state_t yyss_alloc;
422 YYSTYPE yyvs_alloc;
423};
424
425/* The size of the maximum gap between one aligned stack and the next. */
426# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
427
428/* The size of an array large to enough to hold all stacks, each with
429 N elements. */
430# define YYSTACK_BYTES(N) \
431 ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
432 + YYSTACK_GAP_MAXIMUM)
433
434# define YYCOPY_NEEDED 1
435
436/* Relocate STACK from its old location to the new one. The
437 local variables YYSIZE and YYSTACKSIZE give the old and new number of
438 elements in the stack, and YYPTR gives the new location of the
439 stack. Advance YYPTR to a properly aligned location for the next
440 stack. */
441# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
442 do \
443 { \
444 YYPTRDIFF_T yynewbytes; \
445 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
446 Stack = &yyptr->Stack_alloc; \
447 yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
448 yyptr += yynewbytes / YYSIZEOF (*yyptr); \
449 } \
450 while (0)
451
452#endif
453
454#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
455/* Copy COUNT objects from SRC to DST. The source and destination do
456 not overlap. */
457# ifndef YYCOPY
458# if defined __GNUC__ && 1 < __GNUC__
459# define YYCOPY(Dst, Src, Count) \
460 __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
461# else
462# define YYCOPY(Dst, Src, Count) \
463 do \
464 { \
465 YYPTRDIFF_T yyi; \
466 for (yyi = 0; yyi < (Count); yyi++) \
467 (Dst)[yyi] = (Src)[yyi]; \
468 } \
469 while (0)
470# endif
471# endif
472#endif /* !YYCOPY_NEEDED */
473
474/* YYFINAL -- State number of the termination state. */
475#define YYFINAL 43
476/* YYLAST -- Last index in YYTABLE. */
477#define YYLAST 81
478
479/* YYNTOKENS -- Number of terminals. */
480#define YYNTOKENS 20
481/* YYNNTS -- Number of nonterminals. */
482#define YYNNTS 14
483/* YYNRULES -- Number of rules. */
484#define YYNRULES 36
485/* YYNSTATES -- Number of states. */
486#define YYNSTATES 55
487
488/* YYMAXUTOK -- Last valid token kind. */
489#define YYMAXUTOK 274
490
491
492/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
493 as returned by yylex, with out-of-bounds checking. */
494#define YYTRANSLATE(YYX) \
495 (0 <= (YYX) && (YYX) <= YYMAXUTOK \
496 ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
497 : YYSYMBOL_YYUNDEF)
498
499/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
500 as returned by yylex. */
501static const yytype_int8 yytranslate[] =
502{
503 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
504 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
505 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
506 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
507 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
508 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
509 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
510 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
511 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
512 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
513 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
514 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
515 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
516 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
517 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
518 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
519 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
520 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
521 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
522 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
523 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
524 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
525 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
526 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
527 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
528 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
529 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
530 15, 16, 17, 18, 19
531};
532
533#if OCTAVE_TEX_DEBUG
534/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
535static const yytype_uint8 yyrline[] =
536{
537 0, 109, 109, 111, 115, 119, 121, 123, 125, 129,
538 133, 140, 145, 151, 156, 158, 159, 160, 161, 162,
539 163, 164, 165, 168, 170, 172, 176, 178, 180, 184,
540 186, 190, 192, 197, 199, 204, 205
541};
542#endif
543
544/** Accessing symbol of state STATE. */
545#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
546
547#if OCTAVE_TEX_DEBUG || 0
548/* The user-facing name of the symbol whose (internal) number is
549 YYSYMBOL. No bounds checking. */
550static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
551
552/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
553 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
554static const char *const yytname[] =
555{
556 "\"end of file\"", "error", "\"invalid token\"", "BF", "IT", "SL", "RM",
557 "FONTNAME", "FONTSIZE", "COLOR", "COLOR_RGB", "START", "END", "SUPER",
558 "SUB", "CH", "NUM", "SYM", "SCRIPT", "STR", "$accept", "simple_string",
559 "symbol_element", "font_modifier_element", "fontsize_element",
560 "fontname_element", "color_element", "string_element",
561 "superscript_element", "subscript_element", "combined_script_element",
562 "string_element_list", "scoped_string_element_list", "string", YY_NULLPTR
563};
564
565static const char *
566yysymbol_name (yysymbol_kind_t yysymbol)
567{
568 return yytname[yysymbol];
569}
570#endif
571
572#define YYPACT_NINF (-4)
573
574#define yypact_value_is_default(Yyn) \
575 ((Yyn) == YYPACT_NINF)
576
577#define YYTABLE_NINF (-1)
578
579#define yytable_value_is_error(Yyn) \
580 0
581
582/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
583 STATE-NUM. */
584static const yytype_int8 yypact[] =
585{
586 27, -4, -4, -4, -4, 2, 17, 32, 37, -3,
587 34, 35, -4, -4, 40, -4, -4, -4, -4, -4,
588 -4, 45, 52, -4, 27, -4, 66, 54, 55, 54,
589 56, -4, 12, -4, -4, -4, -4, -4, -4, -4,
590 -4, -4, -4, -4, 41, 58, 42, 57, -4, -4,
591 -4, -4, 59, 62, -4
592};
593
594/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
595 Performed when YYTABLE does not specify something else to do. Zero
596 means the default is an error. */
597static const yytype_int8 yydefact[] =
598{
599 35, 5, 6, 7, 8, 0, 0, 0, 0, 0,
600 0, 0, 2, 4, 13, 15, 16, 17, 18, 19,
601 31, 20, 21, 22, 36, 14, 0, 0, 0, 0,
602 0, 34, 0, 23, 25, 24, 26, 28, 27, 3,
603 30, 29, 32, 1, 0, 0, 0, 0, 33, 10,
604 9, 11, 0, 0, 12
605};
606
607/* YYPGOTO[NTERM-NUM]. */
608static const yytype_int8 yypgoto[] =
609{
610 -4, 31, 51, -4, -4, -4, -4, 15, 46, 60,
611 -4, 67, 53, -4
612};
613
614/* YYDEFGOTO[NTERM-NUM]. */
615static const yytype_int8 yydefgoto[] =
616{
617 0, 14, 15, 16, 17, 18, 19, 20, 21, 22,
618 23, 24, 25, 26
619};
620
621/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
622 positive, shift that token. If negative, reduce the rule whose
623 number is the opposite. If YYTABLE_NINF, syntax error. */
624static const yytype_int8 yytable[] =
625{
626 1, 2, 3, 4, 5, 6, 7, 8, 9, 31,
627 10, 11, 12, 27, 13, 1, 2, 3, 4, 5,
628 6, 7, 8, 9, 48, 10, 11, 12, 28, 13,
629 1, 2, 3, 4, 5, 6, 7, 8, 9, 42,
630 10, 11, 12, 29, 13, 9, 9, 42, 30, 33,
631 36, 13, 13, 49, 51, 39, 39, 39, 44, 11,
632 46, 34, 37, 35, 38, 10, 43, 0, 41, 12,
633 50, 45, 47, 52, 54, 53, 32, 0, 0, 0,
634 0, 40
635};
636
637static const yytype_int8 yycheck[] =
638{
639 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
640 13, 14, 15, 11, 17, 3, 4, 5, 6, 7,
641 8, 9, 10, 11, 12, 13, 14, 15, 11, 17,
642 3, 4, 5, 6, 7, 8, 9, 10, 11, 24,
643 13, 14, 15, 11, 17, 11, 11, 32, 11, 15,
644 15, 17, 17, 12, 12, 15, 15, 15, 27, 14,
645 29, 10, 11, 10, 11, 13, 0, -1, 22, 15,
646 12, 16, 16, 16, 12, 16, 9, -1, -1, -1,
647 -1, 21
648};
649
650/* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
651 state STATE-NUM. */
652static const yytype_int8 yystos[] =
653{
654 0, 3, 4, 5, 6, 7, 8, 9, 10, 11,
655 13, 14, 15, 17, 21, 22, 23, 24, 25, 26,
656 27, 28, 29, 30, 31, 32, 33, 11, 11, 11,
657 11, 12, 31, 15, 22, 32, 15, 22, 32, 15,
658 29, 28, 27, 0, 21, 16, 21, 16, 12, 12,
659 12, 12, 16, 16, 12
660};
661
662/* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */
663static const yytype_int8 yyr1[] =
664{
665 0, 20, 21, 21, 22, 23, 23, 23, 23, 24,
666 25, 26, 26, 27, 27, 27, 27, 27, 27, 27,
667 27, 27, 27, 28, 28, 28, 29, 29, 29, 30,
668 30, 31, 31, 32, 32, 33, 33
669};
670
671/* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */
672static const yytype_int8 yyr2[] =
673{
674 0, 2, 1, 2, 1, 1, 1, 1, 1, 4,
675 4, 4, 6, 1, 1, 1, 1, 1, 1, 1,
676 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
677 2, 1, 2, 3, 2, 0, 1
678};
679
680
681enum { YYENOMEM = -2 };
682
683#define yyerrok (yyerrstatus = 0)
684#define yyclearin (yychar = OCTAVE_TEX_EMPTY)
685
686#define YYACCEPT goto yyacceptlab
687#define YYABORT goto yyabortlab
688#define YYERROR goto yyerrorlab
689#define YYNOMEM goto yyexhaustedlab
690
691
692#define YYRECOVERING() (!!yyerrstatus)
693
694#define YYBACKUP(Token, Value) \
695 do \
696 if (yychar == OCTAVE_TEX_EMPTY) \
697 { \
698 yychar = (Token); \
699 yylval = (Value); \
700 YYPOPSTACK (yylen); \
701 yystate = *yyssp; \
702 goto yybackup; \
703 } \
704 else \
705 { \
706 yyerror (parser, YY_("syntax error: cannot back up")); \
707 YYERROR; \
708 } \
709 while (0)
710
711/* Backward compatibility with an undocumented macro.
712 Use OCTAVE_TEX_error or OCTAVE_TEX_UNDEF. */
713#define YYERRCODE OCTAVE_TEX_UNDEF
714
715
716/* Enable debugging if requested. */
717#if OCTAVE_TEX_DEBUG
718
719# ifndef YYFPRINTF
720# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
721# define YYFPRINTF fprintf
722# endif
723
724# define YYDPRINTF(Args) \
725do { \
726 if (yydebug) \
727 YYFPRINTF Args; \
728} while (0)
729
730
731
732
733# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
734do { \
735 if (yydebug) \
736 { \
737 YYFPRINTF (stderr, "%s ", Title); \
738 yy_symbol_print (stderr, \
739 Kind, Value, parser); \
740 YYFPRINTF (stderr, "\n"); \
741 } \
742} while (0)
743
744
745/*-----------------------------------.
746| Print this symbol's value on YYO. |
747`-----------------------------------*/
748
749static void
750yy_symbol_value_print (FILE *yyo,
751 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, octave::text_parser_tex& parser)
752{
753 FILE *yyoutput = yyo;
754 YY_USE (yyoutput);
755 YY_USE (parser);
756 if (!yyvaluep)
757 return;
759 YY_USE (yykind);
761}
762
763
764/*---------------------------.
765| Print this symbol on YYO. |
766`---------------------------*/
767
768static void
769yy_symbol_print (FILE *yyo,
770 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, octave::text_parser_tex& parser)
771{
772 YYFPRINTF (yyo, "%s %s (",
773 yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
774
775 yy_symbol_value_print (yyo, yykind, yyvaluep, parser);
776 YYFPRINTF (yyo, ")");
777}
778
779/*------------------------------------------------------------------.
780| yy_stack_print -- Print the state stack from its BOTTOM up to its |
781| TOP (included). |
782`------------------------------------------------------------------*/
783
784static void
785yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
786{
787 YYFPRINTF (stderr, "Stack now");
788 for (; yybottom <= yytop; yybottom++)
789 {
790 int yybot = *yybottom;
791 YYFPRINTF (stderr, " %d", yybot);
792 }
793 YYFPRINTF (stderr, "\n");
794}
795
796# define YY_STACK_PRINT(Bottom, Top) \
797do { \
798 if (yydebug) \
799 yy_stack_print ((Bottom), (Top)); \
800} while (0)
801
802
803/*------------------------------------------------.
804| Report that the YYRULE is going to be reduced. |
805`------------------------------------------------*/
806
807static void
808yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
809 int yyrule, octave::text_parser_tex& parser)
810{
811 int yylno = yyrline[yyrule];
812 int yynrhs = yyr2[yyrule];
813 int yyi;
814 YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
815 yyrule - 1, yylno);
816 /* The symbols being reduced. */
817 for (yyi = 0; yyi < yynrhs; yyi++)
818 {
819 YYFPRINTF (stderr, " $%d = ", yyi + 1);
820 yy_symbol_print (stderr,
821 YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
822 &yyvsp[(yyi + 1) - (yynrhs)], parser);
823 YYFPRINTF (stderr, "\n");
824 }
825}
826
827# define YY_REDUCE_PRINT(Rule) \
828do { \
829 if (yydebug) \
830 yy_reduce_print (yyssp, yyvsp, Rule, parser); \
831} while (0)
832
833/* Nonzero means print parse trace. It is left uninitialized so that
834 multiple parsers can coexist. */
835int yydebug;
836#else /* !OCTAVE_TEX_DEBUG */
837# define YYDPRINTF(Args) ((void) 0)
838# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
839# define YY_STACK_PRINT(Bottom, Top)
840# define YY_REDUCE_PRINT(Rule)
841#endif /* !OCTAVE_TEX_DEBUG */
842
843
844/* YYINITDEPTH -- initial size of the parser's stacks. */
845#ifndef YYINITDEPTH
846# define YYINITDEPTH 200
847#endif
848
849/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
850 if the built-in stack extension method is used).
851
852 Do not make this value too large; the results are undefined if
853 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
854 evaluated with infinite-precision integer arithmetic. */
855
856#ifndef YYMAXDEPTH
857# define YYMAXDEPTH 10000
858#endif
859/* Parser data structure. */
860struct yypstate
861 {
862 /* Number of syntax errors so far. */
863 int yynerrs;
864
866 /* Number of tokens to shift before error messages enabled. */
867 int yyerrstatus;
868
869 /* Refer to the stacks through separate pointers, to allow yyoverflow
870 to reallocate them elsewhere. */
871
872 /* Their size. */
874
875 /* The state stack: array, bottom, top. */
879
880 /* The semantic value stack: array, bottom, top. */
882 YYSTYPE *yyvs;
883 YYSTYPE *yyvsp;
884 /* Whether this instance has not started parsing yet.
885 * If 2, it corresponds to a finished parsing. */
886 int yynew;
887 };
888
889
890
891
892
893
894/*-----------------------------------------------.
895| Release the memory associated to this symbol. |
896`-----------------------------------------------*/
897
898static void
899yydestruct (const char *yymsg,
900 yysymbol_kind_t yykind, YYSTYPE *yyvaluep, octave::text_parser_tex& parser)
901{
902 YY_USE (yyvaluep);
903 YY_USE (parser);
904 if (!yymsg)
905 yymsg = "Deleting";
906 YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
907
909 switch (yykind)
910 {
911 case YYSYMBOL_CH: /* CH */
912#line 96 "../libinterp/corefcn/oct-tex-parser.yy"
913 { }
914#line 915 "libinterp/corefcn/oct-tex-parser.cc"
915 break;
916
917 case YYSYMBOL_NUM: /* NUM */
918#line 96 "../libinterp/corefcn/oct-tex-parser.yy"
919 { }
920#line 921 "libinterp/corefcn/oct-tex-parser.cc"
921 break;
922
923 case YYSYMBOL_SYM: /* SYM */
924#line 96 "../libinterp/corefcn/oct-tex-parser.yy"
925 { }
926#line 927 "libinterp/corefcn/oct-tex-parser.cc"
927 break;
928
929 case YYSYMBOL_simple_string: /* simple_string */
930#line 97 "../libinterp/corefcn/oct-tex-parser.yy"
931 { delete ((*yyvaluep).str); }
932#line 933 "libinterp/corefcn/oct-tex-parser.cc"
933 break;
934
935 case YYSYMBOL_symbol_element: /* symbol_element */
936#line 97 "../libinterp/corefcn/oct-tex-parser.yy"
937 { delete ((*yyvaluep).e_base); }
938#line 939 "libinterp/corefcn/oct-tex-parser.cc"
939 break;
940
941 case YYSYMBOL_font_modifier_element: /* font_modifier_element */
942#line 97 "../libinterp/corefcn/oct-tex-parser.yy"
943 { delete ((*yyvaluep).e_base); }
944#line 945 "libinterp/corefcn/oct-tex-parser.cc"
945 break;
946
947 case YYSYMBOL_fontsize_element: /* fontsize_element */
948#line 97 "../libinterp/corefcn/oct-tex-parser.yy"
949 { delete ((*yyvaluep).e_base); }
950#line 951 "libinterp/corefcn/oct-tex-parser.cc"
951 break;
952
953 case YYSYMBOL_fontname_element: /* fontname_element */
954#line 97 "../libinterp/corefcn/oct-tex-parser.yy"
955 { delete ((*yyvaluep).e_base); }
956#line 957 "libinterp/corefcn/oct-tex-parser.cc"
957 break;
958
959 case YYSYMBOL_color_element: /* color_element */
960#line 97 "../libinterp/corefcn/oct-tex-parser.yy"
961 { delete ((*yyvaluep).e_base); }
962#line 963 "libinterp/corefcn/oct-tex-parser.cc"
963 break;
964
965 case YYSYMBOL_string_element: /* string_element */
966#line 97 "../libinterp/corefcn/oct-tex-parser.yy"
967 { delete ((*yyvaluep).e_base); }
968#line 969 "libinterp/corefcn/oct-tex-parser.cc"
969 break;
970
971 case YYSYMBOL_superscript_element: /* superscript_element */
972#line 97 "../libinterp/corefcn/oct-tex-parser.yy"
973 { delete ((*yyvaluep).e_base); }
974#line 975 "libinterp/corefcn/oct-tex-parser.cc"
975 break;
976
977 case YYSYMBOL_subscript_element: /* subscript_element */
978#line 97 "../libinterp/corefcn/oct-tex-parser.yy"
979 { delete ((*yyvaluep).e_base); }
980#line 981 "libinterp/corefcn/oct-tex-parser.cc"
981 break;
982
983 case YYSYMBOL_combined_script_element: /* combined_script_element */
984#line 97 "../libinterp/corefcn/oct-tex-parser.yy"
985 { delete ((*yyvaluep).e_base); }
986#line 987 "libinterp/corefcn/oct-tex-parser.cc"
987 break;
988
989 case YYSYMBOL_string_element_list: /* string_element_list */
990#line 97 "../libinterp/corefcn/oct-tex-parser.yy"
991 { delete ((*yyvaluep).e_list); }
992#line 993 "libinterp/corefcn/oct-tex-parser.cc"
993 break;
994
995 case YYSYMBOL_scoped_string_element_list: /* scoped_string_element_list */
996#line 97 "../libinterp/corefcn/oct-tex-parser.yy"
997 { delete ((*yyvaluep).e_list); }
998#line 999 "libinterp/corefcn/oct-tex-parser.cc"
999 break;
1000
1001 default:
1002 break;
1003 }
1005}
1006
1007
1008
1009
1010
1011int
1012yyparse (octave::text_parser_tex& parser)
1013{
1014 yypstate *yyps = yypstate_new ();
1015 if (!yyps)
1016 {
1017 yyerror (parser, YY_("memory exhausted"));
1018 return 2;
1019 }
1020 int yystatus = yypull_parse (yyps, parser);
1021 yypstate_delete (yyps);
1022 return yystatus;
1023}
1024
1025int
1026yypull_parse (yypstate *yyps, octave::text_parser_tex& parser)
1027{
1028 YY_ASSERT (yyps);
1029 int yystatus;
1030 do {
1032 int yychar = yylex (&yylval, m_scanner);
1033 yystatus = yypush_parse (yyps, yychar, &yylval, parser);
1034 } while (yystatus == YYPUSH_MORE);
1035 return yystatus;
1036}
1037
1038#define octave_tex_nerrs yyps->octave_tex_nerrs
1039#define yystate yyps->yystate
1040#define yyerrstatus yyps->yyerrstatus
1041#define yyssa yyps->yyssa
1042#define yyss yyps->yyss
1043#define yyssp yyps->yyssp
1044#define yyvsa yyps->yyvsa
1045#define yyvs yyps->yyvs
1046#define yyvsp yyps->yyvsp
1047#define yystacksize yyps->yystacksize
1048
1049/* Initialize the parser data structure. */
1050static void
1052{
1053 yynerrs = 0;
1054 yystate = 0;
1055 yyerrstatus = 0;
1056
1057 yyssp = yyss;
1058 yyvsp = yyvs;
1059
1060 /* Initialize the state stack, in case yypcontext_expected_tokens is
1061 called before the first call to yyparse. */
1062 *yyssp = 0;
1063 yyps->yynew = 1;
1064}
1065
1066/* Initialize the parser data structure. */
1067yypstate *
1069{
1070 yypstate *yyps;
1071 yyps = YY_CAST (yypstate *, YYMALLOC (sizeof *yyps));
1072 if (!yyps)
1073 return YY_NULLPTR;
1075 yyss = yyssa;
1076 yyvs = yyvsa;
1077 yypstate_clear (yyps);
1078 return yyps;
1079}
1080
1081void
1083{
1084 if (yyps)
1085 {
1086#ifndef yyoverflow
1087 /* If the stack was reallocated but the parse did not complete, then the
1088 stack still needs to be freed. */
1089 if (yyss != yyssa)
1091#endif
1092 YYFREE (yyps);
1093 }
1094}
1095
1096
1097
1098/*---------------.
1099| yypush_parse. |
1100`---------------*/
1101
1102int
1104 int yypushed_char, YYSTYPE const *yypushed_val, octave::text_parser_tex& parser)
1105{
1106/* Lookahead token kind. */
1107int yychar;
1108
1109
1110/* The semantic value of the lookahead symbol. */
1111/* Default value used for initialization, for pacifying older GCCs
1112 or non-GCC compilers. */
1113YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1114YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1115
1116 int yyn;
1117 /* The return value of yyparse. */
1118 int yyresult;
1119 /* Lookahead symbol kind. */
1121 /* The variables used to return semantic value and location from the
1122 action routines. */
1123 YYSTYPE yyval;
1124
1125
1126
1127#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1128
1129 /* The number of symbols on the RHS of the reduced rule.
1130 Keep to zero when no symbol should be popped. */
1131 int yylen = 0;
1132
1133 switch (yyps->yynew)
1134 {
1135 case 0:
1136 yyn = yypact[yystate];
1137 goto yyread_pushed_token;
1138
1139 case 2:
1140 yypstate_clear (yyps);
1141 break;
1142
1143 default:
1144 break;
1145 }
1146
1147 YYDPRINTF ((stderr, "Starting parse\n"));
1148
1149 yychar = OCTAVE_TEX_EMPTY; /* Cause a token to be read. */
1150
1151 goto yysetstate;
1152
1153
1154/*------------------------------------------------------------.
1155| yynewstate -- push a new state, which is found in yystate. |
1156`------------------------------------------------------------*/
1157yynewstate:
1158 /* In all cases, when you get here, the value and location stacks
1159 have just been pushed. So pushing a state here evens the stacks. */
1160 yyssp++;
1161
1162
1163/*--------------------------------------------------------------------.
1164| yysetstate -- set current state (the top of the stack) to yystate. |
1165`--------------------------------------------------------------------*/
1166yysetstate:
1167 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1168 YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1173
1174 if (yyss + yystacksize - 1 <= yyssp)
1175#if !defined yyoverflow && !defined YYSTACK_RELOCATE
1176 YYNOMEM;
1177#else
1178 {
1179 /* Get the current used size of the three stacks, in elements. */
1180 YYPTRDIFF_T yysize = yyssp - yyss + 1;
1181
1182# if defined yyoverflow
1183 {
1184 /* Give user a chance to reallocate the stack. Use copies of
1185 these so that the &'s don't force the real ones into
1186 memory. */
1187 yy_state_t *yyss1 = yyss;
1188 YYSTYPE *yyvs1 = yyvs;
1189
1190 /* Each stack pointer address is followed by the size of the
1191 data in use in that stack, in bytes. This used to be a
1192 conditional around just the two extra args, but that might
1193 be undefined if yyoverflow is a macro. */
1194 yyoverflow (YY_("memory exhausted"),
1195 &yyss1, yysize * YYSIZEOF (*yyssp),
1196 &yyvs1, yysize * YYSIZEOF (*yyvsp),
1197 &yystacksize);
1198 yyss = yyss1;
1199 yyvs = yyvs1;
1200 }
1201# else /* defined YYSTACK_RELOCATE */
1202 /* Extend the stack our own way. */
1203 if (YYMAXDEPTH <= yystacksize)
1204 YYNOMEM;
1205 yystacksize *= 2;
1206 if (YYMAXDEPTH < yystacksize)
1208
1209 {
1210 yy_state_t *yyss1 = yyss;
1211 union yyalloc *yyptr =
1212 YY_CAST (union yyalloc *,
1214 if (! yyptr)
1215 YYNOMEM;
1216 YYSTACK_RELOCATE (yyss_alloc, yyss);
1217 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1218# undef YYSTACK_RELOCATE
1219 if (yyss1 != yyssa)
1220 YYSTACK_FREE (yyss1);
1221 }
1222# endif
1223
1224 yyssp = yyss + yysize - 1;
1225 yyvsp = yyvs + yysize - 1;
1226
1228 YYDPRINTF ((stderr, "Stack size increased to %ld\n",
1229 YY_CAST (long, yystacksize)));
1231
1232 if (yyss + yystacksize - 1 <= yyssp)
1233 YYABORT;
1234 }
1235#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1236
1237
1238 if (yystate == YYFINAL)
1239 YYACCEPT;
1240
1241 goto yybackup;
1242
1243
1244/*-----------.
1245| yybackup. |
1246`-----------*/
1247yybackup:
1248 /* Do appropriate processing given the current state. Read a
1249 lookahead token if we need one and don't already have one. */
1250
1251 /* First try to decide what to do without reference to lookahead token. */
1252 yyn = yypact[yystate];
1253 if (yypact_value_is_default (yyn))
1254 goto yydefault;
1255
1256 /* Not known => get a lookahead token if don't already have one. */
1257
1258 /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1259 if (yychar == OCTAVE_TEX_EMPTY)
1260 {
1261 if (!yyps->yynew)
1262 {
1263 YYDPRINTF ((stderr, "Return for a new token:\n"));
1264 yyresult = YYPUSH_MORE;
1265 goto yypushreturn;
1266 }
1267 yyps->yynew = 0;
1268yyread_pushed_token:
1269 YYDPRINTF ((stderr, "Reading a token\n"));
1270 yychar = yypushed_char;
1271 if (yypushed_val)
1272 yylval = *yypushed_val;
1273 }
1274
1275 if (yychar <= OCTAVE_TEX_EOF)
1276 {
1277 yychar = OCTAVE_TEX_EOF;
1278 yytoken = YYSYMBOL_YYEOF;
1279 YYDPRINTF ((stderr, "Now at end of input.\n"));
1280 }
1281 else if (yychar == OCTAVE_TEX_error)
1282 {
1283 /* The scanner already issued an error message, process directly
1284 to error recovery. But do not keep the error token as
1285 lookahead, it is too special and may lead us to an endless
1286 loop in error recovery. */
1287 yychar = OCTAVE_TEX_UNDEF;
1288 yytoken = YYSYMBOL_YYerror;
1289 goto yyerrlab1;
1290 }
1291 else
1292 {
1293 yytoken = YYTRANSLATE (yychar);
1294 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1295 }
1296
1297 /* If the proper action on seeing token YYTOKEN is to reduce or to
1298 detect an error, take that action. */
1299 yyn += yytoken;
1300 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1301 goto yydefault;
1302 yyn = yytable[yyn];
1303 if (yyn <= 0)
1304 {
1305 if (yytable_value_is_error (yyn))
1306 goto yyerrlab;
1307 yyn = -yyn;
1308 goto yyreduce;
1309 }
1310
1311 /* Count tokens shifted since error; after three, turn off error
1312 status. */
1313 if (yyerrstatus)
1314 yyerrstatus--;
1315
1316 /* Shift the lookahead token. */
1317 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1318 yystate = yyn;
1320 *++yyvsp = yylval;
1322
1323 /* Discard the shifted token. */
1324 yychar = OCTAVE_TEX_EMPTY;
1325 goto yynewstate;
1326
1327
1328/*-----------------------------------------------------------.
1329| yydefault -- do the default action for the current state. |
1330`-----------------------------------------------------------*/
1331yydefault:
1332 yyn = yydefact[yystate];
1333 if (yyn == 0)
1334 goto yyerrlab;
1335 goto yyreduce;
1336
1337
1338/*-----------------------------.
1339| yyreduce -- do a reduction. |
1340`-----------------------------*/
1341yyreduce:
1342 /* yyn is the number of a rule to reduce with. */
1343 yylen = yyr2[yyn];
1344
1345 /* If YYLEN is nonzero, implement the default value of the action:
1346 '$$ = $1'.
1347
1348 Otherwise, the following line sets YYVAL to garbage.
1349 This behavior is undocumented and Bison
1350 users should not rely upon it. Assigning to YYVAL
1351 unconditionally makes the parser a bit smaller, and it avoids a
1352 GCC warning that YYVAL may be used uninitialized. */
1353 yyval = yyvsp[1-yylen];
1354
1355
1356 YY_REDUCE_PRINT (yyn);
1357 switch (yyn)
1358 {
1359 case 2: /* simple_string: CH */
1360#line 110 "../libinterp/corefcn/oct-tex-parser.yy"
1361 { (yyval.str) = new std::string (1, (yyvsp[0].ch)); }
1362#line 1363 "libinterp/corefcn/oct-tex-parser.cc"
1363 break;
1364
1365 case 3: /* simple_string: simple_string CH */
1366#line 112 "../libinterp/corefcn/oct-tex-parser.yy"
1367 { (yyvsp[-1].str)->append (1, (yyvsp[0].ch)); (yyval.str) = (yyvsp[-1].str); }
1368#line 1369 "libinterp/corefcn/oct-tex-parser.cc"
1369 break;
1370
1371 case 4: /* symbol_element: SYM */
1372#line 116 "../libinterp/corefcn/oct-tex-parser.yy"
1373 { (yyval.e_base) = new octave::text_element_symbol ((yyvsp[0].sym)); }
1374#line 1375 "libinterp/corefcn/oct-tex-parser.cc"
1375 break;
1376
1377 case 5: /* font_modifier_element: BF */
1378#line 120 "../libinterp/corefcn/oct-tex-parser.yy"
1379 { (yyval.e_base) = new octave::text_element_fontstyle (octave::text_element_fontstyle::bold); }
1380#line 1381 "libinterp/corefcn/oct-tex-parser.cc"
1381 break;
1382
1383 case 6: /* font_modifier_element: IT */
1384#line 122 "../libinterp/corefcn/oct-tex-parser.yy"
1385 { (yyval.e_base) = new octave::text_element_fontstyle (octave::text_element_fontstyle::italic); }
1386#line 1387 "libinterp/corefcn/oct-tex-parser.cc"
1387 break;
1388
1389 case 7: /* font_modifier_element: SL */
1390#line 124 "../libinterp/corefcn/oct-tex-parser.yy"
1391 { (yyval.e_base) = new octave::text_element_fontstyle (octave::text_element_fontstyle::oblique); }
1392#line 1393 "libinterp/corefcn/oct-tex-parser.cc"
1393 break;
1394
1395 case 8: /* font_modifier_element: RM */
1396#line 126 "../libinterp/corefcn/oct-tex-parser.yy"
1397 { (yyval.e_base) = new octave::text_element_fontstyle (octave::text_element_fontstyle::normal); }
1398#line 1399 "libinterp/corefcn/oct-tex-parser.cc"
1399 break;
1400
1401 case 9: /* fontsize_element: FONTSIZE START NUM END */
1402#line 130 "../libinterp/corefcn/oct-tex-parser.yy"
1403 { (yyval.e_base) = new octave::text_element_fontsize ((yyvsp[-1].num)); }
1404#line 1405 "libinterp/corefcn/oct-tex-parser.cc"
1405 break;
1406
1407 case 10: /* fontname_element: FONTNAME START simple_string END */
1408#line 134 "../libinterp/corefcn/oct-tex-parser.yy"
1409 {
1410 (yyval.e_base) = new octave::text_element_fontname (*(yyvsp[-1].str));
1411 delete (yyvsp[-1].str);
1412 }
1413#line 1414 "libinterp/corefcn/oct-tex-parser.cc"
1414 break;
1415
1416 case 11: /* color_element: COLOR START simple_string END */
1417#line 141 "../libinterp/corefcn/oct-tex-parser.yy"
1418 {
1419 (yyval.e_base) = new octave::text_element_color (*(yyvsp[-1].str));
1420 delete (yyvsp[-1].str);
1421 }
1422#line 1423 "libinterp/corefcn/oct-tex-parser.cc"
1423 break;
1424
1425 case 12: /* color_element: COLOR_RGB START NUM NUM NUM END */
1426#line 146 "../libinterp/corefcn/oct-tex-parser.yy"
1427 {
1428 (yyval.e_base) = new octave::text_element_color ((yyvsp[-3].num), (yyvsp[-2].num), (yyvsp[-1].num));
1429 }
1430#line 1431 "libinterp/corefcn/oct-tex-parser.cc"
1431 break;
1432
1433 case 13: /* string_element: simple_string */
1434#line 152 "../libinterp/corefcn/oct-tex-parser.yy"
1435 {
1436 (yyval.e_base) = new octave::text_element_string (*(yyvsp[0].str));
1437 delete (yyvsp[0].str);
1438 }
1439#line 1440 "libinterp/corefcn/oct-tex-parser.cc"
1440 break;
1441
1442 case 14: /* string_element: scoped_string_element_list */
1443#line 157 "../libinterp/corefcn/oct-tex-parser.yy"
1444 { (yyval.e_base) = (yyvsp[0].e_list); }
1445#line 1446 "libinterp/corefcn/oct-tex-parser.cc"
1446 break;
1447
1448 case 23: /* superscript_element: SUPER CH */
1449#line 169 "../libinterp/corefcn/oct-tex-parser.yy"
1450 { (yyval.e_base) = new octave::text_element_superscript ((yyvsp[0].ch)); }
1451#line 1452 "libinterp/corefcn/oct-tex-parser.cc"
1452 break;
1453
1454 case 24: /* superscript_element: SUPER scoped_string_element_list */
1455#line 171 "../libinterp/corefcn/oct-tex-parser.yy"
1456 { (yyval.e_base) = new octave::text_element_superscript ((yyvsp[0].e_list)); }
1457#line 1458 "libinterp/corefcn/oct-tex-parser.cc"
1458 break;
1459
1460 case 25: /* superscript_element: SUPER symbol_element */
1461#line 173 "../libinterp/corefcn/oct-tex-parser.yy"
1462 { (yyval.e_base) = new octave::text_element_superscript ((yyvsp[0].e_base)); }
1463#line 1464 "libinterp/corefcn/oct-tex-parser.cc"
1464 break;
1465
1466 case 26: /* subscript_element: SUB CH */
1467#line 177 "../libinterp/corefcn/oct-tex-parser.yy"
1468 { (yyval.e_base) = new octave::text_element_subscript ((yyvsp[0].ch)); }
1469#line 1470 "libinterp/corefcn/oct-tex-parser.cc"
1470 break;
1471
1472 case 27: /* subscript_element: SUB scoped_string_element_list */
1473#line 179 "../libinterp/corefcn/oct-tex-parser.yy"
1474 { (yyval.e_base) = new octave::text_element_subscript ((yyvsp[0].e_list)); }
1475#line 1476 "libinterp/corefcn/oct-tex-parser.cc"
1476 break;
1477
1478 case 28: /* subscript_element: SUB symbol_element */
1479#line 181 "../libinterp/corefcn/oct-tex-parser.yy"
1480 { (yyval.e_base) = new octave::text_element_subscript ((yyvsp[0].e_base)); }
1481#line 1482 "libinterp/corefcn/oct-tex-parser.cc"
1482 break;
1483
1484 case 29: /* combined_script_element: subscript_element superscript_element */
1485#line 185 "../libinterp/corefcn/oct-tex-parser.yy"
1486 { (yyval.e_base) = new octave::text_element_combined ((yyvsp[-1].e_base), (yyvsp[0].e_base)); }
1487#line 1488 "libinterp/corefcn/oct-tex-parser.cc"
1488 break;
1489
1490 case 30: /* combined_script_element: superscript_element subscript_element */
1491#line 187 "../libinterp/corefcn/oct-tex-parser.yy"
1492 { (yyval.e_base) = new octave::text_element_combined ((yyvsp[-1].e_base), (yyvsp[0].e_base)); }
1493#line 1494 "libinterp/corefcn/oct-tex-parser.cc"
1494 break;
1495
1496 case 31: /* string_element_list: string_element */
1497#line 191 "../libinterp/corefcn/oct-tex-parser.yy"
1498 { (yyval.e_list) = new octave::text_element_list ((yyvsp[0].e_base)); }
1499#line 1500 "libinterp/corefcn/oct-tex-parser.cc"
1500 break;
1501
1502 case 32: /* string_element_list: string_element_list string_element */
1503#line 193 "../libinterp/corefcn/oct-tex-parser.yy"
1504 { (yyvsp[-1].e_list)->push_back ((yyvsp[0].e_base)); (yyval.e_list) = (yyvsp[-1].e_list); }
1505#line 1506 "libinterp/corefcn/oct-tex-parser.cc"
1506 break;
1507
1508 case 33: /* scoped_string_element_list: START string_element_list END */
1509#line 198 "../libinterp/corefcn/oct-tex-parser.yy"
1510 { (yyval.e_list) = (yyvsp[-1].e_list); }
1511#line 1512 "libinterp/corefcn/oct-tex-parser.cc"
1512 break;
1513
1514 case 34: /* scoped_string_element_list: START END */
1515#line 200 "../libinterp/corefcn/oct-tex-parser.yy"
1516 { (yyval.e_list) = new octave::text_element_list (); }
1517#line 1518 "libinterp/corefcn/oct-tex-parser.cc"
1518 break;
1519
1520 case 35: /* string: %empty */
1521#line 204 "../libinterp/corefcn/oct-tex-parser.yy"
1522 { parser.set_parse_result (new octave::text_element_string ("")); }
1523#line 1524 "libinterp/corefcn/oct-tex-parser.cc"
1524 break;
1525
1526 case 36: /* string: string_element_list */
1527#line 206 "../libinterp/corefcn/oct-tex-parser.yy"
1528 { parser.set_parse_result ((yyvsp[0].e_list)); }
1529#line 1530 "libinterp/corefcn/oct-tex-parser.cc"
1530 break;
1531
1532
1533#line 1534 "libinterp/corefcn/oct-tex-parser.cc"
1534
1535 default: break;
1536 }
1537 /* User semantic actions sometimes alter yychar, and that requires
1538 that yytoken be updated with the new translation. We take the
1539 approach of translating immediately before every use of yytoken.
1540 One alternative is translating here after every semantic action,
1541 but that translation would be missed if the semantic action invokes
1542 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1543 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1544 incorrect destructor might then be invoked immediately. In the
1545 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1546 to an incorrect destructor call or verbose syntax error message
1547 before the lookahead is translated. */
1548 YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
1549
1550 YYPOPSTACK (yylen);
1551 yylen = 0;
1552
1553 *++yyvsp = yyval;
1554
1555 /* Now 'shift' the result of the reduction. Determine what state
1556 that goes to, based on the state we popped back to and the rule
1557 number reduced by. */
1558 {
1559 const int yylhs = yyr1[yyn] - YYNTOKENS;
1560 const int yyi = yypgoto[yylhs] + *yyssp;
1561 yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
1562 ? yytable[yyi]
1563 : yydefgoto[yylhs]);
1564 }
1565
1566 goto yynewstate;
1567
1568
1569/*--------------------------------------.
1570| yyerrlab -- here on detecting error. |
1571`--------------------------------------*/
1572yyerrlab:
1573 /* Make sure we have latest lookahead translation. See comments at
1574 user semantic actions for why this is necessary. */
1575 yytoken = yychar == OCTAVE_TEX_EMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
1576 /* If not already recovering from an error, report this error. */
1577 if (!yyerrstatus)
1578 {
1579 ++yynerrs;
1580 yyerror (parser, YY_("syntax error"));
1581 }
1582
1583 if (yyerrstatus == 3)
1584 {
1585 /* If just tried and failed to reuse lookahead token after an
1586 error, discard it. */
1587
1588 if (yychar <= OCTAVE_TEX_EOF)
1589 {
1590 /* Return failure if at end of input. */
1591 if (yychar == OCTAVE_TEX_EOF)
1592 YYABORT;
1593 }
1594 else
1595 {
1596 yydestruct ("Error: discarding",
1597 yytoken, &yylval, parser);
1598 yychar = OCTAVE_TEX_EMPTY;
1599 }
1600 }
1601
1602 /* Else will try to reuse lookahead token after shifting the error
1603 token. */
1604 goto yyerrlab1;
1605
1606
1607/*---------------------------------------------------.
1608| yyerrorlab -- error raised explicitly by YYERROR. |
1609`---------------------------------------------------*/
1610yyerrorlab:
1611 /* Pacify compilers when the user code never invokes YYERROR and the
1612 label yyerrorlab therefore never appears in user code. */
1613 if (0)
1614 YYERROR;
1615 ++yynerrs;
1616
1617 /* Do not reclaim the symbols of the rule whose action triggered
1618 this YYERROR. */
1619 YYPOPSTACK (yylen);
1620 yylen = 0;
1622 yystate = *yyssp;
1623 goto yyerrlab1;
1624
1625
1626/*-------------------------------------------------------------.
1627| yyerrlab1 -- common code for both syntax error and YYERROR. |
1628`-------------------------------------------------------------*/
1629yyerrlab1:
1630 yyerrstatus = 3; /* Each real token shifted decrements this. */
1631
1632 /* Pop stack until we find a state that shifts the error token. */
1633 for (;;)
1634 {
1635 yyn = yypact[yystate];
1636 if (!yypact_value_is_default (yyn))
1637 {
1638 yyn += YYSYMBOL_YYerror;
1639 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
1640 {
1641 yyn = yytable[yyn];
1642 if (0 < yyn)
1643 break;
1644 }
1645 }
1646
1647 /* Pop the current state because it cannot handle the error token. */
1648 if (yyssp == yyss)
1649 YYABORT;
1650
1651
1652 yydestruct ("Error: popping",
1654 YYPOPSTACK (1);
1655 yystate = *yyssp;
1657 }
1658
1660 *++yyvsp = yylval;
1662
1663
1664 /* Shift the error token. */
1665 YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
1666
1667 yystate = yyn;
1668 goto yynewstate;
1669
1670
1671/*-------------------------------------.
1672| yyacceptlab -- YYACCEPT comes here. |
1673`-------------------------------------*/
1674yyacceptlab:
1675 yyresult = 0;
1676 goto yyreturnlab;
1677
1678
1679/*-----------------------------------.
1680| yyabortlab -- YYABORT comes here. |
1681`-----------------------------------*/
1682yyabortlab:
1683 yyresult = 1;
1684 goto yyreturnlab;
1685
1686
1687/*-----------------------------------------------------------.
1688| yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. |
1689`-----------------------------------------------------------*/
1690yyexhaustedlab:
1691 yyerror (parser, YY_("memory exhausted"));
1692 yyresult = 2;
1693 goto yyreturnlab;
1694
1695
1696/*----------------------------------------------------------.
1697| yyreturnlab -- parsing is finished, clean up and return. |
1698`----------------------------------------------------------*/
1699yyreturnlab:
1700 if (yychar != OCTAVE_TEX_EMPTY)
1701 {
1702 /* Make sure we have latest lookahead translation. See comments at
1703 user semantic actions for why this is necessary. */
1704 yytoken = YYTRANSLATE (yychar);
1705 yydestruct ("Cleanup: discarding lookahead",
1706 yytoken, &yylval, parser);
1707 }
1708 /* Do not reclaim the symbols of the rule whose action triggered
1709 this YYABORT or YYACCEPT. */
1710 YYPOPSTACK (yylen);
1712 while (yyssp != yyss)
1713 {
1714 yydestruct ("Cleanup: popping",
1716 YYPOPSTACK (1);
1717 }
1718 yyps->yynew = 2;
1719 goto yypushreturn;
1720
1721
1722/*-------------------------.
1723| yypushreturn -- return. |
1724`-------------------------*/
1725yypushreturn:
1726
1727 return yyresult;
1728}
1729#undef octave_tex_nerrs
1730#undef yystate
1731#undef yyerrstatus
1732#undef yyssa
1733#undef yyss
1734#undef yyssp
1735#undef yyvsa
1736#undef yyvs
1737#undef yyvsp
1738#undef yystacksize
1739#line 209 "../libinterp/corefcn/oct-tex-parser.yy"
1740
1741
1742#if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
1743 // Restore prevailing warning state for remainder of the file.
1744# pragma GCC diagnostic pop
1745#endif
1746
1748
1750 text_parser_tex::parse (const std::string& s)
1751 {
1752 octave_tex_debug = 0;
1753
1754 if (init_lexer (s))
1755 {
1756 m_result = nullptr;
1757
1758 if (octave_tex_parse (*this) == 0)
1759 return m_result;
1760 }
1761
1762 return new text_element_string (s);
1763 }
1764
1765OCTAVE_END_NAMESPACE(octave)
1766
1767static void
1768yyerror (octave::text_parser_tex&, const char *s)
1769{
1770 fprintf (stderr, "TeX parse error: %s\n", s);
1771}
text_element * parse(const std::string &s)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define YYSTYPE
#define yylval
#define yyss
#define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
#define YYMAXDEPTH
#define YYSTACK_FREE
yysymbol_kind_t
@ YYSYMBOL_END
@ YYSYMBOL_SUPER
@ YYSYMBOL_START
@ YYSYMBOL_YYUNDEF
@ YYSYMBOL_RM
@ YYSYMBOL_string_element_list
@ YYSYMBOL_fontsize_element
@ YYSYMBOL_YYerror
@ YYSYMBOL_scoped_string_element_list
@ YYSYMBOL_COLOR_RGB
@ YYSYMBOL_simple_string
@ YYSYMBOL_subscript_element
@ YYSYMBOL_superscript_element
@ YYSYMBOL_string
@ YYSYMBOL_CH
@ YYSYMBOL_IT
@ YYSYMBOL_COLOR
@ YYSYMBOL_fontname_element
@ YYSYMBOL_NUM
@ YYSYMBOL_combined_script_element
@ YYSYMBOL_SYM
@ YYSYMBOL_color_element
@ YYSYMBOL_YYACCEPT
@ YYSYMBOL_STR
@ YYSYMBOL_SUB
@ YYSYMBOL_YYEOF
@ YYSYMBOL_BF
@ YYSYMBOL_symbol_element
@ YYSYMBOL_FONTSIZE
@ YYSYMBOL_YYEMPTY
@ YYSYMBOL_string_element
@ YYSYMBOL_FONTNAME
@ YYSYMBOL_SCRIPT
@ YYSYMBOL_font_modifier_element
@ YYSYMBOL_SL
#define YY_ASSERT(E)
#define yyerrstatus
#define YY_(Msgid)
#define YYNOMEM
#define yypstate
#define YY_IGNORE_MAYBE_UNINITIALIZED_END
#define YYNSTATES
#define YYSTYPE
#define yypull_parse
#define yypstate_delete
#define YY_IGNORE_USELESS_CAST_END
#define yypstate_clear
#define yypstate_new
short yytype_int16
#define YYABORT
#define YYSTACK_BYTES(N)
#define YY_REDUCE_PRINT(Rule)
#define YY_CAST(Type, Val)
#define yylex
#define YYMALLOC
#define YY_NULLPTR
#define YYFINAL
#define YY_ACCESSING_SYMBOL(State)
Accessing symbol of state STATE.
#define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
#define YY_INITIAL_VALUE(Value)
int octave_tex_parse(octave::text_parser_tex &parser)
#define yyparse
#define YYNTOKENS
unsigned char yytype_uint8
#define YY_STACK_PRINT(Bottom, Top)
#define YYSIZE_T
#define yydebug
#define yyalloc
#define YY_IGNORE_USELESS_CAST_BEGIN
#define yyssa
#define YYPTRDIFF_T
#define yynerrs
#define yyvsp
#define YYACCEPT
#define yytable_value_is_error(Yyn)
#define YYTRANSLATE(YYX)
#define yyssp
void * malloc(unsigned)
#define yystacksize
#define YY_ATTRIBUTE_UNUSED
#define yyvs
#define m_scanner
@ YYENOMEM
#define yystate
#define YYFREE
#define YYPOPSTACK(N)
int octave_tex_lex(OCTAVE_TEX_STYPE *, void *)
The main scanner function which does all the work.
int yy_state_fast_t
unsigned short yytype_uint16
#define YYLAST
#define YYSTACK_RELOCATE(Stack_alloc, Stack)
#define yypact_value_is_default(Yyn)
#define YYINITDEPTH
#define yypush_parse
signed char yytype_int8
void free(void *)
#define YYERROR
#define YYSIZEOF(X)
#define YYSTACK_ALLOC
yytype_int8 yy_state_t
#define yyvsa
#define YYDPRINTF(Args)
#define YY_USE(E)
#define yyerror
@ YYPUSH_MORE
@ OCTAVE_TEX_EMPTY
@ OCTAVE_TEX_error
@ OCTAVE_TEX_EOF
@ OCTAVE_TEX_UNDEF