1 /* Driver template for the LEMON parser generator.
2 ** The author disclaims copyright to this source code.
3 */
4 /* First off, code is included that follows the "include" declaration
5 ** in the input grammar file. */
6 #include <stdio.h>
7 #line 16 "userdict_parser.g"
8 #include "core/userdict.hpp"
9 #line 10 "userdict_parser.c"
10 /* Next is all token values, in a form suitable for use by makeheaders.
11 ** This section will be null unless lemon is run with the -m switch.
12 */
13 /*
14 ** These constants (all generated automatically by the parser generator)
15 ** specify the various kinds of tokens (terminals) that the parser
16 ** understands.
17 **
18 ** Each symbol here is a terminal symbol in the grammar.
19 */
20 /* Make sure the INTERFACE macro is defined.
21 */
22 #ifndef INTERFACE
23 # define INTERFACE 1
24 #endif
25 /* The next thing included is series of defines which control
26 ** various aspects of the generated parser.
27 ** YYCODETYPE is the data type used for storing terminal
28 ** and nonterminal numbers. "unsigned char" is
29 ** used if there are fewer than 250 terminals
30 ** and nonterminals. "int" is used otherwise.
31 ** YYNOCODE is a number of type YYCODETYPE which corresponds
32 ** to no legal terminal or nonterminal number. This
33 ** number is used to fill in empty slots of the hash
34 ** table.
35 ** YYFALLBACK If defined, this indicates that one or more tokens
36 ** have fall-back values which should be used if the
37 ** original value of the token will not parse.
38 ** YYACTIONTYPE is the data type used for storing terminal
39 ** and nonterminal numbers. "unsigned char" is
40 ** used if there are fewer than 250 rules and
41 ** states combined. "int" is used otherwise.
42 ** userdictParseTOKENTYPE is the data type used for minor tokens given
43 ** directly to the parser from the tokenizer.
44 ** YYMINORTYPE is the data type used for all minor tokens.
45 ** This is typically a union of many types, one of
46 ** which is userdictParseTOKENTYPE. The entry in the union
47 ** for base tokens is called "yy0".
48 ** YYSTACKDEPTH is the maximum depth of the parser's stack. If
49 ** zero the stack is dynamically sized using realloc()
50 ** userdictParseARG_SDECL A static variable declaration for the %extra_argument
51 ** userdictParseARG_PDECL A parameter declaration for the %extra_argument
52 ** userdictParseARG_STORE Code to store %extra_argument into yypParser
53 ** userdictParseARG_FETCH Code to extract %extra_argument from yypParser
54 ** YYNSTATE the combined number of states.
55 ** YYNRULE the number of rules in the grammar
56 ** YYERRORSYMBOL is the code number of the error symbol. If not
57 ** defined, then do no error processing.
58 */
59 #define YYCODETYPE unsigned char
60 #define YYNOCODE 57
61 #define YYACTIONTYPE unsigned char
62 #define userdictParseTOKENTYPE RHVoice::userdict::token*
63 typedef union {
64 int yyinit;
65 userdictParseTOKENTYPE yy0;
66 RHVoice::userdict::ruleset* yy98;
67 } YYMINORTYPE;
68 #ifndef YYSTACKDEPTH
69 #define YYSTACKDEPTH 100
70 #endif
71 #define userdictParseARG_SDECL RHVoice::userdict::parse_state* ps;
72 #define userdictParseARG_PDECL ,RHVoice::userdict::parse_state* ps
73 #define userdictParseARG_FETCH RHVoice::userdict::parse_state* ps = yypParser->ps
74 #define userdictParseARG_STORE yypParser->ps = ps
75 #define YYNSTATE 86
76 #define YYNRULE 65
77 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
78 #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
79 #define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
80
81 /* The yyzerominor constant is used to initialize instances of
82 ** YYMINORTYPE objects to zero. */
83 static const YYMINORTYPE yyzerominor = { 0 };
84
85 /* Define the yytestcase() macro to be a no-op if is not already defined
86 ** otherwise.
87 **
88 ** Applications can choose to define yytestcase() in the %include section
89 ** to a macro that can assist in verifying code coverage. For production
90 ** code the yytestcase() macro should be turned off. But it is useful
91 ** for testing.
92 */
93 #ifndef yytestcase
94 # define yytestcase(X)
95 #endif
96
97
98 /* Next are the tables used to determine what action to take based on the
99 ** current state and lookahead token. These tables are used to implement
100 ** functions that take a state number and lookahead value and return an
101 ** action integer.
102 **
103 ** Suppose the action integer is N. Then the action is determined as
104 ** follows
105 **
106 ** 0 <= N < YYNSTATE Shift N. That is, push the lookahead
107 ** token onto the stack and goto state N.
108 **
109 ** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE.
110 **
111 ** N == YYNSTATE+YYNRULE A syntax error has occurred.
112 **
113 ** N == YYNSTATE+YYNRULE+1 The parser accepts its input.
114 **
115 ** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused
116 ** slots in the yy_action[] table.
117 **
118 ** The action table is constructed as a single large table named yy_action[].
119 ** Given state S and lookahead X, the action is computed as
120 **
121 ** yy_action[ yy_shift_ofst[S] + X ]
122 **
123 ** If the index value yy_shift_ofst[S]+X is out of range or if the value
124 ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]
125 ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
126 ** and that yy_default[S] should be used instead.
127 **
128 ** The formula above is for computing the action when the lookahead is
129 ** a terminal symbol. If the lookahead is a non-terminal (as occurs after
130 ** a reduce action) then the yy_reduce_ofst[] array is used in place of
131 ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
132 ** YY_SHIFT_USE_DFLT.
133 **
134 ** The following are the tables generated in this section:
135 **
136 ** yy_action[] A single table containing all actions.
137 ** yy_lookahead[] A table containing the lookahead for each entry in
138 ** yy_action. Used to detect hash collisions.
139 ** yy_shift_ofst[] For each state, the offset into yy_action for
140 ** shifting terminals.
141 ** yy_reduce_ofst[] For each state, the offset into yy_action for
142 ** shifting non-terminals after a reduce.
143 ** yy_default[] Default action for each state.
144 */
145 #define YY_ACTTAB_COUNT (181)
146 static const YYACTIONTYPE yy_action[] = {
147 /* 0 */ 18, 62, 11, 43, 33, 45, 2, 50, 78, 82,
148 /* 10 */ 33, 45, 2, 50, 78, 35, 3, 44, 58, 79,
149 /* 20 */ 78, 80, 77, 59, 58, 48, 31, 76, 77, 59,
150 /* 30 */ 58, 86, 31, 76, 77, 59, 53, 21, 47, 76,
151 /* 40 */ 53, 22, 64, 63, 25, 42, 26, 24, 12, 16,
152 /* 50 */ 69, 81, 2, 50, 78, 68, 67, 71, 87, 73,
153 /* 60 */ 70, 72, 15, 69, 58, 13, 58, 74, 77, 59,
154 /* 70 */ 60, 59, 73, 76, 72, 17, 73, 7, 72, 5,
155 /* 80 */ 57, 56, 6, 70, 65, 52, 51, 30, 65, 52,
156 /* 90 */ 46, 12, 16, 69, 10, 49, 12, 16, 69, 75,
157 /* 100 */ 140, 141, 73, 71, 72, 9, 70, 73, 8, 72,
158 /* 110 */ 19, 41, 12, 16, 69, 66, 40, 12, 16, 69,
159 /* 120 */ 39, 65, 27, 73, 83, 72, 4, 32, 73, 153,
160 /* 130 */ 72, 58, 23, 54, 14, 55, 59, 36, 85, 84,
161 /* 140 */ 153, 1, 153, 58, 153, 61, 14, 55, 59, 153,
162 /* 150 */ 17, 153, 7, 153, 153, 57, 56, 17, 70, 7,
163 /* 160 */ 153, 153, 29, 28, 20, 70, 7, 153, 34, 57,
164 /* 170 */ 56, 38, 152, 153, 153, 153, 153, 153, 153, 153,
165 /* 180 */ 37,
166 };
167 static const YYCODETYPE yy_lookahead[] = {
168 /* 0 */ 22, 9, 10, 25, 26, 27, 28, 29, 30, 25,
169 /* 10 */ 26, 27, 28, 29, 30, 1, 3, 4, 40, 29,
170 /* 20 */ 30, 31, 44, 45, 40, 39, 48, 49, 44, 45,
171 /* 30 */ 40, 0, 48, 49, 44, 45, 50, 51, 52, 49,
172 /* 40 */ 50, 51, 52, 53, 32, 33, 34, 35, 36, 37,
173 /* 50 */ 38, 27, 28, 29, 30, 11, 12, 11, 0, 47,
174 /* 60 */ 14, 49, 37, 38, 40, 2, 40, 38, 44, 45,
175 /* 70 */ 44, 45, 47, 49, 49, 6, 47, 8, 49, 5,
176 /* 80 */ 11, 12, 2, 14, 15, 16, 17, 32, 15, 16,
177 /* 90 */ 35, 36, 37, 38, 5, 35, 36, 37, 38, 7,
178 /* 100 */ 2, 2, 47, 11, 49, 3, 14, 47, 3, 49,
179 /* 110 */ 2, 35, 36, 37, 38, 50, 35, 36, 37, 38,
180 /* 120 */ 3, 15, 55, 47, 24, 49, 55, 48, 47, 56,
181 /* 130 */ 49, 40, 41, 42, 43, 44, 45, 19, 20, 21,
182 /* 140 */ 56, 23, 56, 40, 56, 42, 43, 44, 45, 56,
183 /* 150 */ 6, 56, 8, 56, 56, 11, 12, 6, 14, 8,
184 /* 160 */ 56, 56, 11, 12, 46, 14, 8, 56, 1, 11,
185 /* 170 */ 12, 4, 54, 56, 56, 56, 56, 56, 56, 56,
186 /* 180 */ 13,
187 };
188 #define YY_SHIFT_USE_DFLT (-9)
189 #define YY_SHIFT_COUNT (36)
190 #define YY_SHIFT_MIN (-8)
191 #define YY_SHIFT_MAX (167)
192 static const short yy_shift_ofst[] = {
193 /* 0 */ 167, 151, 69, 151, 46, 144, 46, 158, 46, 46,
194 /* 10 */ 46, 158, 73, 46, 158, 92, 46, 44, 13, 117,
195 /* 20 */ 117, 106, 106, -8, 105, 89, 102, 108, 99, 98,
196 /* 30 */ 89, 80, 63, 74, 58, 31, 14,
197 };
198 #define YY_REDUCE_USE_DFLT (-23)
199 #define YY_REDUCE_COUNT (22)
200 #define YY_REDUCE_MIN (-22)
201 #define YY_REDUCE_MAX (118)
202 static const signed char yy_reduce_ofst[] = {
203 /* 0 */ 118, -22, -10, -16, 12, 24, 55, 91, 81, 76,
204 /* 10 */ 60, 103, -14, 25, 26, 29, 29, 79, 100, 71,
205 /* 20 */ 67, 65, 65,
206 };
207 static const YYACTIONTYPE yy_default[] = {
208 /* 0 */ 95, 151, 109, 151, 151, 151, 151, 117, 151, 151,
209 /* 10 */ 151, 117, 130, 151, 116, 151, 129, 151, 97, 149,
210 /* 20 */ 149, 131, 110, 151, 125, 123, 122, 151, 138, 137,
211 /* 30 */ 99, 151, 151, 98, 151, 151, 151, 139, 94, 150,
212 /* 40 */ 127, 126, 91, 93, 96, 101, 125, 132, 128, 124,
213 /* 50 */ 104, 148, 147, 145, 115, 119, 138, 137, 121, 120,
214 /* 60 */ 118, 114, 113, 112, 111, 146, 144, 141, 140, 134,
215 /* 70 */ 143, 142, 136, 135, 133, 108, 107, 106, 105, 103,
216 /* 80 */ 102, 100, 92, 90, 89, 88,
217 };
218
219 /* The next table maps tokens into fallback tokens. If a construct
220 ** like the following:
221 **
222 ** %fallback ID X Y Z.
223 **
224 ** appears in the grammar, then ID becomes a fallback token for X, Y,
225 ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser
226 ** but it does not parse, the type of the token is changed to ID and
227 ** the parse is retried before an error is thrown.
228 */
229 #ifdef YYFALLBACK
230 static const YYCODETYPE yyFallback[] = {
231 };
232 #endif /* YYFALLBACK */
233
234 /* The following structure represents a single element of the
235 ** parser's stack. Information stored includes:
236 **
237 ** + The state number for the parser at this level of the stack.
238 **
239 ** + The value of the token stored at this level of the stack.
240 ** (In other words, the "major" token.)
241 **
242 ** + The semantic value stored at this level of the stack. This is
243 ** the information used by the action routines in the grammar.
244 ** It is sometimes called the "minor" token.
245 */
246 struct yyStackEntry {
247 YYACTIONTYPE stateno; /* The state-number */
248 YYCODETYPE major; /* The major token value. This is the code
249 ** number for the token at this stack level */
250 YYMINORTYPE minor; /* The user-supplied minor token value. This
251 ** is the value of the token */
252 };
253 typedef struct yyStackEntry yyStackEntry;
254
255 /* The state of the parser is completely contained in an instance of
256 ** the following structure */
257 struct yyParser {
258 int yyidx; /* Index of top element in stack */
259 #ifdef YYTRACKMAXSTACKDEPTH
260 int yyidxMax; /* Maximum value of yyidx */
261 #endif
262 int yyerrcnt; /* Shifts left before out of the error */
263 userdictParseARG_SDECL /* A place to hold %extra_argument */
264 #if YYSTACKDEPTH<=0
265 int yystksz; /* Current side of the stack */
266 yyStackEntry *yystack; /* The parser's stack */
267 #else
268 yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
269 #endif
270 };
271 typedef struct yyParser yyParser;
272
273 #ifndef NDEBUG
274 #include <stdio.h>
275 static FILE *yyTraceFILE = 0;
276 static char *yyTracePrompt = 0;
277 #endif /* NDEBUG */
278
279 #ifndef NDEBUG
280 /*
281 ** Turn parser tracing on by giving a stream to which to write the trace
282 ** and a prompt to preface each trace message. Tracing is turned off
283 ** by making either argument NULL
284 **
285 ** Inputs:
286 ** <ul>
287 ** <li> A FILE* to which trace output should be written.
288 ** If NULL, then tracing is turned off.
289 ** <li> A prefix string written at the beginning of every
290 ** line of trace output. If NULL, then tracing is
291 ** turned off.
292 ** </ul>
293 **
294 ** Outputs:
295 ** None.
296 */
userdictParseTrace(FILE * TraceFILE,char * zTracePrompt)297 void userdictParseTrace(FILE *TraceFILE, char *zTracePrompt){
298 yyTraceFILE = TraceFILE;
299 yyTracePrompt = zTracePrompt;
300 if( yyTraceFILE==0 ) yyTracePrompt = 0;
301 else if( yyTracePrompt==0 ) yyTraceFILE = 0;
302 }
303 #endif /* NDEBUG */
304
305 #ifndef NDEBUG
306 /* For tracing shifts, the names of all terminals and nonterminals
307 ** are required. The following table supplies these names */
308 static const char *const yyTokenName[] = {
309 "$", "NEWLINE", "EQUALS", "SPACE",
310 "STAR", "AND", "LPAREN", "RPAREN",
311 "LBRACE", "RBRACE", "COMMA", "NATIVE_LETTERS",
312 "ENGLISH_LETTERS", "SYM", "PLUS", "STRESSED_SYL_NUMBER",
313 "UNSTRESSED", "INITIALISM", "error", "rule",
314 "collocation_rule", "symbol_rule", "tokens", "prefix",
315 "suffix", "token", "words", "word",
316 "inline_rewrites", "inline_rewrite", "inline_replacement", "word_flags",
317 "token_pron", "symbol_pron", "spaced_symbol_pron", "word_pron",
318 "pron_repr", "text_pron_repr", "text_pron_repr_atom", "word_pron_flags",
319 "set", "set_elements", "set_element", "pattern",
320 "subpattern", "substring", "symbol", "insertion",
321 "deletion", "stress_mark", "stressed_syl_number", "stressed_syl_numbers",
322 "unstressed_flag", "initialism_flag", "line", "space",
323 };
324 #endif /* NDEBUG */
325
326 #ifndef NDEBUG
327 /* For tracing reduce actions, the names of all rules are required.
328 */
329 static const char *const yyRuleName[] = {
330 /* 0 */ "line ::= rule NEWLINE",
331 /* 1 */ "line ::= NEWLINE",
332 /* 2 */ "rule ::= collocation_rule",
333 /* 3 */ "rule ::= symbol_rule",
334 /* 4 */ "collocation_rule ::= prefix tokens suffix",
335 /* 5 */ "symbol_rule ::= symbol space EQUALS space symbol_pron",
336 /* 6 */ "tokens ::= tokens SPACE token",
337 /* 7 */ "tokens ::= token",
338 /* 8 */ "prefix ::= STAR",
339 /* 9 */ "prefix ::=",
340 /* 10 */ "suffix ::= STAR",
341 /* 11 */ "suffix ::=",
342 /* 12 */ "token ::= words",
343 /* 13 */ "token ::= deletion EQUALS token_pron",
344 /* 14 */ "words ::= words AND word",
345 /* 15 */ "words ::= word",
346 /* 16 */ "word ::= inline_rewrites word_flags",
347 /* 17 */ "inline_rewrites ::= inline_rewrites inline_rewrite",
348 /* 18 */ "inline_rewrites ::= inline_rewrite",
349 /* 19 */ "inline_rewrite ::= inline_replacement",
350 /* 20 */ "inline_rewrite ::= subpattern",
351 /* 21 */ "inline_rewrite ::= stress_mark",
352 /* 22 */ "inline_replacement ::= LPAREN deletion EQUALS text_pron_repr RPAREN",
353 /* 23 */ "word_flags ::=",
354 /* 24 */ "word_flags ::= stressed_syl_numbers",
355 /* 25 */ "word_flags ::= unstressed_flag",
356 /* 26 */ "word_flags ::= initialism_flag",
357 /* 27 */ "set ::= LBRACE set_elements RBRACE",
358 /* 28 */ "set_elements ::= set_elements COMMA set_element",
359 /* 29 */ "set_elements ::= set_element",
360 /* 30 */ "set_element ::= pattern",
361 /* 31 */ "set_element ::=",
362 /* 32 */ "pattern ::= pattern subpattern",
363 /* 33 */ "pattern ::= subpattern",
364 /* 34 */ "subpattern ::= substring",
365 /* 35 */ "subpattern ::= set",
366 /* 36 */ "symbol_pron ::= spaced_symbol_pron",
367 /* 37 */ "symbol_pron ::= token_pron",
368 /* 38 */ "token_pron ::= token_pron AND word_pron",
369 /* 39 */ "token_pron ::= word_pron",
370 /* 40 */ "spaced_symbol_pron ::= spaced_symbol_pron SPACE word_pron",
371 /* 41 */ "spaced_symbol_pron ::= word_pron SPACE word_pron",
372 /* 42 */ "word_pron ::= pron_repr word_pron_flags",
373 /* 43 */ "pron_repr ::= text_pron_repr",
374 /* 44 */ "word_pron_flags ::=",
375 /* 45 */ "word_pron_flags ::= stressed_syl_numbers",
376 /* 46 */ "word_pron_flags ::= unstressed_flag",
377 /* 47 */ "text_pron_repr ::= text_pron_repr text_pron_repr_atom",
378 /* 48 */ "text_pron_repr ::= text_pron_repr_atom",
379 /* 49 */ "text_pron_repr_atom ::= insertion",
380 /* 50 */ "text_pron_repr_atom ::= stress_mark",
381 /* 51 */ "substring ::= NATIVE_LETTERS",
382 /* 52 */ "substring ::= ENGLISH_LETTERS",
383 /* 53 */ "symbol ::= SYM",
384 /* 54 */ "deletion ::= NATIVE_LETTERS",
385 /* 55 */ "deletion ::= ENGLISH_LETTERS",
386 /* 56 */ "insertion ::= NATIVE_LETTERS",
387 /* 57 */ "stress_mark ::= PLUS",
388 /* 58 */ "stressed_syl_numbers ::= stressed_syl_numbers stressed_syl_number",
389 /* 59 */ "stressed_syl_numbers ::= stressed_syl_number",
390 /* 60 */ "stressed_syl_number ::= STRESSED_SYL_NUMBER",
391 /* 61 */ "unstressed_flag ::= UNSTRESSED",
392 /* 62 */ "initialism_flag ::= INITIALISM",
393 /* 63 */ "space ::=",
394 /* 64 */ "space ::= SPACE",
395 };
396 #endif /* NDEBUG */
397
398
399 #if YYSTACKDEPTH<=0
400 /*
401 ** Try to increase the size of the parser stack.
402 */
yyGrowStack(yyParser * p)403 static void yyGrowStack(yyParser *p){
404 int newSize;
405 yyStackEntry *pNew;
406
407 newSize = p->yystksz*2 + 100;
408 pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
409 if( pNew ){
410 p->yystack = pNew;
411 p->yystksz = newSize;
412 #ifndef NDEBUG
413 if( yyTraceFILE ){
414 fprintf(yyTraceFILE,"%sStack grows to %d entries!\n",
415 yyTracePrompt, p->yystksz);
416 }
417 #endif
418 }
419 }
420 #endif
421
422 /*
423 ** This function allocates a new parser.
424 ** The only argument is a pointer to a function which works like
425 ** malloc.
426 **
427 ** Inputs:
428 ** A pointer to the function used to allocate memory.
429 **
430 ** Outputs:
431 ** A pointer to a parser. This pointer is used in subsequent calls
432 ** to userdictParse and userdictParseFree.
433 */
userdictParseAlloc(void * (* mallocProc)(size_t))434 void *userdictParseAlloc(void *(*mallocProc)(size_t)){
435 yyParser *pParser;
436 pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) );
437 if( pParser ){
438 pParser->yyidx = -1;
439 #ifdef YYTRACKMAXSTACKDEPTH
440 pParser->yyidxMax = 0;
441 #endif
442 #if YYSTACKDEPTH<=0
443 pParser->yystack = NULL;
444 pParser->yystksz = 0;
445 yyGrowStack(pParser);
446 #endif
447 }
448 return pParser;
449 }
450
451 /* The following function deletes the value associated with a
452 ** symbol. The symbol can be either a terminal or nonterminal.
453 ** "yymajor" is the symbol code, and "yypminor" is a pointer to
454 ** the value.
455 */
yy_destructor(yyParser * yypParser,YYCODETYPE yymajor,YYMINORTYPE * yypminor)456 static void yy_destructor(
457 yyParser *yypParser, /* The parser */
458 YYCODETYPE yymajor, /* Type code for object to destroy */
459 YYMINORTYPE *yypminor /* The object to be destroyed */
460 ){
461 userdictParseARG_FETCH;
462 switch( yymajor ){
463 /* Here is inserted the actions which take place when a
464 ** terminal or non-terminal is destroyed. This can happen
465 ** when the symbol is popped from the stack during a
466 ** reduce or during error processing or when a parser is
467 ** being destroyed before it is finished parsing.
468 **
469 ** Note: during a reduce, the only symbols destroyed are those
470 ** which appear on the RHS of the rule, but which are not used
471 ** inside the C code.
472 */
473 /* TERMINAL Destructor */
474 case 1: /* NEWLINE */
475 case 2: /* EQUALS */
476 case 3: /* SPACE */
477 case 4: /* STAR */
478 case 5: /* AND */
479 case 6: /* LPAREN */
480 case 7: /* RPAREN */
481 case 8: /* LBRACE */
482 case 9: /* RBRACE */
483 case 10: /* COMMA */
484 case 11: /* NATIVE_LETTERS */
485 case 12: /* ENGLISH_LETTERS */
486 case 13: /* SYM */
487 case 14: /* PLUS */
488 case 15: /* STRESSED_SYL_NUMBER */
489 case 16: /* UNSTRESSED */
490 case 17: /* INITIALISM */
491 {
492 #line 24 "userdict_parser.g"
493 delete (yypminor->yy0);
494 #line 495 "userdict_parser.c"
495 }
496 break;
497 case 19: /* rule */
498 case 20: /* collocation_rule */
499 case 21: /* symbol_rule */
500 case 22: /* tokens */
501 case 23: /* prefix */
502 case 24: /* suffix */
503 case 25: /* token */
504 case 26: /* words */
505 case 27: /* word */
506 case 28: /* inline_rewrites */
507 case 29: /* inline_rewrite */
508 case 30: /* inline_replacement */
509 case 31: /* word_flags */
510 case 32: /* token_pron */
511 case 33: /* symbol_pron */
512 case 34: /* spaced_symbol_pron */
513 case 35: /* word_pron */
514 case 36: /* pron_repr */
515 case 37: /* text_pron_repr */
516 case 38: /* text_pron_repr_atom */
517 case 39: /* word_pron_flags */
518 case 40: /* set */
519 case 41: /* set_elements */
520 case 42: /* set_element */
521 case 43: /* pattern */
522 case 44: /* subpattern */
523 case 45: /* substring */
524 case 46: /* symbol */
525 case 47: /* insertion */
526 case 48: /* deletion */
527 case 49: /* stress_mark */
528 case 50: /* stressed_syl_number */
529 case 51: /* stressed_syl_numbers */
530 case 52: /* unstressed_flag */
531 case 53: /* initialism_flag */
532 {
533 #line 27 "userdict_parser.g"
534 delete (yypminor->yy98);
535 #line 536 "userdict_parser.c"
536 }
537 break;
538 default: break; /* If no destructor action specified: do nothing */
539 }
540 }
541
542 /*
543 ** Pop the parser's stack once.
544 **
545 ** If there is a destructor routine associated with the token which
546 ** is popped from the stack, then call it.
547 **
548 ** Return the major token number for the symbol popped.
549 */
yy_pop_parser_stack(yyParser * pParser)550 static int yy_pop_parser_stack(yyParser *pParser){
551 YYCODETYPE yymajor;
552 yyStackEntry *yytos = &pParser->yystack[pParser->yyidx];
553
554 if( pParser->yyidx<0 ) return 0;
555 #ifndef NDEBUG
556 if( yyTraceFILE && pParser->yyidx>=0 ){
557 fprintf(yyTraceFILE,"%sPopping %s\n",
558 yyTracePrompt,
559 yyTokenName[yytos->major]);
560 }
561 #endif
562 yymajor = yytos->major;
563 yy_destructor(pParser, yymajor, &yytos->minor);
564 pParser->yyidx--;
565 return yymajor;
566 }
567
568 /*
569 ** Deallocate and destroy a parser. Destructors are all called for
570 ** all stack elements before shutting the parser down.
571 **
572 ** Inputs:
573 ** <ul>
574 ** <li> A pointer to the parser. This should be a pointer
575 ** obtained from userdictParseAlloc.
576 ** <li> A pointer to a function used to reclaim memory obtained
577 ** from malloc.
578 ** </ul>
579 */
userdictParseFree(void * p,void (* freeProc)(void *))580 void userdictParseFree(
581 void *p, /* The parser to be deleted */
582 void (*freeProc)(void*) /* Function used to reclaim memory */
583 ){
584 yyParser *pParser = (yyParser*)p;
585 if( pParser==0 ) return;
586 while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser);
587 #if YYSTACKDEPTH<=0
588 free(pParser->yystack);
589 #endif
590 (*freeProc)((void*)pParser);
591 }
592
593 /*
594 ** Return the peak depth of the stack for a parser.
595 */
596 #ifdef YYTRACKMAXSTACKDEPTH
userdictParseStackPeak(void * p)597 int userdictParseStackPeak(void *p){
598 yyParser *pParser = (yyParser*)p;
599 return pParser->yyidxMax;
600 }
601 #endif
602
603 /*
604 ** Find the appropriate action for a parser given the terminal
605 ** look-ahead token iLookAhead.
606 **
607 ** If the look-ahead token is YYNOCODE, then check to see if the action is
608 ** independent of the look-ahead. If it is, return the action, otherwise
609 ** return YY_NO_ACTION.
610 */
yy_find_shift_action(yyParser * pParser,YYCODETYPE iLookAhead)611 static int yy_find_shift_action(
612 yyParser *pParser, /* The parser */
613 YYCODETYPE iLookAhead /* The look-ahead token */
614 ){
615 int i;
616 int stateno = pParser->yystack[pParser->yyidx].stateno;
617
618 if( stateno>YY_SHIFT_COUNT
619 || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){
620 return yy_default[stateno];
621 }
622 assert( iLookAhead!=YYNOCODE );
623 i += iLookAhead;
624 if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
625 if( iLookAhead>0 ){
626 #ifdef YYFALLBACK
627 YYCODETYPE iFallback; /* Fallback token */
628 if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
629 && (iFallback = yyFallback[iLookAhead])!=0 ){
630 #ifndef NDEBUG
631 if( yyTraceFILE ){
632 fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
633 yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
634 }
635 #endif
636 return yy_find_shift_action(pParser, iFallback);
637 }
638 #endif
639 #ifdef YYWILDCARD
640 {
641 int j = i - iLookAhead + YYWILDCARD;
642 if(
643 #if YY_SHIFT_MIN+YYWILDCARD<0
644 j>=0 &&
645 #endif
646 #if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
647 j<YY_ACTTAB_COUNT &&
648 #endif
649 yy_lookahead[j]==YYWILDCARD
650 ){
651 #ifndef NDEBUG
652 if( yyTraceFILE ){
653 fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
654 yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]);
655 }
656 #endif /* NDEBUG */
657 return yy_action[j];
658 }
659 }
660 #endif /* YYWILDCARD */
661 }
662 return yy_default[stateno];
663 }else{
664 return yy_action[i];
665 }
666 }
667
668 /*
669 ** Find the appropriate action for a parser given the non-terminal
670 ** look-ahead token iLookAhead.
671 **
672 ** If the look-ahead token is YYNOCODE, then check to see if the action is
673 ** independent of the look-ahead. If it is, return the action, otherwise
674 ** return YY_NO_ACTION.
675 */
yy_find_reduce_action(int stateno,YYCODETYPE iLookAhead)676 static int yy_find_reduce_action(
677 int stateno, /* Current state number */
678 YYCODETYPE iLookAhead /* The look-ahead token */
679 ){
680 int i;
681 #ifdef YYERRORSYMBOL
682 if( stateno>YY_REDUCE_COUNT ){
683 return yy_default[stateno];
684 }
685 #else
686 assert( stateno<=YY_REDUCE_COUNT );
687 #endif
688 i = yy_reduce_ofst[stateno];
689 assert( i!=YY_REDUCE_USE_DFLT );
690 assert( iLookAhead!=YYNOCODE );
691 i += iLookAhead;
692 #ifdef YYERRORSYMBOL
693 if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
694 return yy_default[stateno];
695 }
696 #else
697 assert( i>=0 && i<YY_ACTTAB_COUNT );
698 assert( yy_lookahead[i]==iLookAhead );
699 #endif
700 return yy_action[i];
701 }
702
703 /*
704 ** The following routine is called if the stack overflows.
705 */
yyStackOverflow(yyParser * yypParser,YYMINORTYPE * yypMinor)706 static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){
707 userdictParseARG_FETCH;
708 yypParser->yyidx--;
709 #ifndef NDEBUG
710 if( yyTraceFILE ){
711 fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
712 }
713 #endif
714 while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
715 /* Here code is inserted which will execute if the parser
716 ** stack every overflows */
717 userdictParseARG_STORE; /* Suppress warning about unused %extra_argument var */
718 }
719
720 /*
721 ** Perform a shift action.
722 */
yy_shift(yyParser * yypParser,int yyNewState,int yyMajor,YYMINORTYPE * yypMinor)723 static void yy_shift(
724 yyParser *yypParser, /* The parser to be shifted */
725 int yyNewState, /* The new state to shift in */
726 int yyMajor, /* The major token to shift in */
727 YYMINORTYPE *yypMinor /* Pointer to the minor token to shift in */
728 ){
729 yyStackEntry *yytos;
730 yypParser->yyidx++;
731 #ifdef YYTRACKMAXSTACKDEPTH
732 if( yypParser->yyidx>yypParser->yyidxMax ){
733 yypParser->yyidxMax = yypParser->yyidx;
734 }
735 #endif
736 #if YYSTACKDEPTH>0
737 if( yypParser->yyidx>=YYSTACKDEPTH ){
738 yyStackOverflow(yypParser, yypMinor);
739 return;
740 }
741 #else
742 if( yypParser->yyidx>=yypParser->yystksz ){
743 yyGrowStack(yypParser);
744 if( yypParser->yyidx>=yypParser->yystksz ){
745 yyStackOverflow(yypParser, yypMinor);
746 return;
747 }
748 }
749 #endif
750 yytos = &yypParser->yystack[yypParser->yyidx];
751 yytos->stateno = (YYACTIONTYPE)yyNewState;
752 yytos->major = (YYCODETYPE)yyMajor;
753 yytos->minor = *yypMinor;
754 #ifndef NDEBUG
755 if( yyTraceFILE && yypParser->yyidx>0 ){
756 int i;
757 fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState);
758 fprintf(yyTraceFILE,"%sStack:",yyTracePrompt);
759 for(i=1; i<=yypParser->yyidx; i++)
760 fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]);
761 fprintf(yyTraceFILE,"\n");
762 }
763 #endif
764 }
765
766 /* The following table contains information about every rule that
767 ** is used during the reduce.
768 */
769 static const struct {
770 YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
771 unsigned char nrhs; /* Number of right-hand side symbols in the rule */
772 } yyRuleInfo[] = {
773 { 54, 2 },
774 { 54, 1 },
775 { 19, 1 },
776 { 19, 1 },
777 { 20, 3 },
778 { 21, 5 },
779 { 22, 3 },
780 { 22, 1 },
781 { 23, 1 },
782 { 23, 0 },
783 { 24, 1 },
784 { 24, 0 },
785 { 25, 1 },
786 { 25, 3 },
787 { 26, 3 },
788 { 26, 1 },
789 { 27, 2 },
790 { 28, 2 },
791 { 28, 1 },
792 { 29, 1 },
793 { 29, 1 },
794 { 29, 1 },
795 { 30, 5 },
796 { 31, 0 },
797 { 31, 1 },
798 { 31, 1 },
799 { 31, 1 },
800 { 40, 3 },
801 { 41, 3 },
802 { 41, 1 },
803 { 42, 1 },
804 { 42, 0 },
805 { 43, 2 },
806 { 43, 1 },
807 { 44, 1 },
808 { 44, 1 },
809 { 33, 1 },
810 { 33, 1 },
811 { 32, 3 },
812 { 32, 1 },
813 { 34, 3 },
814 { 34, 3 },
815 { 35, 2 },
816 { 36, 1 },
817 { 39, 0 },
818 { 39, 1 },
819 { 39, 1 },
820 { 37, 2 },
821 { 37, 1 },
822 { 38, 1 },
823 { 38, 1 },
824 { 45, 1 },
825 { 45, 1 },
826 { 46, 1 },
827 { 48, 1 },
828 { 48, 1 },
829 { 47, 1 },
830 { 49, 1 },
831 { 51, 2 },
832 { 51, 1 },
833 { 50, 1 },
834 { 52, 1 },
835 { 53, 1 },
836 { 55, 0 },
837 { 55, 1 },
838 };
839
840 static void yy_accept(yyParser*); /* Forward Declaration */
841
842 /*
843 ** Perform a reduce action and the shift that must immediately
844 ** follow the reduce.
845 */
yy_reduce(yyParser * yypParser,int yyruleno)846 static void yy_reduce(
847 yyParser *yypParser, /* The parser */
848 int yyruleno /* Number of the rule by which to reduce */
849 ){
850 int yygoto; /* The next state */
851 int yyact; /* The next action */
852 YYMINORTYPE yygotominor; /* The LHS of the rule reduced */
853 yyStackEntry *yymsp; /* The top of the parser's stack */
854 int yysize; /* Amount to pop the stack */
855 userdictParseARG_FETCH;
856 yymsp = &yypParser->yystack[yypParser->yyidx];
857 #ifndef NDEBUG
858 if( yyTraceFILE && yyruleno>=0
859 && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
860 fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
861 yyRuleName[yyruleno]);
862 }
863 #endif /* NDEBUG */
864
865 /* Silence complaints from purify about yygotominor being uninitialized
866 ** in some cases when it is copied into the stack after the following
867 ** switch. yygotominor is uninitialized when a rule reduces that does
868 ** not set the value of its left-hand side nonterminal. Leaving the
869 ** value of the nonterminal uninitialized is utterly harmless as long
870 ** as the value is never used. So really the only thing this code
871 ** accomplishes is to quieten purify.
872 **
873 ** 2007-01-16: The wireshark project (www.wireshark.org) reports that
874 ** without this code, their parser segfaults. I'm not sure what there
875 ** parser is doing to make this happen. This is the second bug report
876 ** from wireshark this week. Clearly they are stressing Lemon in ways
877 ** that it has not been previously stressed... (SQLite ticket #2172)
878 */
879 /*memset(&yygotominor, 0, sizeof(yygotominor));*/
880 yygotominor = yyzerominor;
881
882
883 switch( yyruleno ){
884 /* Beginning here are the reduction cases. A typical example
885 ** follows:
886 ** case 0:
887 ** #line <lineno> <grammarfile>
888 ** { ... } // User supplied code
889 ** #line <lineno> <thisfile>
890 ** break;
891 */
892 case 0: /* line ::= rule NEWLINE */
893 #line 102 "userdict_parser.g"
894 {
895 if(!ps->error) ps->result->extend(yymsp[-1].minor.yy98);
896 delete yymsp[-1].minor.yy98;
897 yy_destructor(yypParser,1,&yymsp[0].minor);
898 }
899 #line 900 "userdict_parser.c"
900 break;
901 case 1: /* line ::= NEWLINE */
902 #line 107 "userdict_parser.g"
903 {
904 yy_destructor(yypParser,1,&yymsp[0].minor);
905 }
906 #line 907 "userdict_parser.c"
907 break;
908 case 2: /* rule ::= collocation_rule */
909 case 3: /* rule ::= symbol_rule */ yytestcase(yyruleno==3);
910 case 7: /* tokens ::= token */ yytestcase(yyruleno==7);
911 case 12: /* token ::= words */ yytestcase(yyruleno==12);
912 case 15: /* words ::= word */ yytestcase(yyruleno==15);
913 case 18: /* inline_rewrites ::= inline_rewrite */ yytestcase(yyruleno==18);
914 case 19: /* inline_rewrite ::= inline_replacement */ yytestcase(yyruleno==19);
915 case 20: /* inline_rewrite ::= subpattern */ yytestcase(yyruleno==20);
916 case 21: /* inline_rewrite ::= stress_mark */ yytestcase(yyruleno==21);
917 case 24: /* word_flags ::= stressed_syl_numbers */ yytestcase(yyruleno==24);
918 case 25: /* word_flags ::= unstressed_flag */ yytestcase(yyruleno==25);
919 case 26: /* word_flags ::= initialism_flag */ yytestcase(yyruleno==26);
920 case 29: /* set_elements ::= set_element */ yytestcase(yyruleno==29);
921 case 30: /* set_element ::= pattern */ yytestcase(yyruleno==30);
922 case 33: /* pattern ::= subpattern */ yytestcase(yyruleno==33);
923 case 34: /* subpattern ::= substring */ yytestcase(yyruleno==34);
924 case 35: /* subpattern ::= set */ yytestcase(yyruleno==35);
925 case 36: /* symbol_pron ::= spaced_symbol_pron */ yytestcase(yyruleno==36);
926 case 37: /* symbol_pron ::= token_pron */ yytestcase(yyruleno==37);
927 case 39: /* token_pron ::= word_pron */ yytestcase(yyruleno==39);
928 case 43: /* pron_repr ::= text_pron_repr */ yytestcase(yyruleno==43);
929 case 45: /* word_pron_flags ::= stressed_syl_numbers */ yytestcase(yyruleno==45);
930 case 46: /* word_pron_flags ::= unstressed_flag */ yytestcase(yyruleno==46);
931 case 48: /* text_pron_repr ::= text_pron_repr_atom */ yytestcase(yyruleno==48);
932 case 49: /* text_pron_repr_atom ::= insertion */ yytestcase(yyruleno==49);
933 case 50: /* text_pron_repr_atom ::= stress_mark */ yytestcase(yyruleno==50);
934 case 59: /* stressed_syl_numbers ::= stressed_syl_number */ yytestcase(yyruleno==59);
935 #line 110 "userdict_parser.g"
936 {
937 yygotominor.yy98=yymsp[0].minor.yy98;
938 }
939 #line 940 "userdict_parser.c"
940 break;
941 case 4: /* collocation_rule ::= prefix tokens suffix */
942 #line 120 "userdict_parser.g"
943 {
944 yygotominor.yy98=yymsp[-2].minor.yy98;
945 yygotominor.yy98->append(yymsp[-1].minor.yy98);
946 yygotominor.yy98->append(yymsp[0].minor.yy98);
947 delete yymsp[-1].minor.yy98;
948 delete yymsp[0].minor.yy98;
949 }
950 #line 951 "userdict_parser.c"
951 break;
952 case 5: /* symbol_rule ::= symbol space EQUALS space symbol_pron */
953 #line 129 "userdict_parser.g"
954 {
955 yygotominor.yy98=RHVoice::userdict::ruleset::create<RHVoice::userdict::start_of_token>();
956 yygotominor.yy98->append(yymsp[-4].minor.yy98);
957 yygotominor.yy98->append(yymsp[0].minor.yy98);
958 yygotominor.yy98->append<RHVoice::userdict::end_of_token>();
959 delete yymsp[-4].minor.yy98;
960 delete yymsp[0].minor.yy98;
961 yy_destructor(yypParser,2,&yymsp[-2].minor);
962 }
963 #line 964 "userdict_parser.c"
964 break;
965 case 6: /* tokens ::= tokens SPACE token */
966 #line 139 "userdict_parser.g"
967 {
968 yygotominor.yy98=yymsp[-2].minor.yy98;
969 yygotominor.yy98->append<RHVoice::userdict::end_of_token>();
970 yygotominor.yy98->append<RHVoice::userdict::start_of_token>();
971 yygotominor.yy98->append(yymsp[0].minor.yy98);
972 delete yymsp[0].minor.yy98;
973 yy_destructor(yypParser,3,&yymsp[-1].minor);
974 }
975 #line 976 "userdict_parser.c"
976 break;
977 case 8: /* prefix ::= STAR */
978 case 10: /* suffix ::= STAR */ yytestcase(yyruleno==10);
979 #line 153 "userdict_parser.g"
980 {
981 yygotominor.yy98=new RHVoice::userdict::ruleset;
982 yy_destructor(yypParser,4,&yymsp[0].minor);
983 }
984 #line 985 "userdict_parser.c"
985 break;
986 case 9: /* prefix ::= */
987 #line 158 "userdict_parser.g"
988 {
989 yygotominor.yy98=RHVoice::userdict::ruleset::create<RHVoice::userdict::start_of_token>();
990 }
991 #line 992 "userdict_parser.c"
992 break;
993 case 11: /* suffix ::= */
994 #line 168 "userdict_parser.g"
995 {
996 yygotominor.yy98=RHVoice::userdict::ruleset::create<RHVoice::userdict::end_of_token>();
997 }
998 #line 999 "userdict_parser.c"
999 break;
1000 case 13: /* token ::= deletion EQUALS token_pron */
1001 #line 178 "userdict_parser.g"
1002 {
1003 yygotominor.yy98=yymsp[-2].minor.yy98;
1004 yygotominor.yy98->append(yymsp[0].minor.yy98);
1005 delete yymsp[0].minor.yy98;
1006 yy_destructor(yypParser,2,&yymsp[-1].minor);
1007 }
1008 #line 1009 "userdict_parser.c"
1009 break;
1010 case 14: /* words ::= words AND word */
1011 case 38: /* token_pron ::= token_pron AND word_pron */ yytestcase(yyruleno==38);
1012 #line 185 "userdict_parser.g"
1013 {
1014 yygotominor.yy98=yymsp[-2].minor.yy98;
1015 yygotominor.yy98->append<RHVoice::userdict::word_break>();
1016 yygotominor.yy98->append(yymsp[0].minor.yy98);
1017 delete yymsp[0].minor.yy98;
1018 yy_destructor(yypParser,5,&yymsp[-1].minor);
1019 }
1020 #line 1021 "userdict_parser.c"
1021 break;
1022 case 16: /* word ::= inline_rewrites word_flags */
1023 case 17: /* inline_rewrites ::= inline_rewrites inline_rewrite */ yytestcase(yyruleno==17);
1024 case 32: /* pattern ::= pattern subpattern */ yytestcase(yyruleno==32);
1025 case 42: /* word_pron ::= pron_repr word_pron_flags */ yytestcase(yyruleno==42);
1026 case 47: /* text_pron_repr ::= text_pron_repr text_pron_repr_atom */ yytestcase(yyruleno==47);
1027 case 58: /* stressed_syl_numbers ::= stressed_syl_numbers stressed_syl_number */ yytestcase(yyruleno==58);
1028 #line 198 "userdict_parser.g"
1029 {
1030 yygotominor.yy98=yymsp[-1].minor.yy98;
1031 yygotominor.yy98->append(yymsp[0].minor.yy98);
1032 delete yymsp[0].minor.yy98;
1033 }
1034 #line 1035 "userdict_parser.c"
1035 break;
1036 case 22: /* inline_replacement ::= LPAREN deletion EQUALS text_pron_repr RPAREN */
1037 #line 232 "userdict_parser.g"
1038 {
1039 yygotominor.yy98=yymsp[-3].minor.yy98;
1040 yygotominor.yy98->append(yymsp[-1].minor.yy98);
1041 delete yymsp[-1].minor.yy98;
1042 yy_destructor(yypParser,6,&yymsp[-4].minor);
1043 yy_destructor(yypParser,2,&yymsp[-2].minor);
1044 yy_destructor(yypParser,7,&yymsp[0].minor);
1045 }
1046 #line 1047 "userdict_parser.c"
1047 break;
1048 case 23: /* word_flags ::= */
1049 #line 239 "userdict_parser.g"
1050 {
1051 yygotominor.yy98=new RHVoice::userdict::ruleset;
1052 }
1053 #line 1054 "userdict_parser.c"
1054 break;
1055 case 27: /* set ::= LBRACE set_elements RBRACE */
1056 #line 259 "userdict_parser.g"
1057 {
1058 yygotominor.yy98=yymsp[-1].minor.yy98;
1059 yy_destructor(yypParser,8,&yymsp[-2].minor);
1060 yy_destructor(yypParser,9,&yymsp[0].minor);
1061 }
1062 #line 1063 "userdict_parser.c"
1063 break;
1064 case 28: /* set_elements ::= set_elements COMMA set_element */
1065 #line 264 "userdict_parser.g"
1066 {
1067 yygotominor.yy98=yymsp[-2].minor.yy98;
1068 yygotominor.yy98->extend(yymsp[0].minor.yy98);
1069 delete yymsp[0].minor.yy98;
1070 yy_destructor(yypParser,10,&yymsp[-1].minor);
1071 }
1072 #line 1073 "userdict_parser.c"
1073 break;
1074 case 31: /* set_element ::= */
1075 #line 281 "userdict_parser.g"
1076 {
1077 yygotominor.yy98=RHVoice::userdict::ruleset::create<RHVoice::userdict::empty_string>();
1078 }
1079 #line 1080 "userdict_parser.c"
1080 break;
1081 case 40: /* spaced_symbol_pron ::= spaced_symbol_pron SPACE word_pron */
1082 case 41: /* spaced_symbol_pron ::= word_pron SPACE word_pron */ yytestcase(yyruleno==41);
1083 #line 331 "userdict_parser.g"
1084 {
1085 yygotominor.yy98=yymsp[-2].minor.yy98;
1086 yygotominor.yy98->append<RHVoice::userdict::word_break>();
1087 yygotominor.yy98->append(yymsp[0].minor.yy98);
1088 delete yymsp[0].minor.yy98;
1089 yy_destructor(yypParser,3,&yymsp[-1].minor);
1090 }
1091 #line 1092 "userdict_parser.c"
1092 break;
1093 case 44: /* word_pron_flags ::= */
1094 #line 359 "userdict_parser.g"
1095 {
1096 yygotominor.yy98= new RHVoice::userdict::ruleset;
1097 }
1098 #line 1099 "userdict_parser.c"
1099 break;
1100 case 51: /* substring ::= NATIVE_LETTERS */
1101 case 52: /* substring ::= ENGLISH_LETTERS */ yytestcase(yyruleno==52);
1102 #line 396 "userdict_parser.g"
1103 {
1104 yygotominor.yy98=RHVoice::userdict::ruleset::create<RHVoice::userdict::substring>(yymsp[0].minor.yy0);
1105 delete yymsp[0].minor.yy0;
1106 }
1107 #line 1108 "userdict_parser.c"
1108 break;
1109 case 53: /* symbol ::= SYM */
1110 #line 408 "userdict_parser.g"
1111 {
1112 yygotominor.yy98=RHVoice::userdict::ruleset::create<RHVoice::userdict::symbol>(yymsp[0].minor.yy0);
1113 delete yymsp[0].minor.yy0;
1114 }
1115 #line 1116 "userdict_parser.c"
1116 break;
1117 case 54: /* deletion ::= NATIVE_LETTERS */
1118 case 55: /* deletion ::= ENGLISH_LETTERS */ yytestcase(yyruleno==55);
1119 #line 414 "userdict_parser.g"
1120 {
1121 yygotominor.yy98=RHVoice::userdict::ruleset::create<RHVoice::userdict::deletion>(yymsp[0].minor.yy0);
1122 delete yymsp[0].minor.yy0;
1123 }
1124 #line 1125 "userdict_parser.c"
1125 break;
1126 case 56: /* insertion ::= NATIVE_LETTERS */
1127 #line 426 "userdict_parser.g"
1128 {
1129 yygotominor.yy98=RHVoice::userdict::ruleset::create<RHVoice::userdict::insertion>(yymsp[0].minor.yy0);
1130 delete yymsp[0].minor.yy0;
1131 }
1132 #line 1133 "userdict_parser.c"
1133 break;
1134 case 57: /* stress_mark ::= PLUS */
1135 #line 432 "userdict_parser.g"
1136 {
1137 yygotominor.yy98=RHVoice::userdict::ruleset::create<RHVoice::userdict::stress_mark>();
1138 yy_destructor(yypParser,14,&yymsp[0].minor);
1139 }
1140 #line 1141 "userdict_parser.c"
1141 break;
1142 case 60: /* stressed_syl_number ::= STRESSED_SYL_NUMBER */
1143 #line 449 "userdict_parser.g"
1144 {
1145 yygotominor.yy98=RHVoice::userdict::ruleset::create<RHVoice::userdict::stressed_syl_number>(yymsp[0].minor.yy0);
1146 delete yymsp[0].minor.yy0;
1147 }
1148 #line 1149 "userdict_parser.c"
1149 break;
1150 case 61: /* unstressed_flag ::= UNSTRESSED */
1151 #line 455 "userdict_parser.g"
1152 {
1153 yygotominor.yy98=RHVoice::userdict::ruleset::create<RHVoice::userdict::unstressed_flag>();
1154 yy_destructor(yypParser,16,&yymsp[0].minor);
1155 }
1156 #line 1157 "userdict_parser.c"
1157 break;
1158 case 62: /* initialism_flag ::= INITIALISM */
1159 #line 460 "userdict_parser.g"
1160 {
1161 yygotominor.yy98=RHVoice::userdict::ruleset::create<RHVoice::userdict::initialism_flag>();
1162 yy_destructor(yypParser,17,&yymsp[0].minor);
1163 }
1164 #line 1165 "userdict_parser.c"
1165 break;
1166 case 64: /* space ::= SPACE */
1167 #line 464 "userdict_parser.g"
1168 {
1169 yy_destructor(yypParser,3,&yymsp[0].minor);
1170 }
1171 #line 1172 "userdict_parser.c"
1172 break;
1173 default:
1174 /* (63) space ::= */ yytestcase(yyruleno==63);
1175 break;
1176 };
1177 yygoto = yyRuleInfo[yyruleno].lhs;
1178 yysize = yyRuleInfo[yyruleno].nrhs;
1179 yypParser->yyidx -= yysize;
1180 yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
1181 if( yyact < YYNSTATE ){
1182 #ifdef NDEBUG
1183 /* If we are not debugging and the reduce action popped at least
1184 ** one element off the stack, then we can push the new element back
1185 ** onto the stack here, and skip the stack overflow test in yy_shift().
1186 ** That gives a significant speed improvement. */
1187 if( yysize ){
1188 yypParser->yyidx++;
1189 yymsp -= yysize-1;
1190 yymsp->stateno = (YYACTIONTYPE)yyact;
1191 yymsp->major = (YYCODETYPE)yygoto;
1192 yymsp->minor = yygotominor;
1193 }else
1194 #endif
1195 {
1196 yy_shift(yypParser,yyact,yygoto,&yygotominor);
1197 }
1198 }else{
1199 assert( yyact == YYNSTATE + YYNRULE + 1 );
1200 yy_accept(yypParser);
1201 }
1202 }
1203
1204 /*
1205 ** The following code executes when the parse fails
1206 */
1207 #ifndef YYNOERRORRECOVERY
yy_parse_failed(yyParser * yypParser)1208 static void yy_parse_failed(
1209 yyParser *yypParser /* The parser */
1210 ){
1211 userdictParseARG_FETCH;
1212 #ifndef NDEBUG
1213 if( yyTraceFILE ){
1214 fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
1215 }
1216 #endif
1217 while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
1218 /* Here code is inserted which will be executed whenever the
1219 ** parser fails */
1220 userdictParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
1221 }
1222 #endif /* YYNOERRORRECOVERY */
1223
1224 /*
1225 ** The following code executes when a syntax error first occurs.
1226 */
yy_syntax_error(yyParser * yypParser,int yymajor,YYMINORTYPE yyminor)1227 static void yy_syntax_error(
1228 yyParser *yypParser, /* The parser */
1229 int yymajor, /* The major type of the error token */
1230 YYMINORTYPE yyminor /* The minor type of the error token */
1231 ){
1232 userdictParseARG_FETCH;
1233 #define TOKEN (yyminor.yy0)
1234 #line 99 "userdict_parser.g"
1235 ps->error=true;
1236 #line 1237 "userdict_parser.c"
1237 userdictParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
1238 }
1239
1240 /*
1241 ** The following is executed when the parser accepts
1242 */
yy_accept(yyParser * yypParser)1243 static void yy_accept(
1244 yyParser *yypParser /* The parser */
1245 ){
1246 userdictParseARG_FETCH;
1247 #ifndef NDEBUG
1248 if( yyTraceFILE ){
1249 fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
1250 }
1251 #endif
1252 while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
1253 /* Here code is inserted which will be executed whenever the
1254 ** parser accepts */
1255 userdictParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
1256 }
1257
1258 /* The main parser program.
1259 ** The first argument is a pointer to a structure obtained from
1260 ** "userdictParseAlloc" which describes the current state of the parser.
1261 ** The second argument is the major token number. The third is
1262 ** the minor token. The fourth optional argument is whatever the
1263 ** user wants (and specified in the grammar) and is available for
1264 ** use by the action routines.
1265 **
1266 ** Inputs:
1267 ** <ul>
1268 ** <li> A pointer to the parser (an opaque structure.)
1269 ** <li> The major token number.
1270 ** <li> The minor token number.
1271 ** <li> An option argument of a grammar-specified type.
1272 ** </ul>
1273 **
1274 ** Outputs:
1275 ** None.
1276 */
userdictParse(void * yyp,int yymajor,userdictParseTOKENTYPE yyminor userdictParseARG_PDECL)1277 void userdictParse(
1278 void *yyp, /* The parser */
1279 int yymajor, /* The major token code number */
1280 userdictParseTOKENTYPE yyminor /* The value for the token */
1281 userdictParseARG_PDECL /* Optional %extra_argument parameter */
1282 ){
1283 YYMINORTYPE yyminorunion;
1284 int yyact; /* The parser action. */
1285 int yyendofinput; /* True if we are at the end of input */
1286 #ifdef YYERRORSYMBOL
1287 int yyerrorhit = 0; /* True if yymajor has invoked an error */
1288 #endif
1289 yyParser *yypParser; /* The parser */
1290
1291 /* (re)initialize the parser, if necessary */
1292 yypParser = (yyParser*)yyp;
1293 if( yypParser->yyidx<0 ){
1294 #if YYSTACKDEPTH<=0
1295 if( yypParser->yystksz <=0 ){
1296 /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/
1297 yyminorunion = yyzerominor;
1298 yyStackOverflow(yypParser, &yyminorunion);
1299 return;
1300 }
1301 #endif
1302 yypParser->yyidx = 0;
1303 yypParser->yyerrcnt = -1;
1304 yypParser->yystack[0].stateno = 0;
1305 yypParser->yystack[0].major = 0;
1306 }
1307 yyminorunion.yy0 = yyminor;
1308 yyendofinput = (yymajor==0);
1309 userdictParseARG_STORE;
1310
1311 #ifndef NDEBUG
1312 if( yyTraceFILE ){
1313 fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]);
1314 }
1315 #endif
1316
1317 do{
1318 yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
1319 if( yyact<YYNSTATE ){
1320 assert( !yyendofinput ); /* Impossible to shift the $ token */
1321 yy_shift(yypParser,yyact,yymajor,&yyminorunion);
1322 yypParser->yyerrcnt--;
1323 yymajor = YYNOCODE;
1324 }else if( yyact < YYNSTATE + YYNRULE ){
1325 yy_reduce(yypParser,yyact-YYNSTATE);
1326 }else{
1327 assert( yyact == YY_ERROR_ACTION );
1328 #ifdef YYERRORSYMBOL
1329 int yymx;
1330 #endif
1331 #ifndef NDEBUG
1332 if( yyTraceFILE ){
1333 fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
1334 }
1335 #endif
1336 #ifdef YYERRORSYMBOL
1337 /* A syntax error has occurred.
1338 ** The response to an error depends upon whether or not the
1339 ** grammar defines an error token "ERROR".
1340 **
1341 ** This is what we do if the grammar does define ERROR:
1342 **
1343 ** * Call the %syntax_error function.
1344 **
1345 ** * Begin popping the stack until we enter a state where
1346 ** it is legal to shift the error symbol, then shift
1347 ** the error symbol.
1348 **
1349 ** * Set the error count to three.
1350 **
1351 ** * Begin accepting and shifting new tokens. No new error
1352 ** processing will occur until three tokens have been
1353 ** shifted successfully.
1354 **
1355 */
1356 if( yypParser->yyerrcnt<0 ){
1357 yy_syntax_error(yypParser,yymajor,yyminorunion);
1358 }
1359 yymx = yypParser->yystack[yypParser->yyidx].major;
1360 if( yymx==YYERRORSYMBOL || yyerrorhit ){
1361 #ifndef NDEBUG
1362 if( yyTraceFILE ){
1363 fprintf(yyTraceFILE,"%sDiscard input token %s\n",
1364 yyTracePrompt,yyTokenName[yymajor]);
1365 }
1366 #endif
1367 yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion);
1368 yymajor = YYNOCODE;
1369 }else{
1370 while(
1371 yypParser->yyidx >= 0 &&
1372 yymx != YYERRORSYMBOL &&
1373 (yyact = yy_find_reduce_action(
1374 yypParser->yystack[yypParser->yyidx].stateno,
1375 YYERRORSYMBOL)) >= YYNSTATE
1376 ){
1377 yy_pop_parser_stack(yypParser);
1378 }
1379 if( yypParser->yyidx < 0 || yymajor==0 ){
1380 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
1381 yy_parse_failed(yypParser);
1382 yymajor = YYNOCODE;
1383 }else if( yymx!=YYERRORSYMBOL ){
1384 YYMINORTYPE u2;
1385 u2.YYERRSYMDT = 0;
1386 yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2);
1387 }
1388 }
1389 yypParser->yyerrcnt = 3;
1390 yyerrorhit = 1;
1391 #elif defined(YYNOERRORRECOVERY)
1392 /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
1393 ** do any kind of error recovery. Instead, simply invoke the syntax
1394 ** error routine and continue going as if nothing had happened.
1395 **
1396 ** Applications can set this macro (for example inside %include) if
1397 ** they intend to abandon the parse upon the first syntax error seen.
1398 */
1399 yy_syntax_error(yypParser,yymajor,yyminorunion);
1400 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
1401 yymajor = YYNOCODE;
1402
1403 #else /* YYERRORSYMBOL is not defined */
1404 /* This is what we do if the grammar does not define ERROR:
1405 **
1406 ** * Report an error message, and throw away the input token.
1407 **
1408 ** * If the input token is $, then fail the parse.
1409 **
1410 ** As before, subsequent error messages are suppressed until
1411 ** three input tokens have been successfully shifted.
1412 */
1413 if( yypParser->yyerrcnt<=0 ){
1414 yy_syntax_error(yypParser,yymajor,yyminorunion);
1415 }
1416 yypParser->yyerrcnt = 3;
1417 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
1418 if( yyendofinput ){
1419 yy_parse_failed(yypParser);
1420 }
1421 yymajor = YYNOCODE;
1422 #endif
1423 }
1424 }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );
1425 return;
1426 }
1427