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