SphinxBase 5prealpha
jsgf_parser.c
1
2/* A Bison parser, made by GNU Bison 2.4.1. */
3
4/* Skeleton implementation for Bison's Yacc-like parsers in C
5
6 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
7 Free Software Foundation, Inc.
8
9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22/* As a special exception, you may create a larger work that contains
23 part or all of the Bison parser skeleton and distribute that work
24 under terms of your choice, so long as that work isn't itself a
25 parser generator using the skeleton or a modified version thereof
26 as a parser skeleton. Alternatively, if you modify or redistribute
27 the parser skeleton itself, you may (at your option) remove this
28 special exception, which will cause the skeleton and the resulting
29 Bison output files to be licensed under the GNU General Public
30 License without this special exception.
31
32 This special exception was added by the Free Software Foundation in
33 version 2.2 of Bison. */
34
35/* C LALR(1) parser skeleton written by Richard Stallman, by
36 simplifying the original so-called "semantic" parser. */
37
38/* All symbols defined below should begin with yy or YY, to avoid
39 infringing on user name space. This should be done even for local
40 variables, as they might otherwise be expanded by user macros.
41 There are some unavoidable exceptions within include files to
42 define necessary library symbols; they are noted "INFRINGES ON
43 USER NAME SPACE" below. */
44
45/* Identify Bison output. */
46#define YYBISON 1
47
48/* Bison version. */
49#define YYBISON_VERSION "2.4.1"
50
51/* Skeleton name. */
52#define YYSKELETON_NAME "yacc.c"
53
54/* Pure parsers. */
55#define YYPURE 1
56
57/* Push parsers. */
58#define YYPUSH 0
59
60/* Pull parsers. */
61#define YYPULL 1
62
63/* Using locations. */
64#define YYLSP_NEEDED 0
65
66
67
68/* Copy the first part of user declarations. */
69
70/* Line 189 of yacc.c */
71#line 37 "jsgf_parser.y"
72
73#define YYERROR_VERBOSE
74
75#include <stdio.h>
76#include <string.h>
77
80#include <sphinxbase/err.h>
81
82#include "jsgf_internal.h"
83#include "jsgf_parser.h"
84#include "jsgf_scanner.h"
85
86/* Suppress warnings from generated code */
87#if defined _MSC_VER
88#pragma warning(disable: 4273)
89#endif
90
91void yyerror(yyscan_t lex, jsgf_t *jsgf, const char *s);
92
93
94
95/* Line 189 of yacc.c */
96#line 97 "jsgf_parser.c"
97
98/* Enabling traces. */
99#ifndef YYDEBUG
100# define YYDEBUG 0
101#endif
102
103/* Enabling verbose error messages. */
104#ifdef YYERROR_VERBOSE
105# undef YYERROR_VERBOSE
106# define YYERROR_VERBOSE 1
107#else
108# define YYERROR_VERBOSE 0
109#endif
110
111/* Enabling the token table. */
112#ifndef YYTOKEN_TABLE
113# define YYTOKEN_TABLE 0
114#endif
115
116
117/* Tokens. */
118#ifndef YYTOKENTYPE
119# define YYTOKENTYPE
120 /* Put the tokens into the symbol table, so that GDB and other debuggers
121 know about them. */
122 enum yytokentype {
123 HEADER = 258,
124 GRAMMAR = 259,
125 IMPORT = 260,
126 PUBLIC = 261,
127 TOKEN = 262,
128 RULENAME = 263,
129 TAG = 264,
130 WEIGHT = 265
131 };
132#endif
133/* Tokens. */
134#define HEADER 258
135#define GRAMMAR 259
136#define IMPORT 260
137#define PUBLIC 261
138#define TOKEN 262
139#define RULENAME 263
140#define TAG 264
141#define WEIGHT 265
142
143
144
145
146#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
147typedef union YYSTYPE
148{
149
150/* Line 214 of yacc.c */
151#line 65 "jsgf_parser.y"
152
153 char *name;
154 float weight;
155 jsgf_rule_t *rule;
156 jsgf_rhs_t *rhs;
157 jsgf_atom_t *atom;
158
159
160
161/* Line 214 of yacc.c */
162#line 163 "jsgf_parser.c"
163} YYSTYPE;
164# define YYSTYPE_IS_TRIVIAL 1
165# define yystype YYSTYPE /* obsolescent; will be withdrawn */
166# define YYSTYPE_IS_DECLARED 1
167#endif
168
169
170/* Copy the second part of user declarations. */
171
172
173/* Line 264 of yacc.c */
174#line 175 "jsgf_parser.c"
175
176#ifdef short
177# undef short
178#endif
179
180#ifdef YYTYPE_UINT8
181typedef YYTYPE_UINT8 yytype_uint8;
182#else
183typedef unsigned char yytype_uint8;
184#endif
185
186#ifdef YYTYPE_INT8
187typedef YYTYPE_INT8 yytype_int8;
188#elif (defined __STDC__ || defined __C99__FUNC__ \
189 || defined __cplusplus || defined _MSC_VER)
190typedef signed char yytype_int8;
191#else
192typedef short int yytype_int8;
193#endif
194
195#ifdef YYTYPE_UINT16
196typedef YYTYPE_UINT16 yytype_uint16;
197#else
198typedef unsigned short int yytype_uint16;
199#endif
200
201#ifdef YYTYPE_INT16
202typedef YYTYPE_INT16 yytype_int16;
203#else
204typedef short int yytype_int16;
205#endif
206
207#ifndef YYSIZE_T
208# ifdef __SIZE_TYPE__
209# define YYSIZE_T __SIZE_TYPE__
210# elif defined size_t
211# define YYSIZE_T size_t
212# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
213 || defined __cplusplus || defined _MSC_VER)
214# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
215# define YYSIZE_T size_t
216# else
217# define YYSIZE_T unsigned int
218# endif
219#endif
220
221#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
222
223#ifndef YY_
224# if YYENABLE_NLS
225# if ENABLE_NLS
226# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
227# define YY_(msgid) dgettext ("bison-runtime", msgid)
228# endif
229# endif
230# ifndef YY_
231# define YY_(msgid) msgid
232# endif
233#endif
234
235/* Suppress unused-variable warnings by "using" E. */
236#if ! defined lint || defined __GNUC__
237# define YYUSE(e) ((void) (e))
238#else
239# define YYUSE(e) /* empty */
240#endif
241
242/* Identity function, used to suppress warnings about constant conditions. */
243#ifndef lint
244# define YYID(n) (n)
245#else
246#if (defined __STDC__ || defined __C99__FUNC__ \
247 || defined __cplusplus || defined _MSC_VER)
248static int
249YYID (int yyi)
250#else
251static int
252YYID (yyi)
253 int yyi;
254#endif
255{
256 return yyi;
257}
258#endif
259
260#if ! defined yyoverflow || YYERROR_VERBOSE
261
262/* The parser invokes alloca or malloc; define the necessary symbols. */
263
264# ifdef YYSTACK_USE_ALLOCA
265# if YYSTACK_USE_ALLOCA
266# ifdef __GNUC__
267# define YYSTACK_ALLOC __builtin_alloca
268# elif defined __BUILTIN_VA_ARG_INCR
269# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
270# elif defined _AIX
271# define YYSTACK_ALLOC __alloca
272# elif defined _MSC_VER
273# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
274# define alloca _alloca
275# else
276# define YYSTACK_ALLOC alloca
277# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
278 || defined __cplusplus || defined _MSC_VER)
279# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
280# ifndef _STDLIB_H
281# define _STDLIB_H 1
282# endif
283# endif
284# endif
285# endif
286# endif
287
288# ifdef YYSTACK_ALLOC
289 /* Pacify GCC's `empty if-body' warning. */
290# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
291# ifndef YYSTACK_ALLOC_MAXIMUM
292 /* The OS might guarantee only one guard page at the bottom of the stack,
293 and a page size can be as small as 4096 bytes. So we cannot safely
294 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
295 to allow for a few compiler-allocated temporary stack slots. */
296# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
297# endif
298# else
299# define YYSTACK_ALLOC YYMALLOC
300# define YYSTACK_FREE YYFREE
301# ifndef YYSTACK_ALLOC_MAXIMUM
302# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
303# endif
304# if (defined __cplusplus && ! defined _STDLIB_H \
305 && ! ((defined YYMALLOC || defined malloc) \
306 && (defined YYFREE || defined free)))
307# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
308# ifndef _STDLIB_H
309# define _STDLIB_H 1
310# endif
311# endif
312# ifndef YYMALLOC
313# define YYMALLOC malloc
314# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
315 || defined __cplusplus || defined _MSC_VER)
316void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
317# endif
318# endif
319# ifndef YYFREE
320# define YYFREE free
321# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
322 || defined __cplusplus || defined _MSC_VER)
323void free (void *); /* INFRINGES ON USER NAME SPACE */
324# endif
325# endif
326# endif
327#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
328
329
330#if (! defined yyoverflow \
331 && (! defined __cplusplus \
332 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
333
334/* A type that is properly aligned for any stack member. */
336{
337 yytype_int16 yyss_alloc;
338 YYSTYPE yyvs_alloc;
339};
340
341/* The size of the maximum gap between one aligned stack and the next. */
342# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
343
344/* The size of an array large to enough to hold all stacks, each with
345 N elements. */
346# define YYSTACK_BYTES(N) \
347 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
348 + YYSTACK_GAP_MAXIMUM)
349
350/* Copy COUNT objects from FROM to TO. The source and destination do
351 not overlap. */
352# ifndef YYCOPY
353# if defined __GNUC__ && 1 < __GNUC__
354# define YYCOPY(To, From, Count) \
355 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
356# else
357# define YYCOPY(To, From, Count) \
358 do \
359 { \
360 YYSIZE_T yyi; \
361 for (yyi = 0; yyi < (Count); yyi++) \
362 (To)[yyi] = (From)[yyi]; \
363 } \
364 while (YYID (0))
365# endif
366# endif
367
368/* Relocate STACK from its old location to the new one. The
369 local variables YYSIZE and YYSTACKSIZE give the old and new number of
370 elements in the stack, and YYPTR gives the new location of the
371 stack. Advance YYPTR to a properly aligned location for the next
372 stack. */
373# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
374 do \
375 { \
376 YYSIZE_T yynewbytes; \
377 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
378 Stack = &yyptr->Stack_alloc; \
379 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
380 yyptr += yynewbytes / sizeof (*yyptr); \
381 } \
382 while (YYID (0))
383
384#endif
385
386/* YYFINAL -- State number of the termination state. */
387#define YYFINAL 7
388/* YYLAST -- Last index in YYTABLE. */
389#define YYLAST 54
390
391/* YYNTOKENS -- Number of terminals. */
392#define YYNTOKENS 20
393/* YYNNTS -- Number of nonterminals. */
394#define YYNNTS 16
395/* YYNRULES -- Number of rules. */
396#define YYNRULES 33
397/* YYNRULES -- Number of states. */
398#define YYNSTATES 58
399
400/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
401#define YYUNDEFTOK 2
402#define YYMAXUTOK 265
403
404#define YYTRANSLATE(YYX) \
405 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
406
407/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
408static const yytype_uint8 yytranslate[] =
409{
410 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
411 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
412 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
413 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
414 14, 15, 18, 19, 2, 2, 2, 2, 2, 2,
415 2, 2, 2, 2, 2, 2, 2, 2, 2, 11,
416 2, 12, 2, 2, 2, 2, 2, 2, 2, 2,
417 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
418 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
419 2, 16, 2, 17, 2, 2, 2, 2, 2, 2,
420 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
421 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
422 2, 2, 2, 2, 13, 2, 2, 2, 2, 2,
423 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
424 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
425 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
426 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
427 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
428 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
429 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
430 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
431 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
432 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
433 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
434 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
435 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
436 5, 6, 7, 8, 9, 10
437};
438
439#if YYDEBUG
440/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
441 YYRHS. */
442static const yytype_uint8 yyprhs[] =
443{
444 0, 0, 3, 5, 8, 12, 15, 18, 22, 27,
445 33, 37, 39, 42, 46, 48, 51, 56, 62, 64,
446 68, 70, 73, 75, 78, 80, 83, 87, 91, 93,
447 95, 97, 99, 102
448};
449
450/* YYRHS -- A `-1'-separated list of the rules' RHS. */
451static const yytype_int8 yyrhs[] =
452{
453 21, 0, -1, 22, -1, 22, 27, -1, 22, 25,
454 27, -1, 23, 24, -1, 3, 11, -1, 3, 7,
455 11, -1, 3, 7, 7, 11, -1, 3, 7, 7,
456 7, 11, -1, 4, 7, 11, -1, 26, -1, 25,
457 26, -1, 5, 8, 11, -1, 28, -1, 27, 28,
458 -1, 8, 12, 29, 11, -1, 6, 8, 12, 29,
459 11, -1, 30, -1, 29, 13, 30, -1, 31, -1,
460 30, 31, -1, 32, -1, 31, 9, -1, 35, -1,
461 10, 35, -1, 14, 29, 15, -1, 16, 29, 17,
462 -1, 7, -1, 8, -1, 33, -1, 34, -1, 35,
463 18, -1, 35, 19, -1
464};
465
466/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
467static const yytype_uint8 yyrline[] =
468{
469 0, 82, 82, 83, 84, 87, 90, 91, 92, 93,
470 97, 100, 101, 104, 107, 108, 111, 112, 115, 116,
471 121, 123, 127, 128, 132, 133, 136, 139, 142, 143,
472 144, 145, 146, 147
473};
474#endif
475
476#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
477/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
478 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
479static const char *const yytname[] =
480{
481 "$end", "error", "$undefined", "HEADER", "GRAMMAR", "IMPORT", "PUBLIC",
482 "TOKEN", "RULENAME", "TAG", "WEIGHT", "';'", "'='", "'|'", "'('", "')'",
483 "'['", "']'", "'*'", "'+'", "$accept", "grammar", "header",
484 "jsgf_header", "grammar_header", "import_header", "import_statement",
485 "rule_list", "rule", "alternate_list", "rule_expansion",
486 "tagged_rule_item", "rule_item", "rule_group", "rule_optional",
487 "rule_atom", 0
488};
489#endif
490
491# ifdef YYPRINT
492/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
493 token YYLEX-NUM. */
494static const yytype_uint16 yytoknum[] =
495{
496 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
497 265, 59, 61, 124, 40, 41, 91, 93, 42, 43
498};
499# endif
500
501/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
502static const yytype_uint8 yyr1[] =
503{
504 0, 20, 21, 21, 21, 22, 23, 23, 23, 23,
505 24, 25, 25, 26, 27, 27, 28, 28, 29, 29,
506 30, 30, 31, 31, 32, 32, 33, 34, 35, 35,
507 35, 35, 35, 35
508};
509
510/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
511static const yytype_uint8 yyr2[] =
512{
513 0, 2, 1, 2, 3, 2, 2, 3, 4, 5,
514 3, 1, 2, 3, 1, 2, 4, 5, 1, 3,
515 1, 2, 1, 2, 1, 2, 3, 3, 1, 1,
516 1, 1, 2, 2
517};
518
519/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
520 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
521 means the default is an error. */
522static const yytype_uint8 yydefact[] =
523{
524 0, 0, 0, 2, 0, 0, 6, 1, 0, 0,
525 0, 0, 11, 3, 14, 0, 5, 0, 7, 0,
526 0, 0, 12, 4, 15, 0, 0, 8, 13, 0,
527 28, 29, 0, 0, 0, 0, 18, 20, 22, 30,
528 31, 24, 10, 9, 0, 25, 0, 0, 16, 0,
529 21, 23, 32, 33, 17, 26, 27, 19
530};
531
532/* YYDEFGOTO[NTERM-NUM]. */
533static const yytype_int8 yydefgoto[] =
534{
535 -1, 2, 3, 4, 16, 11, 12, 13, 14, 35,
536 36, 37, 38, 39, 40, 41
537};
538
539/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
540 STATE-NUM. */
541#define YYPACT_NINF -37
542static const yytype_int8 yypact[] =
543{
544 -1, -2, 36, 22, 35, 8, -37, -37, 32, 33,
545 30, 22, -37, 17, -37, 37, -37, 13, -37, 34,
546 31, -4, -37, 17, -37, 38, 39, -37, -37, -4,
547 -37, -37, 0, -4, -4, 18, -4, 42, -37, -37,
548 -37, 19, -37, -37, 21, 19, 20, 9, -37, -4,
549 42, -37, -37, -37, -37, -37, -37, -4
550};
551
552/* YYPGOTO[NTERM-NUM]. */
553static const yytype_int8 yypgoto[] =
554{
555 -37, -37, -37, -37, -37, -37, 41, 43, -12, -16,
556 -3, -36, -37, -37, -37, 15
557};
558
559/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
560 positive, shift that token. If negative, reduce the rule which
561 number is the opposite. If zero, do what YYDEFACT says.
562 If YYTABLE_NINF, syntax error. */
563#define YYTABLE_NINF -1
564static const yytype_uint8 yytable[] =
565{
566 50, 24, 1, 30, 31, 5, 32, 30, 31, 6,
567 33, 24, 34, 44, 33, 17, 34, 46, 47, 18,
568 26, 50, 49, 9, 27, 10, 56, 8, 9, 48,
569 10, 49, 54, 49, 49, 55, 7, 52, 53, 15,
570 19, 20, 21, 29, 25, 28, 57, 45, 0, 42,
571 43, 51, 22, 0, 23
572};
573
574static const yytype_int8 yycheck[] =
575{
576 36, 13, 3, 7, 8, 7, 10, 7, 8, 11,
577 14, 23, 16, 29, 14, 7, 16, 33, 34, 11,
578 7, 57, 13, 6, 11, 8, 17, 5, 6, 11,
579 8, 13, 11, 13, 13, 15, 0, 18, 19, 4,
580 8, 8, 12, 12, 7, 11, 49, 32, -1, 11,
581 11, 9, 11, -1, 11
582};
583
584/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
585 symbol of state STATE-NUM. */
586static const yytype_uint8 yystos[] =
587{
588 0, 3, 21, 22, 23, 7, 11, 0, 5, 6,
589 8, 25, 26, 27, 28, 4, 24, 7, 11, 8,
590 8, 12, 26, 27, 28, 7, 7, 11, 11, 12,
591 7, 8, 10, 14, 16, 29, 30, 31, 32, 33,
592 34, 35, 11, 11, 29, 35, 29, 29, 11, 13,
593 31, 9, 18, 19, 11, 15, 17, 30
594};
595
596#define yyerrok (yyerrstatus = 0)
597#define yyclearin (yychar = YYEMPTY)
598#define YYEMPTY (-2)
599#define YYEOF 0
600
601#define YYACCEPT goto yyacceptlab
602#define YYABORT goto yyabortlab
603#define YYERROR goto yyerrorlab
604
605
606/* Like YYERROR except do call yyerror. This remains here temporarily
607 to ease the transition to the new meaning of YYERROR, for GCC.
608 Once GCC version 2 has supplanted version 1, this can go. */
609
610#define YYFAIL goto yyerrlab
611
612#define YYRECOVERING() (!!yyerrstatus)
613
614#define YYBACKUP(Token, Value) \
615do \
616 if (yychar == YYEMPTY && yylen == 1) \
617 { \
618 yychar = (Token); \
619 yylval = (Value); \
620 yytoken = YYTRANSLATE (yychar); \
621 YYPOPSTACK (1); \
622 goto yybackup; \
623 } \
624 else \
625 { \
626 yyerror (yyscanner, jsgf, YY_("syntax error: cannot back up")); \
627 YYERROR; \
628 } \
629while (YYID (0))
630
631
632#define YYTERROR 1
633#define YYERRCODE 256
634
635
636/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
637 If N is 0, then set CURRENT to the empty location which ends
638 the previous symbol: RHS[0] (always defined). */
639
640#define YYRHSLOC(Rhs, K) ((Rhs)[K])
641#ifndef YYLLOC_DEFAULT
642# define YYLLOC_DEFAULT(Current, Rhs, N) \
643 do \
644 if (YYID (N)) \
645 { \
646 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
647 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
648 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
649 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
650 } \
651 else \
652 { \
653 (Current).first_line = (Current).last_line = \
654 YYRHSLOC (Rhs, 0).last_line; \
655 (Current).first_column = (Current).last_column = \
656 YYRHSLOC (Rhs, 0).last_column; \
657 } \
658 while (YYID (0))
659#endif
660
661
662/* YY_LOCATION_PRINT -- Print the location on the stream.
663 This macro was not mandated originally: define only if we know
664 we won't break user code: when these are the locations we know. */
665
666#ifndef YY_LOCATION_PRINT
667# if YYLTYPE_IS_TRIVIAL
668# define YY_LOCATION_PRINT(File, Loc) \
669 fprintf (File, "%d.%d-%d.%d", \
670 (Loc).first_line, (Loc).first_column, \
671 (Loc).last_line, (Loc).last_column)
672# else
673# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
674# endif
675#endif
676
677
678/* YYLEX -- calling `yylex' with the right arguments. */
679
680#ifdef YYLEX_PARAM
681# define YYLEX yylex (&yylval, YYLEX_PARAM)
682#else
683# define YYLEX yylex (&yylval, yyscanner)
684#endif
685
686/* Enable debugging if requested. */
687#if YYDEBUG
688
689# ifndef YYFPRINTF
690# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
691# define YYFPRINTF fprintf
692# endif
693
694# define YYDPRINTF(Args) \
695do { \
696 if (yydebug) \
697 YYFPRINTF Args; \
698} while (YYID (0))
699
700# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
701do { \
702 if (yydebug) \
703 { \
704 YYFPRINTF (stderr, "%s ", Title); \
705 yy_symbol_print (stderr, \
706 Type, Value, yyscanner, jsgf); \
707 YYFPRINTF (stderr, "\n"); \
708 } \
709} while (YYID (0))
710
711
712/*--------------------------------.
713| Print this symbol on YYOUTPUT. |
714`--------------------------------*/
715
716/*ARGSUSED*/
717#if (defined __STDC__ || defined __C99__FUNC__ \
718 || defined __cplusplus || defined _MSC_VER)
719static void
720yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void* yyscanner, jsgf_t *jsgf)
721#else
722static void
723yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner, jsgf)
724 FILE *yyoutput;
725 int yytype;
726 YYSTYPE const * const yyvaluep;
727 void* yyscanner;
728 jsgf_t *jsgf;
729#endif
730{
731 if (!yyvaluep)
732 return;
733 YYUSE (yyscanner);
734 YYUSE (jsgf);
735# ifdef YYPRINT
736 if (yytype < YYNTOKENS)
737 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
738# else
739 YYUSE (yyoutput);
740# endif
741 switch (yytype)
742 {
743 default:
744 break;
745 }
746}
747
748
749/*--------------------------------.
750| Print this symbol on YYOUTPUT. |
751`--------------------------------*/
752
753#if (defined __STDC__ || defined __C99__FUNC__ \
754 || defined __cplusplus || defined _MSC_VER)
755static void
756yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void* yyscanner, jsgf_t *jsgf)
757#else
758static void
759yy_symbol_print (yyoutput, yytype, yyvaluep, yyscanner, jsgf)
760 FILE *yyoutput;
761 int yytype;
762 YYSTYPE const * const yyvaluep;
763 void* yyscanner;
764 jsgf_t *jsgf;
765#endif
766{
767 if (yytype < YYNTOKENS)
768 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
769 else
770 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
771
772 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner, jsgf);
773 YYFPRINTF (yyoutput, ")");
774}
775
776/*------------------------------------------------------------------.
777| yy_stack_print -- Print the state stack from its BOTTOM up to its |
778| TOP (included). |
779`------------------------------------------------------------------*/
780
781#if (defined __STDC__ || defined __C99__FUNC__ \
782 || defined __cplusplus || defined _MSC_VER)
783static void
784yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
785#else
786static void
787yy_stack_print (yybottom, yytop)
788 yytype_int16 *yybottom;
789 yytype_int16 *yytop;
790#endif
791{
792 YYFPRINTF (stderr, "Stack now");
793 for (; yybottom <= yytop; yybottom++)
794 {
795 int yybot = *yybottom;
796 YYFPRINTF (stderr, " %d", yybot);
797 }
798 YYFPRINTF (stderr, "\n");
799}
800
801# define YY_STACK_PRINT(Bottom, Top) \
802do { \
803 if (yydebug) \
804 yy_stack_print ((Bottom), (Top)); \
805} while (YYID (0))
806
807
808/*------------------------------------------------.
809| Report that the YYRULE is going to be reduced. |
810`------------------------------------------------*/
811
812#if (defined __STDC__ || defined __C99__FUNC__ \
813 || defined __cplusplus || defined _MSC_VER)
814static void
815yy_reduce_print (YYSTYPE *yyvsp, int yyrule, void* yyscanner, jsgf_t *jsgf)
816#else
817static void
818yy_reduce_print (yyvsp, yyrule, yyscanner, jsgf)
819 YYSTYPE *yyvsp;
820 int yyrule;
821 void* yyscanner;
822 jsgf_t *jsgf;
823#endif
824{
825 int yynrhs = yyr2[yyrule];
826 int yyi;
827 unsigned long int yylno = yyrline[yyrule];
828 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
829 yyrule - 1, yylno);
830 /* The symbols being reduced. */
831 for (yyi = 0; yyi < yynrhs; yyi++)
832 {
833 YYFPRINTF (stderr, " $%d = ", yyi + 1);
834 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
835 &(yyvsp[(yyi + 1) - (yynrhs)])
836 , yyscanner, jsgf);
837 YYFPRINTF (stderr, "\n");
838 }
839}
840
841# define YY_REDUCE_PRINT(Rule) \
842do { \
843 if (yydebug) \
844 yy_reduce_print (yyvsp, Rule, yyscanner, jsgf); \
845} while (YYID (0))
846
847/* Nonzero means print parse trace. It is left uninitialized so that
848 multiple parsers can coexist. */
849int yydebug;
850#else /* !YYDEBUG */
851# define YYDPRINTF(Args)
852# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
853# define YY_STACK_PRINT(Bottom, Top)
854# define YY_REDUCE_PRINT(Rule)
855#endif /* !YYDEBUG */
856
857
858/* YYINITDEPTH -- initial size of the parser's stacks. */
859#ifndef YYINITDEPTH
860# define YYINITDEPTH 200
861#endif
862
863/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
864 if the built-in stack extension method is used).
865
866 Do not make this value too large; the results are undefined if
867 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
868 evaluated with infinite-precision integer arithmetic. */
869
870#ifndef YYMAXDEPTH
871# define YYMAXDEPTH 10000
872#endif
873
874
875
876#if YYERROR_VERBOSE
877
878# ifndef yystrlen
879# if defined __GLIBC__ && defined _STRING_H
880# define yystrlen strlen
881# else
882/* Return the length of YYSTR. */
883#if (defined __STDC__ || defined __C99__FUNC__ \
884 || defined __cplusplus || defined _MSC_VER)
885static YYSIZE_T
886yystrlen (const char *yystr)
887#else
888static YYSIZE_T
889yystrlen (yystr)
890 const char *yystr;
891#endif
892{
893 YYSIZE_T yylen;
894 for (yylen = 0; yystr[yylen]; yylen++)
895 continue;
896 return yylen;
897}
898# endif
899# endif
900
901# ifndef yystpcpy
902# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
903# define yystpcpy stpcpy
904# else
905/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
906 YYDEST. */
907#if (defined __STDC__ || defined __C99__FUNC__ \
908 || defined __cplusplus || defined _MSC_VER)
909static char *
910yystpcpy (char *yydest, const char *yysrc)
911#else
912static char *
913yystpcpy (yydest, yysrc)
914 char *yydest;
915 const char *yysrc;
916#endif
917{
918 char *yyd = yydest;
919 const char *yys = yysrc;
920
921 while ((*yyd++ = *yys++) != '\0')
922 continue;
923
924 return yyd - 1;
925}
926# endif
927# endif
928
929# ifndef yytnamerr
930/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
931 quotes and backslashes, so that it's suitable for yyerror. The
932 heuristic is that double-quoting is unnecessary unless the string
933 contains an apostrophe, a comma, or backslash (other than
934 backslash-backslash). YYSTR is taken from yytname. If YYRES is
935 null, do not copy; instead, return the length of what the result
936 would have been. */
937static YYSIZE_T
938yytnamerr (char *yyres, const char *yystr)
939{
940 if (*yystr == '"')
941 {
942 YYSIZE_T yyn = 0;
943 char const *yyp = yystr;
944
945 for (;;)
946 switch (*++yyp)
947 {
948 case '\'':
949 case ',':
950 goto do_not_strip_quotes;
951
952 case '\\':
953 if (*++yyp != '\\')
954 goto do_not_strip_quotes;
955 /* Fall through. */
956 default:
957 if (yyres)
958 yyres[yyn] = *yyp;
959 yyn++;
960 break;
961
962 case '"':
963 if (yyres)
964 yyres[yyn] = '\0';
965 return yyn;
966 }
967 do_not_strip_quotes: ;
968 }
969
970 if (! yyres)
971 return yystrlen (yystr);
972
973 return yystpcpy (yyres, yystr) - yyres;
974}
975# endif
976
977/* Copy into YYRESULT an error message about the unexpected token
978 YYCHAR while in state YYSTATE. Return the number of bytes copied,
979 including the terminating null byte. If YYRESULT is null, do not
980 copy anything; just return the number of bytes that would be
981 copied. As a special case, return 0 if an ordinary "syntax error"
982 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
983 size calculation. */
984static YYSIZE_T
985yysyntax_error (char *yyresult, int yystate, int yychar)
986{
987 int yyn = yypact[yystate];
988
989 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
990 return 0;
991 else
992 {
993 int yytype = YYTRANSLATE (yychar);
994 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
995 YYSIZE_T yysize = yysize0;
996 YYSIZE_T yysize1;
997 int yysize_overflow = 0;
998 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
999 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1000 int yyx;
1001
1002# if 0
1003 /* This is so xgettext sees the translatable formats that are
1004 constructed on the fly. */
1005 YY_("syntax error, unexpected %s");
1006 YY_("syntax error, unexpected %s, expecting %s");
1007 YY_("syntax error, unexpected %s, expecting %s or %s");
1008 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1009 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1010# endif
1011 char *yyfmt;
1012 char const *yyf;
1013 static char const yyunexpected[] = "syntax error, unexpected %s";
1014 static char const yyexpecting[] = ", expecting %s";
1015 static char const yyor[] = " or %s";
1016 char yyformat[sizeof yyunexpected
1017 + sizeof yyexpecting - 1
1018 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1019 * (sizeof yyor - 1))];
1020 char const *yyprefix = yyexpecting;
1021
1022 /* Start YYX at -YYN if negative to avoid negative indexes in
1023 YYCHECK. */
1024 int yyxbegin = yyn < 0 ? -yyn : 0;
1025
1026 /* Stay within bounds of both yycheck and yytname. */
1027 int yychecklim = YYLAST - yyn + 1;
1028 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1029 int yycount = 1;
1030
1031 yyarg[0] = yytname[yytype];
1032 yyfmt = yystpcpy (yyformat, yyunexpected);
1033
1034 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1035 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1036 {
1037 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1038 {
1039 yycount = 1;
1040 yysize = yysize0;
1041 yyformat[sizeof yyunexpected - 1] = '\0';
1042 break;
1043 }
1044 yyarg[yycount++] = yytname[yyx];
1045 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1046 yysize_overflow |= (yysize1 < yysize);
1047 yysize = yysize1;
1048 yyfmt = yystpcpy (yyfmt, yyprefix);
1049 yyprefix = yyor;
1050 }
1051
1052 yyf = YY_(yyformat);
1053 yysize1 = yysize + yystrlen (yyf);
1054 yysize_overflow |= (yysize1 < yysize);
1055 yysize = yysize1;
1056
1057 if (yysize_overflow)
1058 return YYSIZE_MAXIMUM;
1059
1060 if (yyresult)
1061 {
1062 /* Avoid sprintf, as that infringes on the user's name space.
1063 Don't have undefined behavior even if the translation
1064 produced a string with the wrong number of "%s"s. */
1065 char *yyp = yyresult;
1066 int yyi = 0;
1067 while ((*yyp = *yyf) != '\0')
1068 {
1069 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1070 {
1071 yyp += yytnamerr (yyp, yyarg[yyi++]);
1072 yyf += 2;
1073 }
1074 else
1075 {
1076 yyp++;
1077 yyf++;
1078 }
1079 }
1080 }
1081 return yysize;
1082 }
1083}
1084#endif /* YYERROR_VERBOSE */
1085
1086
1087/*-----------------------------------------------.
1088| Release the memory associated to this symbol. |
1089`-----------------------------------------------*/
1090
1091/*ARGSUSED*/
1092#if (defined __STDC__ || defined __C99__FUNC__ \
1093 || defined __cplusplus || defined _MSC_VER)
1094static void
1095yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void* yyscanner, jsgf_t *jsgf)
1096#else
1097static void
1098yydestruct (yymsg, yytype, yyvaluep, yyscanner, jsgf)
1099 const char *yymsg;
1100 int yytype;
1101 YYSTYPE *yyvaluep;
1102 void* yyscanner;
1103 jsgf_t *jsgf;
1104#endif
1105{
1106 YYUSE (yyvaluep);
1107 YYUSE (yyscanner);
1108 YYUSE (jsgf);
1109
1110 if (!yymsg)
1111 yymsg = "Deleting";
1112 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1113
1114 switch (yytype)
1115 {
1116
1117 default:
1118 break;
1119 }
1120}
1121
1122/* Prevent warnings from -Wmissing-prototypes. */
1123#ifdef YYPARSE_PARAM
1124#if defined __STDC__ || defined __cplusplus
1125int yyparse (void *YYPARSE_PARAM);
1126#else
1127int yyparse ();
1128#endif
1129#else /* ! YYPARSE_PARAM */
1130#if defined __STDC__ || defined __cplusplus
1131int yyparse (void* yyscanner, jsgf_t *jsgf);
1132#else
1133int yyparse ();
1134#endif
1135#endif /* ! YYPARSE_PARAM */
1136
1137
1138
1139
1140
1141/*-------------------------.
1142| yyparse or yypush_parse. |
1143`-------------------------*/
1144
1145#ifdef YYPARSE_PARAM
1146#if (defined __STDC__ || defined __C99__FUNC__ \
1147 || defined __cplusplus || defined _MSC_VER)
1148int
1149yyparse (void *YYPARSE_PARAM)
1150#else
1151int
1152yyparse (YYPARSE_PARAM)
1153 void *YYPARSE_PARAM;
1154#endif
1155#else /* ! YYPARSE_PARAM */
1156#if (defined __STDC__ || defined __C99__FUNC__ \
1157 || defined __cplusplus || defined _MSC_VER)
1158int
1159yyparse (void* yyscanner, jsgf_t *jsgf)
1160#else
1161int
1162yyparse (yyscanner, jsgf)
1163 void* yyscanner;
1164 jsgf_t *jsgf;
1165#endif
1166#endif
1167{
1168/* The lookahead symbol. */
1169int yychar;
1170
1171/* The semantic value of the lookahead symbol. */
1172YYSTYPE yylval;
1173
1174 /* Number of syntax errors so far. */
1175 int yynerrs;
1176
1177 int yystate;
1178 /* Number of tokens to shift before error messages enabled. */
1179 int yyerrstatus;
1180
1181 /* The stacks and their tools:
1182 `yyss': related to states.
1183 `yyvs': related to semantic values.
1184
1185 Refer to the stacks thru separate pointers, to allow yyoverflow
1186 to reallocate them elsewhere. */
1187
1188 /* The state stack. */
1189 yytype_int16 yyssa[YYINITDEPTH];
1190 yytype_int16 *yyss;
1191 yytype_int16 *yyssp;
1192
1193 /* The semantic value stack. */
1194 YYSTYPE yyvsa[YYINITDEPTH];
1195 YYSTYPE *yyvs;
1196 YYSTYPE *yyvsp;
1197
1198 YYSIZE_T yystacksize;
1199
1200 int yyn;
1201 int yyresult;
1202 /* Lookahead token as an internal (translated) token number. */
1203 int yytoken;
1204 /* The variables used to return semantic value and location from the
1205 action routines. */
1206 YYSTYPE yyval;
1207
1208#if YYERROR_VERBOSE
1209 /* Buffer for error messages, and its allocated size. */
1210 char yymsgbuf[128];
1211 char *yymsg = yymsgbuf;
1212 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1213#endif
1214
1215#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1216
1217 /* The number of symbols on the RHS of the reduced rule.
1218 Keep to zero when no symbol should be popped. */
1219 int yylen = 0;
1220
1221 yytoken = 0;
1222 yyss = yyssa;
1223 yyvs = yyvsa;
1224 yystacksize = YYINITDEPTH;
1225
1226 YYDPRINTF ((stderr, "Starting parse\n"));
1227
1228 yystate = 0;
1229 yyerrstatus = 0;
1230 yynerrs = 0;
1231 yychar = YYEMPTY; /* Cause a token to be read. */
1232
1233 /* Initialize stack pointers.
1234 Waste one element of value and location stack
1235 so that they stay on the same level as the state stack.
1236 The wasted elements are never initialized. */
1237 yyssp = yyss;
1238 yyvsp = yyvs;
1239
1240 goto yysetstate;
1241
1242/*------------------------------------------------------------.
1243| yynewstate -- Push a new state, which is found in yystate. |
1244`------------------------------------------------------------*/
1245 yynewstate:
1246 /* In all cases, when you get here, the value and location stacks
1247 have just been pushed. So pushing a state here evens the stacks. */
1248 yyssp++;
1249
1250 yysetstate:
1251 *yyssp = yystate;
1252
1253 if (yyss + yystacksize - 1 <= yyssp)
1254 {
1255 /* Get the current used size of the three stacks, in elements. */
1256 YYSIZE_T yysize = yyssp - yyss + 1;
1257
1258#ifdef yyoverflow
1259 {
1260 /* Give user a chance to reallocate the stack. Use copies of
1261 these so that the &'s don't force the real ones into
1262 memory. */
1263 YYSTYPE *yyvs1 = yyvs;
1264 yytype_int16 *yyss1 = yyss;
1265
1266 /* Each stack pointer address is followed by the size of the
1267 data in use in that stack, in bytes. This used to be a
1268 conditional around just the two extra args, but that might
1269 be undefined if yyoverflow is a macro. */
1270 yyoverflow (YY_("memory exhausted"),
1271 &yyss1, yysize * sizeof (*yyssp),
1272 &yyvs1, yysize * sizeof (*yyvsp),
1273 &yystacksize);
1274
1275 yyss = yyss1;
1276 yyvs = yyvs1;
1277 }
1278#else /* no yyoverflow */
1279# ifndef YYSTACK_RELOCATE
1280 goto yyexhaustedlab;
1281# else
1282 /* Extend the stack our own way. */
1283 if (YYMAXDEPTH <= yystacksize)
1284 goto yyexhaustedlab;
1285 yystacksize *= 2;
1286 if (YYMAXDEPTH < yystacksize)
1287 yystacksize = YYMAXDEPTH;
1288
1289 {
1290 yytype_int16 *yyss1 = yyss;
1291 union yyalloc *yyptr =
1292 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1293 if (! yyptr)
1294 goto yyexhaustedlab;
1295 YYSTACK_RELOCATE (yyss_alloc, yyss);
1296 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1297# undef YYSTACK_RELOCATE
1298 if (yyss1 != yyssa)
1299 YYSTACK_FREE (yyss1);
1300 }
1301# endif
1302#endif /* no yyoverflow */
1303
1304 yyssp = yyss + yysize - 1;
1305 yyvsp = yyvs + yysize - 1;
1306
1307 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1308 (unsigned long int) yystacksize));
1309
1310 if (yyss + yystacksize - 1 <= yyssp)
1311 YYABORT;
1312 }
1313
1314 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1315
1316 if (yystate == YYFINAL)
1317 YYACCEPT;
1318
1319 goto yybackup;
1320
1321/*-----------.
1322| yybackup. |
1323`-----------*/
1324yybackup:
1325
1326 /* Do appropriate processing given the current state. Read a
1327 lookahead token if we need one and don't already have one. */
1328
1329 /* First try to decide what to do without reference to lookahead token. */
1330 yyn = yypact[yystate];
1331 if (yyn == YYPACT_NINF)
1332 goto yydefault;
1333
1334 /* Not known => get a lookahead token if don't already have one. */
1335
1336 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1337 if (yychar == YYEMPTY)
1338 {
1339 YYDPRINTF ((stderr, "Reading a token: "));
1340 yychar = YYLEX;
1341 }
1342
1343 if (yychar <= YYEOF)
1344 {
1345 yychar = yytoken = YYEOF;
1346 YYDPRINTF ((stderr, "Now at end of input.\n"));
1347 }
1348 else
1349 {
1350 yytoken = YYTRANSLATE (yychar);
1351 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1352 }
1353
1354 /* If the proper action on seeing token YYTOKEN is to reduce or to
1355 detect an error, take that action. */
1356 yyn += yytoken;
1357 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1358 goto yydefault;
1359 yyn = yytable[yyn];
1360 if (yyn <= 0)
1361 {
1362 if (yyn == 0 || yyn == YYTABLE_NINF)
1363 goto yyerrlab;
1364 yyn = -yyn;
1365 goto yyreduce;
1366 }
1367
1368 /* Count tokens shifted since error; after three, turn off error
1369 status. */
1370 if (yyerrstatus)
1371 yyerrstatus--;
1372
1373 /* Shift the lookahead token. */
1374 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1375
1376 /* Discard the shifted token. */
1377 yychar = YYEMPTY;
1378
1379 yystate = yyn;
1380 *++yyvsp = yylval;
1381
1382 goto yynewstate;
1383
1384
1385/*-----------------------------------------------------------.
1386| yydefault -- do the default action for the current state. |
1387`-----------------------------------------------------------*/
1388yydefault:
1389 yyn = yydefact[yystate];
1390 if (yyn == 0)
1391 goto yyerrlab;
1392 goto yyreduce;
1393
1394
1395/*-----------------------------.
1396| yyreduce -- Do a reduction. |
1397`-----------------------------*/
1398yyreduce:
1399 /* yyn is the number of a rule to reduce with. */
1400 yylen = yyr2[yyn];
1401
1402 /* If YYLEN is nonzero, implement the default value of the action:
1403 `$$ = $1'.
1404
1405 Otherwise, the following line sets YYVAL to garbage.
1406 This behavior is undocumented and Bison
1407 users should not rely upon it. Assigning to YYVAL
1408 unconditionally makes the parser a bit smaller, and it avoids a
1409 GCC warning that YYVAL may be used uninitialized. */
1410 yyval = yyvsp[1-yylen];
1411
1412
1413 YY_REDUCE_PRINT (yyn);
1414 switch (yyn)
1415 {
1416 case 5:
1417
1418/* Line 1455 of yacc.c */
1419#line 87 "jsgf_parser.y"
1420 { jsgf->name = (yyvsp[(2) - (2)].name); }
1421 break;
1422
1423 case 7:
1424
1425/* Line 1455 of yacc.c */
1426#line 91 "jsgf_parser.y"
1427 { jsgf->version = (yyvsp[(2) - (3)].name); }
1428 break;
1429
1430 case 8:
1431
1432/* Line 1455 of yacc.c */
1433#line 92 "jsgf_parser.y"
1434 { jsgf->version = (yyvsp[(2) - (4)].name); jsgf->charset = (yyvsp[(3) - (4)].name); }
1435 break;
1436
1437 case 9:
1438
1439/* Line 1455 of yacc.c */
1440#line 93 "jsgf_parser.y"
1441 { jsgf->version = (yyvsp[(2) - (5)].name); jsgf->charset = (yyvsp[(3) - (5)].name);
1442 jsgf->locale = (yyvsp[(4) - (5)].name); }
1443 break;
1444
1445 case 10:
1446
1447/* Line 1455 of yacc.c */
1448#line 97 "jsgf_parser.y"
1449 { (yyval.name) = (yyvsp[(2) - (3)].name); }
1450 break;
1451
1452 case 13:
1453
1454/* Line 1455 of yacc.c */
1455#line 104 "jsgf_parser.y"
1456 { jsgf_import_rule(jsgf, (yyvsp[(2) - (3)].name)); ckd_free((yyvsp[(2) - (3)].name)); }
1457 break;
1458
1459 case 16:
1460
1461/* Line 1455 of yacc.c */
1462#line 111 "jsgf_parser.y"
1463 { jsgf_define_rule(jsgf, (yyvsp[(1) - (4)].name), (yyvsp[(3) - (4)].rhs), 0); ckd_free((yyvsp[(1) - (4)].name)); }
1464 break;
1465
1466 case 17:
1467
1468/* Line 1455 of yacc.c */
1469#line 112 "jsgf_parser.y"
1470 { jsgf_define_rule(jsgf, (yyvsp[(2) - (5)].name), (yyvsp[(4) - (5)].rhs), 1); ckd_free((yyvsp[(2) - (5)].name)); }
1471 break;
1472
1473 case 18:
1474
1475/* Line 1455 of yacc.c */
1476#line 115 "jsgf_parser.y"
1477 { (yyval.rhs) = (yyvsp[(1) - (1)].rhs); (yyval.rhs)->atoms = glist_reverse((yyval.rhs)->atoms); }
1478 break;
1479
1480 case 19:
1481
1482/* Line 1455 of yacc.c */
1483#line 116 "jsgf_parser.y"
1484 { (yyval.rhs) = (yyvsp[(3) - (3)].rhs);
1485 (yyval.rhs)->atoms = glist_reverse((yyval.rhs)->atoms);
1486 (yyval.rhs)->alt = (yyvsp[(1) - (3)].rhs); }
1487 break;
1488
1489 case 20:
1490
1491/* Line 1455 of yacc.c */
1492#line 121 "jsgf_parser.y"
1493 { (yyval.rhs) = ckd_calloc(1, sizeof(*(yyval.rhs)));
1494 (yyval.rhs)->atoms = glist_add_ptr((yyval.rhs)->atoms, (yyvsp[(1) - (1)].atom)); }
1495 break;
1496
1497 case 21:
1498
1499/* Line 1455 of yacc.c */
1500#line 123 "jsgf_parser.y"
1501 { (yyval.rhs) = (yyvsp[(1) - (2)].rhs);
1502 (yyval.rhs)->atoms = glist_add_ptr((yyval.rhs)->atoms, (yyvsp[(2) - (2)].atom)); }
1503 break;
1504
1505 case 23:
1506
1507/* Line 1455 of yacc.c */
1508#line 128 "jsgf_parser.y"
1509 { (yyval.atom) = (yyvsp[(1) - (2)].atom);
1510 (yyval.atom)->tags = glist_add_ptr((yyval.atom)->tags, (yyvsp[(2) - (2)].name)); }
1511 break;
1512
1513 case 25:
1514
1515/* Line 1455 of yacc.c */
1516#line 133 "jsgf_parser.y"
1517 { (yyval.atom) = (yyvsp[(2) - (2)].atom); (yyval.atom)->weight = (yyvsp[(1) - (2)].weight); }
1518 break;
1519
1520 case 26:
1521
1522/* Line 1455 of yacc.c */
1523#line 136 "jsgf_parser.y"
1524 { (yyval.rule) = jsgf_define_rule(jsgf, NULL, (yyvsp[(2) - (3)].rhs), 0); }
1525 break;
1526
1527 case 27:
1528
1529/* Line 1455 of yacc.c */
1530#line 139 "jsgf_parser.y"
1531 { (yyval.rule) = jsgf_optional_new(jsgf, (yyvsp[(2) - (3)].rhs)); }
1532 break;
1533
1534 case 28:
1535
1536/* Line 1455 of yacc.c */
1537#line 142 "jsgf_parser.y"
1538 { (yyval.atom) = jsgf_atom_new((yyvsp[(1) - (1)].name), 1.0); ckd_free((yyvsp[(1) - (1)].name)); }
1539 break;
1540
1541 case 29:
1542
1543/* Line 1455 of yacc.c */
1544#line 143 "jsgf_parser.y"
1545 { (yyval.atom) = jsgf_atom_new((yyvsp[(1) - (1)].name), 1.0); ckd_free((yyvsp[(1) - (1)].name)); }
1546 break;
1547
1548 case 30:
1549
1550/* Line 1455 of yacc.c */
1551#line 144 "jsgf_parser.y"
1552 { (yyval.atom) = jsgf_atom_new((yyvsp[(1) - (1)].rule)->name, 1.0); }
1553 break;
1554
1555 case 31:
1556
1557/* Line 1455 of yacc.c */
1558#line 145 "jsgf_parser.y"
1559 { (yyval.atom) = jsgf_atom_new((yyvsp[(1) - (1)].rule)->name, 1.0); }
1560 break;
1561
1562 case 32:
1563
1564/* Line 1455 of yacc.c */
1565#line 146 "jsgf_parser.y"
1566 { (yyval.atom) = jsgf_kleene_new(jsgf, (yyvsp[(1) - (2)].atom), 0); }
1567 break;
1568
1569 case 33:
1570
1571/* Line 1455 of yacc.c */
1572#line 147 "jsgf_parser.y"
1573 { (yyval.atom) = jsgf_kleene_new(jsgf, (yyvsp[(1) - (2)].atom), 1); }
1574 break;
1575
1576
1577
1578/* Line 1455 of yacc.c */
1579#line 1580 "jsgf_parser.c"
1580 default: break;
1581 }
1582 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1583
1584 YYPOPSTACK (yylen);
1585 yylen = 0;
1586 YY_STACK_PRINT (yyss, yyssp);
1587
1588 *++yyvsp = yyval;
1589
1590 /* Now `shift' the result of the reduction. Determine what state
1591 that goes to, based on the state we popped back to and the rule
1592 number reduced by. */
1593
1594 yyn = yyr1[yyn];
1595
1596 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1597 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1598 yystate = yytable[yystate];
1599 else
1600 yystate = yydefgoto[yyn - YYNTOKENS];
1601
1602 goto yynewstate;
1603
1604
1605/*------------------------------------.
1606| yyerrlab -- here on detecting error |
1607`------------------------------------*/
1608yyerrlab:
1609 /* If not already recovering from an error, report this error. */
1610 if (!yyerrstatus)
1611 {
1612 ++yynerrs;
1613#if ! YYERROR_VERBOSE
1614 yyerror (yyscanner, jsgf, YY_("syntax error"));
1615#else
1616 {
1617 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1618 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1619 {
1620 YYSIZE_T yyalloc = 2 * yysize;
1621 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1622 yyalloc = YYSTACK_ALLOC_MAXIMUM;
1623 if (yymsg != yymsgbuf)
1624 YYSTACK_FREE (yymsg);
1625 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1626 if (yymsg)
1627 yymsg_alloc = yyalloc;
1628 else
1629 {
1630 yymsg = yymsgbuf;
1631 yymsg_alloc = sizeof yymsgbuf;
1632 }
1633 }
1634
1635 if (0 < yysize && yysize <= yymsg_alloc)
1636 {
1637 (void) yysyntax_error (yymsg, yystate, yychar);
1638 yyerror (yyscanner, jsgf, yymsg);
1639 }
1640 else
1641 {
1642 yyerror (yyscanner, jsgf, YY_("syntax error"));
1643 if (yysize != 0)
1644 goto yyexhaustedlab;
1645 }
1646 }
1647#endif
1648 }
1649
1650
1651
1652 if (yyerrstatus == 3)
1653 {
1654 /* If just tried and failed to reuse lookahead token after an
1655 error, discard it. */
1656
1657 if (yychar <= YYEOF)
1658 {
1659 /* Return failure if at end of input. */
1660 if (yychar == YYEOF)
1661 YYABORT;
1662 }
1663 else
1664 {
1665 yydestruct ("Error: discarding",
1666 yytoken, &yylval, yyscanner, jsgf);
1667 yychar = YYEMPTY;
1668 }
1669 }
1670
1671 /* Else will try to reuse lookahead token after shifting the error
1672 token. */
1673 goto yyerrlab1;
1674
1675
1676/*---------------------------------------------------.
1677| yyerrorlab -- error raised explicitly by YYERROR. |
1678`---------------------------------------------------*/
1679yyerrorlab:
1680
1681 /* Pacify compilers like GCC when the user code never invokes
1682 YYERROR and the label yyerrorlab therefore never appears in user
1683 code. */
1684 if (/*CONSTCOND*/ 0)
1685 goto yyerrorlab;
1686
1687 /* Do not reclaim the symbols of the rule which action triggered
1688 this YYERROR. */
1689 YYPOPSTACK (yylen);
1690 yylen = 0;
1691 YY_STACK_PRINT (yyss, yyssp);
1692 yystate = *yyssp;
1693 goto yyerrlab1;
1694
1695
1696/*-------------------------------------------------------------.
1697| yyerrlab1 -- common code for both syntax error and YYERROR. |
1698`-------------------------------------------------------------*/
1699yyerrlab1:
1700 yyerrstatus = 3; /* Each real token shifted decrements this. */
1701
1702 for (;;)
1703 {
1704 yyn = yypact[yystate];
1705 if (yyn != YYPACT_NINF)
1706 {
1707 yyn += YYTERROR;
1708 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1709 {
1710 yyn = yytable[yyn];
1711 if (0 < yyn)
1712 break;
1713 }
1714 }
1715
1716 /* Pop the current state because it cannot handle the error token. */
1717 if (yyssp == yyss)
1718 YYABORT;
1719
1720
1721 yydestruct ("Error: popping",
1722 yystos[yystate], yyvsp, yyscanner, jsgf);
1723 YYPOPSTACK (1);
1724 yystate = *yyssp;
1725 YY_STACK_PRINT (yyss, yyssp);
1726 }
1727
1728 *++yyvsp = yylval;
1729
1730
1731 /* Shift the error token. */
1732 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1733
1734 yystate = yyn;
1735 goto yynewstate;
1736
1737
1738/*-------------------------------------.
1739| yyacceptlab -- YYACCEPT comes here. |
1740`-------------------------------------*/
1741yyacceptlab:
1742 yyresult = 0;
1743 goto yyreturn;
1744
1745/*-----------------------------------.
1746| yyabortlab -- YYABORT comes here. |
1747`-----------------------------------*/
1748yyabortlab:
1749 yyresult = 1;
1750 goto yyreturn;
1751
1752#if !defined(yyoverflow) || YYERROR_VERBOSE
1753/*-------------------------------------------------.
1754| yyexhaustedlab -- memory exhaustion comes here. |
1755`-------------------------------------------------*/
1756yyexhaustedlab:
1757 yyerror (yyscanner, jsgf, YY_("memory exhausted"));
1758 yyresult = 2;
1759 /* Fall through. */
1760#endif
1761
1762yyreturn:
1763 if (yychar != YYEMPTY)
1764 yydestruct ("Cleanup: discarding lookahead",
1765 yytoken, &yylval, yyscanner, jsgf);
1766 /* Do not reclaim the symbols of the rule which action triggered
1767 this YYABORT or YYACCEPT. */
1768 YYPOPSTACK (yylen);
1769 YY_STACK_PRINT (yyss, yyssp);
1770 while (yyssp != yyss)
1771 {
1772 yydestruct ("Cleanup: popping",
1773 yystos[*yyssp], yyvsp, yyscanner, jsgf);
1774 YYPOPSTACK (1);
1775 }
1776#ifndef yyoverflow
1777 if (yyss != yyssa)
1778 YYSTACK_FREE (yyss);
1779#endif
1780#if YYERROR_VERBOSE
1781 if (yymsg != yymsgbuf)
1782 YYSTACK_FREE (yymsg);
1783#endif
1784 /* Make sure YYID is used. */
1785 return YYID (yyresult);
1786}
1787
1788
1789
1790/* Line 1675 of yacc.c */
1791#line 150 "jsgf_parser.y"
1792
1793
1794void
1795yyerror(yyscan_t lex, jsgf_t *jsgf, const char *s)
1796{
1797 E_ERROR("%s at line %d current token '%s'\n", s, yyget_lineno(lex), yyget_text(lex));
1798}
1799
Sphinx's memory allocation/deallocation routines.
SPHINXBASE_EXPORT void ckd_free(void *ptr)
Test and free a 1-D array.
Definition: ckd_alloc.c:244
#define ckd_calloc(n, sz)
Macros to simplify the use of above functions.
Definition: ckd_alloc.h:248
Implementation of logging routines.
#define E_ERROR(...)
Print error message to error log.
Definition: err.h:104
SPHINXBASE_EXPORT glist_t glist_reverse(glist_t g)
Reverse the order of the given glist.
Definition: glist.c:169
SPHINXBASE_EXPORT glist_t glist_add_ptr(glist_t g, void *ptr)
Create and prepend a new list node, with the given user-defined data, at the HEAD of the given generi...
Definition: glist.c:74
Hash table implementation.
Internal definitions for JSGF grammar compiler.
char * locale
JSGF locale (default C)
Definition: jsgf_internal.h:78
char * name
Grammar name.
Definition: jsgf_internal.h:79
char * charset
JSGF charset (default UTF-8)
Definition: jsgf_internal.h:77
char * version
JSGF version (from header)
Definition: jsgf_internal.h:76