Coverage Report

Created: 2025-02-15 06:25

/work/build/epan/dtd_grammar.c
Line
Count
Source (jump to first uncovered line)
1
/* This file is automatically generated by Lemon from input grammar
2
** source file "/src/wireshark/epan/dtd_grammar.lemon". */
3
/* dtd_parser.lemon
4
 * XML dissector for wireshark
5
 * XML's DTD grammar
6
 *
7
 * Copyright 2005, Luis E. Garcia Ontanon <luis@ontanon.org>
8
 *
9
 * Wireshark - Network traffic analyzer
10
 * By Gerald Combs <gerald@wireshark.org>
11
 * Copyright 1998 Gerald Combs
12
 *
13
 * SPDX-License-Identifier: GPL-2.0-or-later
14
 */
15
16
#include "config.h"
17
18
#include <stdio.h>
19
#include <glib.h>
20
#include <assert.h>
21
#include <ws_diag_control.h>
22
#include "dtd.h"
23
#include "dtd_parse.h"
24
25
0
static dtd_named_list_t* dtd_named_list_new(char* name, GPtrArray* list) {
26
0
  dtd_named_list_t* nl = g_new(dtd_named_list_t,1);
27
28
0
  nl->name = name;
29
0
  nl->list = list;
30
31
0
  return nl;
32
0
}
33
34
0
static GPtrArray* g_ptr_array_join(GPtrArray* a, GPtrArray* b){
35
36
0
  while(b->len > 0) {
37
0
    g_ptr_array_add(a,g_ptr_array_remove_index_fast(b,0));
38
0
  }
39
40
0
  g_ptr_array_free(b,true);
41
42
0
  return a;
43
0
}
44
45
DIAG_OFF_LEMON()
46
#line 72 "./dtd_grammar.c"
47
/**************** End of %include directives **********************************/
48
/* These constants specify the various numeric values for terminal symbols.
49
***************** Begin token definitions *************************************/
50
#ifndef TOKEN_TAG_START
51
#define TOKEN_TAG_START                       1
52
#define TOKEN_DOCTYPE_KW                      2
53
#define TOKEN_NAME                            3
54
#define TOKEN_OPEN_BRACKET                    4
55
#define TOKEN_CLOSE_BRACKET                   5
56
#define TOKEN_TAG_STOP                        6
57
#define TOKEN_ATTLIST_KW                      7
58
#define TOKEN_ELEMENT_KW                      8
59
#define TOKEN_ATT_TYPE                        9
60
#define TOKEN_ATT_DEF                        10
61
#define TOKEN_ATT_DEF_WITH_VALUE             11
62
#define TOKEN_QUOTED                         12
63
#define TOKEN_IMPLIED_KW                     13
64
#define TOKEN_REQUIRED_KW                    14
65
#define TOKEN_OPEN_PARENS                    15
66
#define TOKEN_CLOSE_PARENS                   16
67
#define TOKEN_PIPE                           17
68
#define TOKEN_STAR                           18
69
#define TOKEN_PLUS                           19
70
#define TOKEN_QUESTION                       20
71
#define TOKEN_ELEM_DATA                      21
72
#define TOKEN_COMMA                          22
73
#define TOKEN_EMPTY_KW                       23
74
#endif
75
/**************** End token definitions ***************************************/
76
77
/* The next sections is a series of control #defines.
78
** various aspects of the generated parser.
79
**    YYCODETYPE         is the data type used to store the integer codes
80
**                       that represent terminal and non-terminal symbols.
81
**                       "unsigned char" is used if there are fewer than
82
**                       256 symbols.  Larger types otherwise.
83
**    YYNOCODE           is a number of type YYCODETYPE that is not used for
84
**                       any terminal or nonterminal symbol.
85
**    YYFALLBACK         If defined, this indicates that one or more tokens
86
**                       (also known as: "terminal symbols") have fall-back
87
**                       values which should be used if the original symbol
88
**                       would not parse.  This permits keywords to sometimes
89
**                       be used as identifiers, for example.
90
**    YYACTIONTYPE       is the data type used for "action codes" - numbers
91
**                       that indicate what to do in response to the next
92
**                       token.
93
**    DtdParseTOKENTYPE     is the data type used for minor type for terminal
94
**                       symbols.  Background: A "minor type" is a semantic
95
**                       value associated with a terminal or non-terminal
96
**                       symbols.  For example, for an "ID" terminal symbol,
97
**                       the minor type might be the name of the identifier.
98
**                       Each non-terminal can have a different minor type.
99
**                       Terminal symbols all have the same minor type, though.
100
**                       This macros defines the minor type for terminal
101
**                       symbols.
102
**    YYMINORTYPE        is the data type used for all minor types.
103
**                       This is typically a union of many types, one of
104
**                       which is DtdParseTOKENTYPE.  The entry in the union
105
**                       for terminal symbols is called "yy0".
106
**    YYSTACKDEPTH       is the maximum depth of the parser's stack.  If
107
**                       zero the stack is dynamically sized using realloc()
108
**    DtdParseARG_SDECL     A static variable declaration for the %extra_argument
109
**    DtdParseARG_PDECL     A parameter declaration for the %extra_argument
110
**    DtdParseARG_PARAM     Code to pass %extra_argument as a subroutine parameter
111
**    DtdParseARG_STORE     Code to store %extra_argument into yypParser
112
**    DtdParseARG_FETCH     Code to extract %extra_argument from yypParser
113
**    DtdParseCTX_*         As DtdParseARG_ except for %extra_context
114
**    YYERRORSYMBOL      is the code number of the error symbol.  If not
115
**                       defined, then do no error processing.
116
**    YYNSTATE           the combined number of states.
117
**    YYNRULE            the number of rules in the grammar
118
**    YYNTOKEN           Number of terminal symbols
119
**    YY_MAX_SHIFT       Maximum value for shift actions
120
**    YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions
121
**    YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions
122
**    YY_ERROR_ACTION    The yy_action[] code for syntax error
123
**    YY_ACCEPT_ACTION   The yy_action[] code for accept
124
**    YY_NO_ACTION       The yy_action[] code for no-op
125
**    YY_MIN_REDUCE      Minimum value for reduce actions
126
**    YY_MAX_REDUCE      Maximum value for reduce actions
127
*/
128
#ifndef INTERFACE
129
# define INTERFACE 1
130
#endif
131
/************* Begin control #defines *****************************************/
132
#define YYCODETYPE unsigned char
133
#define YYNOCODE 39
134
0
#define YYACTIONTYPE unsigned char
135
#define DtdParseTOKENTYPE  dtd_token_data_t* 
136
typedef union {
137
  int yyinit;
138
  DtdParseTOKENTYPE yy0;
139
  GPtrArray* yy9;
140
  char* yy15;
141
  dtd_named_list_t* yy41;
142
} YYMINORTYPE;
143
#ifndef YYSTACKDEPTH
144
0
#define YYSTACKDEPTH 100
145
#endif
146
#define DtdParseARG_SDECL  dtd_build_data_t *bd ;
147
#define DtdParseARG_PDECL , dtd_build_data_t *bd 
148
#define DtdParseARG_PARAM ,bd 
149
0
#define DtdParseARG_FETCH  dtd_build_data_t *bd =yypParser->bd ;
150
0
#define DtdParseARG_STORE yypParser->bd =bd ;
151
#define DtdParseCTX_SDECL
152
#define DtdParseCTX_PDECL
153
#define DtdParseCTX_PARAM
154
#define DtdParseCTX_FETCH
155
#define DtdParseCTX_STORE
156
#define YYNSTATE             33
157
#define YYNRULE              44
158
#define YYNRULE_WITH_ACTION  28
159
#define YYNTOKEN             24
160
0
#define YY_MAX_SHIFT         32
161
0
#define YY_MIN_SHIFTREDUCE   71
162
0
#define YY_MAX_SHIFTREDUCE   114
163
#define YY_ERROR_ACTION      115
164
0
#define YY_ACCEPT_ACTION     116
165
#define YY_NO_ACTION         117
166
0
#define YY_MIN_REDUCE        118
167
#define YY_MAX_REDUCE        161
168
/************* End control #defines *******************************************/
169
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
170
171
/* Define the yytestcase() macro to be a no-op if is not already defined
172
** otherwise.
173
**
174
** Applications can choose to define yytestcase() in the %include section
175
** to a macro that can assist in verifying code coverage.  For production
176
** code the yytestcase() macro should be turned off.  But it is useful
177
** for testing.
178
*/
179
#ifndef yytestcase
180
# define yytestcase(X)
181
#endif
182
183
184
/* Next are the tables used to determine what action to take based on the
185
** current state and lookahead token.  These tables are used to implement
186
** functions that take a state number and lookahead value and return an
187
** action integer.
188
**
189
** Suppose the action integer is N.  Then the action is determined as
190
** follows
191
**
192
**   0 <= N <= YY_MAX_SHIFT             Shift N.  That is, push the lookahead
193
**                                      token onto the stack and goto state N.
194
**
195
**   N between YY_MIN_SHIFTREDUCE       Shift to an arbitrary state then
196
**     and YY_MAX_SHIFTREDUCE           reduce by rule N-YY_MIN_SHIFTREDUCE.
197
**
198
**   N == YY_ERROR_ACTION               A syntax error has occurred.
199
**
200
**   N == YY_ACCEPT_ACTION              The parser accepts its input.
201
**
202
**   N == YY_NO_ACTION                  No such action.  Denotes unused
203
**                                      slots in the yy_action[] table.
204
**
205
**   N between YY_MIN_REDUCE            Reduce by rule N-YY_MIN_REDUCE
206
**     and YY_MAX_REDUCE
207
**
208
** The action table is constructed as a single large table named yy_action[].
209
** Given state S and lookahead X, the action is computed as either:
210
**
211
**    (A)   N = yy_action[ yy_shift_ofst[S] + X ]
212
**    (B)   N = yy_default[S]
213
**
214
** The (A) formula is preferred.  The B formula is used instead if
215
** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X.
216
**
217
** The formulas above are for computing the action when the lookahead is
218
** a terminal symbol.  If the lookahead is a non-terminal (as occurs after
219
** a reduce action) then the yy_reduce_ofst[] array is used in place of
220
** the yy_shift_ofst[] array.
221
**
222
** The following are the tables generated in this section:
223
**
224
**  yy_action[]        A single table containing all actions.
225
**  yy_lookahead[]     A table containing the lookahead for each entry in
226
**                     yy_action.  Used to detect hash collisions.
227
**  yy_shift_ofst[]    For each state, the offset into yy_action for
228
**                     shifting terminals.
229
**  yy_reduce_ofst[]   For each state, the offset into yy_action for
230
**                     shifting non-terminals after a reduce.
231
**  yy_default[]       Default action for each state.
232
**
233
*********** Begin parsing tables **********************************************/
234
#define YY_ACTTAB_COUNT (92)
235
static const YYACTIONTYPE yy_action[] = {
236
 /*     0 */   116,   32,    9,  121,  122,   17,   17,    8,   20,   17,
237
 /*    10 */   103,   30,  105,  106,  107,   19,  138,    1,    1,   77,
238
 /*    20 */   159,    1,  156,   28,   26,   88,   88,   27,  113,   88,
239
 /*    30 */    25,   81,   82,   83,   22,   31,   29,  114,   23,   15,
240
 /*    40 */     2,   21,   21,   21,    7,  121,  122,   81,   82,   83,
241
 /*    50 */    96,   98,   97,   87,    4,    8,   16,   18,   76,    5,
242
 /*    60 */   101,  119,  120,   22,  137,  136,    2,   11,    1,   11,
243
 /*    70 */   147,   22,   13,  127,  126,   14,   88,  108,    6,   31,
244
 /*    80 */    29,  125,   71,    3,   24,   86,   12,   85,   10,   84,
245
 /*    90 */   104,  146,
246
};
247
static const YYCODETYPE yy_lookahead[] = {
248
 /*     0 */    24,   25,   26,   27,   28,    3,    3,    3,   30,    3,
249
 /*    10 */    10,   11,   12,   13,   14,   37,   38,   15,   15,    6,
250
 /*    20 */    34,   15,   36,   21,   21,   23,   23,   21,    3,   23,
251
 /*    30 */     2,   18,   19,   20,    1,    7,    8,   12,    5,    1,
252
 /*    40 */    15,   34,   35,   36,   26,   27,   28,   18,   19,   20,
253
 /*    50 */    18,   19,   20,   16,   17,    3,   30,   30,    6,   22,
254
 /*    60 */     9,   27,   28,    1,   38,   38,   15,   32,   15,   34,
255
 /*    70 */     0,    1,   29,   33,   31,   30,   23,   16,   17,    7,
256
 /*    80 */     8,   31,    6,    4,    3,   16,    3,   16,    3,   16,
257
 /*    90 */    12,    0,   39,   39,   39,   39,   39,   39,   39,   39,
258
 /*   100 */    39,   39,   39,   39,   39,   39,   39,   39,   39,   39,
259
 /*   110 */    39,   39,   39,   39,   39,   39,
260
};
261
#define YY_SHIFT_COUNT    (32)
262
#define YY_SHIFT_MIN      (0)
263
#define YY_SHIFT_MAX      (91)
264
static const unsigned char yy_shift_ofst[] = {
265
 /*     0 */    38,    2,   25,   62,    3,    6,   25,   33,   51,   70,
266
 /*    10 */     4,    0,   53,   52,   13,   28,   29,   32,   29,   37,
267
 /*    20 */    29,   61,   72,   76,   79,   81,   69,   71,   73,   83,
268
 /*    30 */    78,   85,   91,
269
};
270
#define YY_REDUCE_COUNT (13)
271
#define YY_REDUCE_MIN   (-24)
272
#define YY_REDUCE_MAX   (50)
273
static const signed char yy_reduce_ofst[] = {
274
 /*     0 */   -24,  -22,    7,   18,   26,   27,  -14,   34,   35,   34,
275
 /*    10 */    43,   40,   45,   50,
276
};
277
static const YYACTIONTYPE yy_default[] = {
278
 /*     0 */   115,  115,  115,  115,  115,  115,  115,  115,  115,  115,
279
 /*    10 */   115,  115,  115,  115,  115,  115,  141,  142,  140,  115,
280
 /*    20 */   139,  115,  115,  115,  115,  115,  115,  115,  115,  115,
281
 /*    30 */   115,  115,  115,
282
};
283
/********** End of lemon-generated parsing tables *****************************/
284
285
/* The next table maps tokens (terminal symbols) into fallback tokens.
286
** If a construct like the following:
287
**
288
**      %fallback ID X Y Z.
289
**
290
** appears in the grammar, then ID becomes a fallback token for X, Y,
291
** and Z.  Whenever one of the tokens X, Y, or Z is input to the parser
292
** but it does not parse, the type of the token is changed to ID and
293
** the parse is retried before an error is thrown.
294
**
295
** This feature can be used, for example, to cause some keywords in a language
296
** to revert to identifiers if they keyword does not apply in the context where
297
** it appears.
298
*/
299
#ifdef YYFALLBACK
300
static const YYCODETYPE yyFallback[] = {
301
};
302
#endif /* YYFALLBACK */
303
304
/* The following structure represents a single element of the
305
** parser's stack.  Information stored includes:
306
**
307
**   +  The state number for the parser at this level of the stack.
308
**
309
**   +  The value of the token stored at this level of the stack.
310
**      (In other words, the "major" token.)
311
**
312
**   +  The semantic value stored at this level of the stack.  This is
313
**      the information used by the action routines in the grammar.
314
**      It is sometimes called the "minor" token.
315
**
316
** After the "shift" half of a SHIFTREDUCE action, the stateno field
317
** actually contains the reduce action for the second half of the
318
** SHIFTREDUCE.
319
*/
320
struct yyStackEntry {
321
  YYACTIONTYPE stateno;  /* The state-number, or reduce action in SHIFTREDUCE */
322
  YYCODETYPE major;      /* The major token value.  This is the code
323
                         ** number for the token at this stack level */
324
  YYMINORTYPE minor;     /* The user-supplied minor token value.  This
325
                         ** is the value of the token  */
326
};
327
typedef struct yyStackEntry yyStackEntry;
328
329
/* The state of the parser is completely contained in an instance of
330
** the following structure */
331
struct yyParser {
332
  yyStackEntry *yytos;          /* Pointer to top element of the stack */
333
#ifdef YYTRACKMAXSTACKDEPTH
334
  int yyhwm;                    /* High-water mark of the stack */
335
#endif
336
#ifndef YYNOERRORRECOVERY
337
  int yyerrcnt;                 /* Shifts left before out of the error */
338
#endif
339
  DtdParseARG_SDECL                /* A place to hold %extra_argument */
340
  DtdParseCTX_SDECL                /* A place to hold %extra_context */
341
#if YYSTACKDEPTH<=0
342
  int yystksz;                  /* Current side of the stack */
343
  yyStackEntry *yystack;        /* The parser's stack */
344
  yyStackEntry yystk0;          /* First stack entry */
345
#else
346
  yyStackEntry yystack[YYSTACKDEPTH];  /* The parser's stack */
347
  yyStackEntry *yystackEnd;            /* Last entry in the stack */
348
#endif
349
};
350
typedef struct yyParser yyParser;
351
352
#include <assert.h>
353
#ifndef NDEBUG
354
#include <stdio.h>
355
static FILE *yyTraceFILE = 0;
356
static char *yyTracePrompt = 0;
357
#endif /* NDEBUG */
358
359
#ifndef NDEBUG
360
/*
361
** Turn parser tracing on by giving a stream to which to write the trace
362
** and a prompt to preface each trace message.  Tracing is turned off
363
** by making either argument NULL
364
**
365
** Inputs:
366
** <ul>
367
** <li> A FILE* to which trace output should be written.
368
**      If NULL, then tracing is turned off.
369
** <li> A prefix string written at the beginning of every
370
**      line of trace output.  If NULL, then tracing is
371
**      turned off.
372
** </ul>
373
**
374
** Outputs:
375
** None.
376
*/
377
void DtdParseTrace(FILE *TraceFILE, char *zTracePrompt){
378
  yyTraceFILE = TraceFILE;
379
  yyTracePrompt = zTracePrompt;
380
  if( yyTraceFILE==0 ) yyTracePrompt = 0;
381
  else if( yyTracePrompt==0 ) yyTraceFILE = 0;
382
}
383
#endif /* NDEBUG */
384
385
#if defined(YYCOVERAGE) || !defined(NDEBUG)
386
/* For tracing shifts, the names of all terminals and nonterminals
387
** are required.  The following table supplies these names */
388
static const char *const yyTokenName[] = {
389
  /*    0 */ "$",
390
  /*    1 */ "TAG_START",
391
  /*    2 */ "DOCTYPE_KW",
392
  /*    3 */ "NAME",
393
  /*    4 */ "OPEN_BRACKET",
394
  /*    5 */ "CLOSE_BRACKET",
395
  /*    6 */ "TAG_STOP",
396
  /*    7 */ "ATTLIST_KW",
397
  /*    8 */ "ELEMENT_KW",
398
  /*    9 */ "ATT_TYPE",
399
  /*   10 */ "ATT_DEF",
400
  /*   11 */ "ATT_DEF_WITH_VALUE",
401
  /*   12 */ "QUOTED",
402
  /*   13 */ "IMPLIED_KW",
403
  /*   14 */ "REQUIRED_KW",
404
  /*   15 */ "OPEN_PARENS",
405
  /*   16 */ "CLOSE_PARENS",
406
  /*   17 */ "PIPE",
407
  /*   18 */ "STAR",
408
  /*   19 */ "PLUS",
409
  /*   20 */ "QUESTION",
410
  /*   21 */ "ELEM_DATA",
411
  /*   22 */ "COMMA",
412
  /*   23 */ "EMPTY_KW",
413
  /*   24 */ "dtd",
414
  /*   25 */ "doctype",
415
  /*   26 */ "dtd_parts",
416
  /*   27 */ "element",
417
  /*   28 */ "attlist",
418
  /*   29 */ "attrib_list",
419
  /*   30 */ "sub_elements",
420
  /*   31 */ "attrib",
421
  /*   32 */ "att_type",
422
  /*   33 */ "att_default",
423
  /*   34 */ "enumeration",
424
  /*   35 */ "enum_list",
425
  /*   36 */ "enum_item",
426
  /*   37 */ "element_list",
427
  /*   38 */ "element_child",
428
};
429
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
430
431
#ifndef NDEBUG
432
/* For tracing reduce actions, the names of all rules are required.
433
*/
434
static const char *const yyRuleName[] = {
435
 /*   0 */ "doctype ::= TAG_START DOCTYPE_KW NAME OPEN_BRACKET dtd_parts CLOSE_BRACKET TAG_STOP",
436
 /*   1 */ "dtd_parts ::= dtd_parts element",
437
 /*   2 */ "dtd_parts ::= dtd_parts attlist",
438
 /*   3 */ "dtd_parts ::= element",
439
 /*   4 */ "dtd_parts ::= attlist",
440
 /*   5 */ "attlist ::= TAG_START ATTLIST_KW NAME attrib_list TAG_STOP",
441
 /*   6 */ "element ::= TAG_START ELEMENT_KW NAME sub_elements TAG_STOP",
442
 /*   7 */ "attrib_list ::= attrib_list attrib",
443
 /*   8 */ "attrib_list ::= attrib",
444
 /*   9 */ "attrib ::= NAME att_type att_default",
445
 /*  10 */ "sub_elements ::= sub_elements STAR",
446
 /*  11 */ "sub_elements ::= sub_elements PLUS",
447
 /*  12 */ "sub_elements ::= sub_elements QUESTION",
448
 /*  13 */ "sub_elements ::= OPEN_PARENS ELEM_DATA CLOSE_PARENS",
449
 /*  14 */ "sub_elements ::= OPEN_PARENS element_list COMMA ELEM_DATA CLOSE_PARENS",
450
 /*  15 */ "sub_elements ::= OPEN_PARENS element_list PIPE ELEM_DATA CLOSE_PARENS",
451
 /*  16 */ "sub_elements ::= OPEN_PARENS element_list CLOSE_PARENS",
452
 /*  17 */ "sub_elements ::= EMPTY_KW",
453
 /*  18 */ "element_list ::= element_list COMMA element_child",
454
 /*  19 */ "element_list ::= element_list PIPE element_child",
455
 /*  20 */ "element_list ::= element_child",
456
 /*  21 */ "element_list ::= sub_elements",
457
 /*  22 */ "element_list ::= element_list COMMA sub_elements",
458
 /*  23 */ "element_list ::= element_list PIPE sub_elements",
459
 /*  24 */ "element_child ::= NAME",
460
 /*  25 */ "element_child ::= NAME STAR",
461
 /*  26 */ "element_child ::= NAME QUESTION",
462
 /*  27 */ "element_child ::= NAME PLUS",
463
 /*  28 */ "dtd ::= doctype",
464
 /*  29 */ "dtd ::= dtd_parts",
465
 /*  30 */ "att_type ::= ATT_TYPE",
466
 /*  31 */ "att_type ::= enumeration",
467
 /*  32 */ "att_default ::= ATT_DEF",
468
 /*  33 */ "att_default ::= ATT_DEF_WITH_VALUE QUOTED",
469
 /*  34 */ "att_default ::= QUOTED",
470
 /*  35 */ "att_default ::= IMPLIED_KW",
471
 /*  36 */ "att_default ::= REQUIRED_KW",
472
 /*  37 */ "enumeration ::= OPEN_PARENS enum_list CLOSE_PARENS",
473
 /*  38 */ "enum_list ::= enum_list PIPE enum_item",
474
 /*  39 */ "enum_list ::= enum_item",
475
 /*  40 */ "enum_list ::= enumeration",
476
 /*  41 */ "enum_list ::= enum_list PIPE enumeration",
477
 /*  42 */ "enum_item ::= NAME",
478
 /*  43 */ "enum_item ::= QUOTED",
479
};
480
#endif /* NDEBUG */
481
482
483
#if YYSTACKDEPTH<=0
484
/*
485
** Try to increase the size of the parser stack.  Return the number
486
** of errors.  Return 0 on success.
487
*/
488
static int yyGrowStack(yyParser *p){
489
  int newSize;
490
  int idx;
491
  yyStackEntry *pNew;
492
493
  newSize = p->yystksz*2 + 100;
494
  idx = p->yytos ? (int)(p->yytos - p->yystack) : 0;
495
  if( p->yystack==&p->yystk0 ){
496
    pNew = malloc(newSize*sizeof(pNew[0]));
497
    if( pNew ) pNew[0] = p->yystk0;
498
  }else{
499
    pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
500
  }
501
  if( pNew ){
502
    p->yystack = pNew;
503
    p->yytos = &p->yystack[idx];
504
#ifndef NDEBUG
505
    if( yyTraceFILE ){
506
      fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n",
507
              yyTracePrompt, p->yystksz, newSize);
508
    }
509
#endif
510
    p->yystksz = newSize;
511
  }
512
  return pNew==0;
513
}
514
#endif
515
516
/* Datatype of the argument to the memory allocated passed as the
517
** second argument to DtdParseAlloc() below.  This can be changed by
518
** putting an appropriate #define in the %include section of the input
519
** grammar.
520
*/
521
#ifndef YYMALLOCARGTYPE
522
# define YYMALLOCARGTYPE size_t
523
#endif
524
525
/* Initialize a new parser that has already been allocated.
526
*/
527
0
void DtdParseInit(void *yypRawParser DtdParseCTX_PDECL){
528
0
  yyParser *yypParser = (yyParser*)yypRawParser;
529
0
  DtdParseCTX_STORE
530
#ifdef YYTRACKMAXSTACKDEPTH
531
  yypParser->yyhwm = 0;
532
#endif
533
#if YYSTACKDEPTH<=0
534
  yypParser->yytos = NULL;
535
  yypParser->yystack = NULL;
536
  yypParser->yystksz = 0;
537
  if( yyGrowStack(yypParser) ){
538
    yypParser->yystack = &yypParser->yystk0;
539
    yypParser->yystksz = 1;
540
  }
541
#endif
542
0
#ifndef YYNOERRORRECOVERY
543
0
  yypParser->yyerrcnt = -1;
544
0
#endif
545
0
  yypParser->yytos = yypParser->yystack;
546
0
  yypParser->yystack[0].stateno = 0;
547
0
  yypParser->yystack[0].major = 0;
548
0
#if YYSTACKDEPTH>0
549
0
  yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1];
550
0
#endif
551
0
}
552
553
#ifndef DtdParse_ENGINEALWAYSONSTACK
554
/*
555
** This function allocates a new parser.
556
** The only argument is a pointer to a function which works like
557
** malloc.
558
**
559
** Inputs:
560
** A pointer to the function used to allocate memory.
561
**
562
** Outputs:
563
** A pointer to a parser.  This pointer is used in subsequent calls
564
** to DtdParse and DtdParseFree.
565
*/
566
0
void *DtdParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) DtdParseCTX_PDECL){
567
0
  yyParser *yypParser;
568
0
  yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
569
0
  if( yypParser ){
570
0
    DtdParseCTX_STORE
571
0
    DtdParseInit(yypParser DtdParseCTX_PARAM);
572
0
  }
573
0
  return (void*)yypParser;
574
0
}
575
#endif /* DtdParse_ENGINEALWAYSONSTACK */
576
577
578
/* The following function deletes the "minor type" or semantic value
579
** associated with a symbol.  The symbol can be either a terminal
580
** or nonterminal. "yymajor" is the symbol code, and "yypminor" is
581
** a pointer to the value to be deleted.  The code used to do the
582
** deletions is derived from the %destructor and/or %token_destructor
583
** directives of the input grammar.
584
*/
585
static void yy_destructor(
586
  yyParser *yypParser,    /* The parser */
587
  YYCODETYPE yymajor,     /* Type code for object to destroy */
588
  YYMINORTYPE *yypminor   /* The object to be destroyed */
589
0
){
590
0
  DtdParseARG_FETCH
591
0
  DtdParseCTX_FETCH
592
0
  switch( yymajor ){
593
    /* Here is inserted the actions which take place when a
594
    ** terminal or non-terminal is destroyed.  This can happen
595
    ** when the symbol is popped from the stack during a
596
    ** reduce or during error processing or when a parser is
597
    ** being destroyed before it is finished parsing.
598
    **
599
    ** Note: during a reduce, the only symbols destroyed are those
600
    ** which appear on the RHS of the rule, but which are *not* used
601
    ** inside the C code.
602
    */
603
/********* Begin destructor definitions ***************************************/
604
      /* TERMINAL Destructor */
605
0
    case 1: /* TAG_START */
606
0
    case 2: /* DOCTYPE_KW */
607
0
    case 3: /* NAME */
608
0
    case 4: /* OPEN_BRACKET */
609
0
    case 5: /* CLOSE_BRACKET */
610
0
    case 6: /* TAG_STOP */
611
0
    case 7: /* ATTLIST_KW */
612
0
    case 8: /* ELEMENT_KW */
613
0
    case 9: /* ATT_TYPE */
614
0
    case 10: /* ATT_DEF */
615
0
    case 11: /* ATT_DEF_WITH_VALUE */
616
0
    case 12: /* QUOTED */
617
0
    case 13: /* IMPLIED_KW */
618
0
    case 14: /* REQUIRED_KW */
619
0
    case 15: /* OPEN_PARENS */
620
0
    case 16: /* CLOSE_PARENS */
621
0
    case 17: /* PIPE */
622
0
    case 18: /* STAR */
623
0
    case 19: /* PLUS */
624
0
    case 20: /* QUESTION */
625
0
    case 21: /* ELEM_DATA */
626
0
    case 22: /* COMMA */
627
0
    case 23: /* EMPTY_KW */
628
0
{
629
0
#line 56 "/src/wireshark/epan/dtd_grammar.lemon"
630
631
0
  (void) bd; /* Mark unused, similar to Q_UNUSED */
632
0
  if ((yypminor->yy0)) {
633
0
    g_free((yypminor->yy0)->text);
634
0
    g_free((yypminor->yy0)->location);
635
0
    g_free((yypminor->yy0));
636
0
  }
637
638
0
#line 663 "./dtd_grammar.c"
639
0
}
640
0
      break;
641
/********* End destructor definitions *****************************************/
642
0
    default:  break;   /* If no destructor action specified: do nothing */
643
0
  }
644
0
}
645
646
/*
647
** Pop the parser's stack once.
648
**
649
** If there is a destructor routine associated with the token which
650
** is popped from the stack, then call it.
651
*/
652
0
static void yy_pop_parser_stack(yyParser *pParser){
653
0
  yyStackEntry *yytos;
654
0
  assert( pParser->yytos!=0 );
655
0
  assert( pParser->yytos > pParser->yystack );
656
0
  yytos = pParser->yytos--;
657
#ifndef NDEBUG
658
  if( yyTraceFILE ){
659
    fprintf(yyTraceFILE,"%sPopping %s\n",
660
      yyTracePrompt,
661
      yyTokenName[yytos->major]);
662
  }
663
#endif
664
0
  yy_destructor(pParser, yytos->major, &yytos->minor);
665
0
}
666
667
/*
668
** Clear all secondary memory allocations from the parser
669
*/
670
0
void DtdParseFinalize(void *p){
671
0
  yyParser *pParser = (yyParser*)p;
672
0
  while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser);
673
#if YYSTACKDEPTH<=0
674
  if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack);
675
#endif
676
0
}
677
678
#ifndef DtdParse_ENGINEALWAYSONSTACK
679
/*
680
** Deallocate and destroy a parser.  Destructors are called for
681
** all stack elements before shutting the parser down.
682
**
683
** If the YYPARSEFREENEVERNULL macro exists (for example because it
684
** is defined in a %include section of the input grammar) then it is
685
** assumed that the input pointer is never NULL.
686
*/
687
void DtdParseFree(
688
  void *p,                    /* The parser to be deleted */
689
  void (*freeProc)(void*)     /* Function used to reclaim memory */
690
0
){
691
0
#ifndef YYPARSEFREENEVERNULL
692
0
  if( p==0 ) return;
693
0
#endif
694
0
  DtdParseFinalize(p);
695
0
  (*freeProc)(p);
696
0
}
697
#endif /* DtdParse_ENGINEALWAYSONSTACK */
698
699
/*
700
** Return the peak depth of the stack for a parser.
701
*/
702
#ifdef YYTRACKMAXSTACKDEPTH
703
int DtdParseStackPeak(void *p){
704
  yyParser *pParser = (yyParser*)p;
705
  return pParser->yyhwm;
706
}
707
#endif
708
709
/* This array of booleans keeps track of the parser statement
710
** coverage.  The element yycoverage[X][Y] is set when the parser
711
** is in state X and has a lookahead token Y.  In a well-tested
712
** systems, every element of this matrix should end up being set.
713
*/
714
#if defined(YYCOVERAGE)
715
static unsigned char yycoverage[YYNSTATE][YYNTOKEN];
716
#endif
717
718
/*
719
** Write into out a description of every state/lookahead combination that
720
**
721
**   (1)  has not been used by the parser, and
722
**   (2)  is not a syntax error.
723
**
724
** Return the number of missed state/lookahead combinations.
725
*/
726
#if defined(YYCOVERAGE)
727
int DtdParseCoverage(FILE *out){
728
  int stateno, iLookAhead, i;
729
  int nMissed = 0;
730
  for(stateno=0; stateno<YYNSTATE; stateno++){
731
    i = yy_shift_ofst[stateno];
732
    for(iLookAhead=0; iLookAhead<YYNTOKEN; iLookAhead++){
733
      if( yy_lookahead[i+iLookAhead]!=iLookAhead ) continue;
734
      if( yycoverage[stateno][iLookAhead]==0 ) nMissed++;
735
      if( out ){
736
        fprintf(out,"State %d lookahead %s %s\n", stateno,
737
                yyTokenName[iLookAhead],
738
                yycoverage[stateno][iLookAhead] ? "ok" : "missed");
739
      }
740
    }
741
  }
742
  return nMissed;
743
}
744
#endif
745
746
/*
747
** Find the appropriate action for a parser given the terminal
748
** look-ahead token iLookAhead.
749
*/
750
static YYACTIONTYPE yy_find_shift_action(
751
  YYCODETYPE iLookAhead,    /* The look-ahead token */
752
  YYACTIONTYPE stateno      /* Current state number */
753
0
){
754
0
  int i;
755
756
0
  if( stateno>YY_MAX_SHIFT ) return stateno;
757
0
  assert( stateno <= YY_SHIFT_COUNT );
758
#if defined(YYCOVERAGE)
759
  yycoverage[stateno][iLookAhead] = 1;
760
#endif
761
0
  do{
762
0
    i = yy_shift_ofst[stateno];
763
0
    assert( i>=0 );
764
0
    assert( i<=YY_ACTTAB_COUNT );
765
0
    assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD );
766
0
    assert( iLookAhead!=YYNOCODE );
767
0
    assert( iLookAhead < YYNTOKEN );
768
0
    i += iLookAhead;
769
0
    assert( i<(int)YY_NLOOKAHEAD );
770
0
    if( yy_lookahead[i]!=iLookAhead ){
771
#ifdef YYFALLBACK
772
      YYCODETYPE iFallback;            /* Fallback token */
773
      assert( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0]) );
774
      iFallback = yyFallback[iLookAhead];
775
      if( iFallback!=0 ){
776
#ifndef NDEBUG
777
        if( yyTraceFILE ){
778
          fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
779
             yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
780
        }
781
#endif
782
        assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */
783
        iLookAhead = iFallback;
784
        continue;
785
      }
786
#endif
787
#ifdef YYWILDCARD
788
      {
789
        int j = i - iLookAhead + YYWILDCARD;
790
        assert( j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) );
791
        if( yy_lookahead[j]==YYWILDCARD && iLookAhead>0 ){
792
#ifndef NDEBUG
793
          if( yyTraceFILE ){
794
            fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
795
               yyTracePrompt, yyTokenName[iLookAhead],
796
               yyTokenName[YYWILDCARD]);
797
          }
798
#endif /* NDEBUG */
799
          return yy_action[j];
800
        }
801
      }
802
#endif /* YYWILDCARD */
803
0
      return yy_default[stateno];
804
0
    }else{
805
0
      assert( i>=0 && i<(int)(sizeof(yy_action)/sizeof(yy_action[0])) );
806
0
      return yy_action[i];
807
0
    }
808
0
  }while(1);
809
0
}
810
811
/*
812
** Find the appropriate action for a parser given the non-terminal
813
** look-ahead token iLookAhead.
814
*/
815
static YYACTIONTYPE yy_find_reduce_action(
816
  YYACTIONTYPE stateno,     /* Current state number */
817
  YYCODETYPE iLookAhead     /* The look-ahead token */
818
0
){
819
0
  int i;
820
#ifdef YYERRORSYMBOL
821
  if( stateno>YY_REDUCE_COUNT ){
822
    return yy_default[stateno];
823
  }
824
#else
825
0
  assert( stateno<=YY_REDUCE_COUNT );
826
0
#endif
827
0
  i = yy_reduce_ofst[stateno];
828
0
  assert( iLookAhead!=YYNOCODE );
829
0
  i += iLookAhead;
830
#ifdef YYERRORSYMBOL
831
  if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
832
    return yy_default[stateno];
833
  }
834
#else
835
0
  assert( i>=0 && i<YY_ACTTAB_COUNT );
836
0
  assert( yy_lookahead[i]==iLookAhead );
837
0
#endif
838
0
  return yy_action[i];
839
0
}
840
841
/*
842
** The following routine is called if the stack overflows.
843
*/
844
0
static void yyStackOverflow(yyParser *yypParser){
845
0
   DtdParseARG_FETCH
846
0
   DtdParseCTX_FETCH
847
#ifndef NDEBUG
848
   if( yyTraceFILE ){
849
     fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
850
   }
851
#endif
852
0
   while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
853
   /* Here code is inserted which will execute if the parser
854
   ** stack every overflows */
855
/******** Begin %stack_overflow code ******************************************/
856
/******** End %stack_overflow code ********************************************/
857
0
   DtdParseARG_STORE /* Suppress warning about unused %extra_argument var */
858
0
   DtdParseCTX_STORE
859
0
}
860
861
/*
862
** Print tracing information for a SHIFT action
863
*/
864
#ifndef NDEBUG
865
static void yyTraceShift(yyParser *yypParser, int yyNewState, const char *zTag){
866
  if( yyTraceFILE ){
867
    if( yyNewState<YYNSTATE ){
868
      fprintf(yyTraceFILE,"%s%s '%s', go to state %d\n",
869
         yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major],
870
         yyNewState);
871
    }else{
872
      fprintf(yyTraceFILE,"%s%s '%s', pending reduce %d\n",
873
         yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major],
874
         yyNewState - YY_MIN_REDUCE);
875
    }
876
  }
877
}
878
#else
879
# define yyTraceShift(X,Y,Z)
880
#endif
881
882
/*
883
** Perform a shift action.
884
*/
885
static void yy_shift(
886
  yyParser *yypParser,          /* The parser to be shifted */
887
  YYACTIONTYPE yyNewState,      /* The new state to shift in */
888
  YYCODETYPE yyMajor,           /* The major token to shift in */
889
  DtdParseTOKENTYPE yyMinor        /* The minor token to shift in */
890
0
){
891
0
  yyStackEntry *yytos;
892
0
  yypParser->yytos++;
893
#ifdef YYTRACKMAXSTACKDEPTH
894
  if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
895
    yypParser->yyhwm++;
896
    assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );
897
  }
898
#endif
899
0
#if YYSTACKDEPTH>0
900
0
  if( yypParser->yytos>yypParser->yystackEnd ){
901
0
    yypParser->yytos--;
902
0
    yyStackOverflow(yypParser);
903
0
    return;
904
0
  }
905
#else
906
  if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){
907
    if( yyGrowStack(yypParser) ){
908
      yypParser->yytos--;
909
      yyStackOverflow(yypParser);
910
      return;
911
    }
912
  }
913
#endif
914
0
  if( yyNewState > YY_MAX_SHIFT ){
915
0
    yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
916
0
  }
917
0
  yytos = yypParser->yytos;
918
0
  yytos->stateno = yyNewState;
919
0
  yytos->major = yyMajor;
920
0
  yytos->minor.yy0 = yyMinor;
921
0
  yyTraceShift(yypParser, yyNewState, "Shift");
922
0
}
923
924
/* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
925
** of that rule */
926
static const YYCODETYPE yyRuleInfoLhs[] = {
927
    25,  /* (0) doctype ::= TAG_START DOCTYPE_KW NAME OPEN_BRACKET dtd_parts CLOSE_BRACKET TAG_STOP */
928
    26,  /* (1) dtd_parts ::= dtd_parts element */
929
    26,  /* (2) dtd_parts ::= dtd_parts attlist */
930
    26,  /* (3) dtd_parts ::= element */
931
    26,  /* (4) dtd_parts ::= attlist */
932
    28,  /* (5) attlist ::= TAG_START ATTLIST_KW NAME attrib_list TAG_STOP */
933
    27,  /* (6) element ::= TAG_START ELEMENT_KW NAME sub_elements TAG_STOP */
934
    29,  /* (7) attrib_list ::= attrib_list attrib */
935
    29,  /* (8) attrib_list ::= attrib */
936
    31,  /* (9) attrib ::= NAME att_type att_default */
937
    30,  /* (10) sub_elements ::= sub_elements STAR */
938
    30,  /* (11) sub_elements ::= sub_elements PLUS */
939
    30,  /* (12) sub_elements ::= sub_elements QUESTION */
940
    30,  /* (13) sub_elements ::= OPEN_PARENS ELEM_DATA CLOSE_PARENS */
941
    30,  /* (14) sub_elements ::= OPEN_PARENS element_list COMMA ELEM_DATA CLOSE_PARENS */
942
    30,  /* (15) sub_elements ::= OPEN_PARENS element_list PIPE ELEM_DATA CLOSE_PARENS */
943
    30,  /* (16) sub_elements ::= OPEN_PARENS element_list CLOSE_PARENS */
944
    30,  /* (17) sub_elements ::= EMPTY_KW */
945
    37,  /* (18) element_list ::= element_list COMMA element_child */
946
    37,  /* (19) element_list ::= element_list PIPE element_child */
947
    37,  /* (20) element_list ::= element_child */
948
    37,  /* (21) element_list ::= sub_elements */
949
    37,  /* (22) element_list ::= element_list COMMA sub_elements */
950
    37,  /* (23) element_list ::= element_list PIPE sub_elements */
951
    38,  /* (24) element_child ::= NAME */
952
    38,  /* (25) element_child ::= NAME STAR */
953
    38,  /* (26) element_child ::= NAME QUESTION */
954
    38,  /* (27) element_child ::= NAME PLUS */
955
    24,  /* (28) dtd ::= doctype */
956
    24,  /* (29) dtd ::= dtd_parts */
957
    32,  /* (30) att_type ::= ATT_TYPE */
958
    32,  /* (31) att_type ::= enumeration */
959
    33,  /* (32) att_default ::= ATT_DEF */
960
    33,  /* (33) att_default ::= ATT_DEF_WITH_VALUE QUOTED */
961
    33,  /* (34) att_default ::= QUOTED */
962
    33,  /* (35) att_default ::= IMPLIED_KW */
963
    33,  /* (36) att_default ::= REQUIRED_KW */
964
    34,  /* (37) enumeration ::= OPEN_PARENS enum_list CLOSE_PARENS */
965
    35,  /* (38) enum_list ::= enum_list PIPE enum_item */
966
    35,  /* (39) enum_list ::= enum_item */
967
    35,  /* (40) enum_list ::= enumeration */
968
    35,  /* (41) enum_list ::= enum_list PIPE enumeration */
969
    36,  /* (42) enum_item ::= NAME */
970
    36,  /* (43) enum_item ::= QUOTED */
971
};
972
973
/* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
974
** of symbols on the right-hand side of that rule. */
975
static const signed char yyRuleInfoNRhs[] = {
976
   -7,  /* (0) doctype ::= TAG_START DOCTYPE_KW NAME OPEN_BRACKET dtd_parts CLOSE_BRACKET TAG_STOP */
977
   -2,  /* (1) dtd_parts ::= dtd_parts element */
978
   -2,  /* (2) dtd_parts ::= dtd_parts attlist */
979
   -1,  /* (3) dtd_parts ::= element */
980
   -1,  /* (4) dtd_parts ::= attlist */
981
   -5,  /* (5) attlist ::= TAG_START ATTLIST_KW NAME attrib_list TAG_STOP */
982
   -5,  /* (6) element ::= TAG_START ELEMENT_KW NAME sub_elements TAG_STOP */
983
   -2,  /* (7) attrib_list ::= attrib_list attrib */
984
   -1,  /* (8) attrib_list ::= attrib */
985
   -3,  /* (9) attrib ::= NAME att_type att_default */
986
   -2,  /* (10) sub_elements ::= sub_elements STAR */
987
   -2,  /* (11) sub_elements ::= sub_elements PLUS */
988
   -2,  /* (12) sub_elements ::= sub_elements QUESTION */
989
   -3,  /* (13) sub_elements ::= OPEN_PARENS ELEM_DATA CLOSE_PARENS */
990
   -5,  /* (14) sub_elements ::= OPEN_PARENS element_list COMMA ELEM_DATA CLOSE_PARENS */
991
   -5,  /* (15) sub_elements ::= OPEN_PARENS element_list PIPE ELEM_DATA CLOSE_PARENS */
992
   -3,  /* (16) sub_elements ::= OPEN_PARENS element_list CLOSE_PARENS */
993
   -1,  /* (17) sub_elements ::= EMPTY_KW */
994
   -3,  /* (18) element_list ::= element_list COMMA element_child */
995
   -3,  /* (19) element_list ::= element_list PIPE element_child */
996
   -1,  /* (20) element_list ::= element_child */
997
   -1,  /* (21) element_list ::= sub_elements */
998
   -3,  /* (22) element_list ::= element_list COMMA sub_elements */
999
   -3,  /* (23) element_list ::= element_list PIPE sub_elements */
1000
   -1,  /* (24) element_child ::= NAME */
1001
   -2,  /* (25) element_child ::= NAME STAR */
1002
   -2,  /* (26) element_child ::= NAME QUESTION */
1003
   -2,  /* (27) element_child ::= NAME PLUS */
1004
   -1,  /* (28) dtd ::= doctype */
1005
   -1,  /* (29) dtd ::= dtd_parts */
1006
   -1,  /* (30) att_type ::= ATT_TYPE */
1007
   -1,  /* (31) att_type ::= enumeration */
1008
   -1,  /* (32) att_default ::= ATT_DEF */
1009
   -2,  /* (33) att_default ::= ATT_DEF_WITH_VALUE QUOTED */
1010
   -1,  /* (34) att_default ::= QUOTED */
1011
   -1,  /* (35) att_default ::= IMPLIED_KW */
1012
   -1,  /* (36) att_default ::= REQUIRED_KW */
1013
   -3,  /* (37) enumeration ::= OPEN_PARENS enum_list CLOSE_PARENS */
1014
   -3,  /* (38) enum_list ::= enum_list PIPE enum_item */
1015
   -1,  /* (39) enum_list ::= enum_item */
1016
   -1,  /* (40) enum_list ::= enumeration */
1017
   -3,  /* (41) enum_list ::= enum_list PIPE enumeration */
1018
   -1,  /* (42) enum_item ::= NAME */
1019
   -1,  /* (43) enum_item ::= QUOTED */
1020
};
1021
1022
static void yy_accept(yyParser*);  /* Forward Declaration */
1023
1024
/*
1025
** Perform a reduce action and the shift that must immediately
1026
** follow the reduce.
1027
**
1028
** The yyLookahead and yyLookaheadToken parameters provide reduce actions
1029
** access to the lookahead token (if any).  The yyLookahead will be YYNOCODE
1030
** if the lookahead token has already been consumed.  As this procedure is
1031
** only called from one place, optimizing compilers will in-line it, which
1032
** means that the extra parameters have no performance impact.
1033
*/
1034
static YYACTIONTYPE yy_reduce(
1035
  yyParser *yypParser,         /* The parser */
1036
  unsigned int yyruleno,       /* Number of the rule by which to reduce */
1037
  int yyLookahead,             /* Lookahead token, or YYNOCODE if none */
1038
  DtdParseTOKENTYPE yyLookaheadToken  /* Value of the lookahead token */
1039
  DtdParseCTX_PDECL                   /* %extra_context */
1040
0
){
1041
0
  int yygoto;                     /* The next state */
1042
0
  YYACTIONTYPE yyact;             /* The next action */
1043
0
  yyStackEntry *yymsp;            /* The top of the parser's stack */
1044
0
  int yysize;                     /* Amount to pop the stack */
1045
0
  DtdParseARG_FETCH
1046
0
  (void)yyLookahead;
1047
0
  (void)yyLookaheadToken;
1048
0
  yymsp = yypParser->yytos;
1049
1050
0
  switch( yyruleno ){
1051
  /* Beginning here are the reduction cases.  A typical example
1052
  ** follows:
1053
  **   case 0:
1054
  **  #line <lineno> <grammarfile>
1055
  **     { ... }           // User supplied code
1056
  **  #line <lineno> <thisfile>
1057
  **     break;
1058
  */
1059
/********** Begin reduce actions **********************************************/
1060
0
        YYMINORTYPE yylhsminor;
1061
0
      case 0: /* doctype ::= TAG_START DOCTYPE_KW NAME OPEN_BRACKET dtd_parts CLOSE_BRACKET TAG_STOP */
1062
0
{  yy_destructor(yypParser,1,&yymsp[-6].minor);
1063
0
#line 83 "/src/wireshark/epan/dtd_grammar.lemon"
1064
0
{
1065
0
  dtd_named_list_t* root;
1066
0
  GPtrArray* root_elems = g_ptr_array_new();
1067
0
  unsigned i;
1068
0
  char *name;
1069
1070
0
  if(! bd->proto_name) {
1071
0
    bd->proto_name = g_strdup(yymsp[-4].minor.yy0->text);
1072
0
  }
1073
1074
0
  g_free(bd->proto_root);
1075
1076
0
  bd->proto_root = yymsp[-4].minor.yy0->text;
1077
1078
0
  name = g_ascii_strdown(bd->proto_name, -1);
1079
0
  g_free(bd->proto_name);
1080
0
  bd->proto_name = name;
1081
1082
0
  for( i = 0; i< bd->elements->len; i++) {
1083
0
    dtd_named_list_t* el = (dtd_named_list_t*)g_ptr_array_index(bd->elements,i);
1084
1085
0
    g_ptr_array_add(root_elems,g_strdup(el->name));
1086
0
  }
1087
1088
0
  root = dtd_named_list_new(g_strdup(yymsp[-4].minor.yy0->text),root_elems);
1089
1090
0
  g_ptr_array_add(bd->elements,root);
1091
1092
0
  g_free(yymsp[-4].minor.yy0->location);
1093
0
  g_free(yymsp[-4].minor.yy0);
1094
1095
0
}
1096
0
#line 1121 "./dtd_grammar.c"
1097
0
  yy_destructor(yypParser,2,&yymsp[-5].minor);
1098
0
  yy_destructor(yypParser,4,&yymsp[-3].minor);
1099
0
  yy_destructor(yypParser,5,&yymsp[-1].minor);
1100
0
  yy_destructor(yypParser,6,&yymsp[0].minor);
1101
0
}
1102
0
        break;
1103
0
      case 1: /* dtd_parts ::= dtd_parts element */
1104
0
      case 3: /* dtd_parts ::= element */ yytestcase(yyruleno==3);
1105
0
#line 116 "/src/wireshark/epan/dtd_grammar.lemon"
1106
0
{ g_ptr_array_add(bd->elements,yymsp[0].minor.yy41); }
1107
0
#line 1132 "./dtd_grammar.c"
1108
0
        break;
1109
0
      case 2: /* dtd_parts ::= dtd_parts attlist */
1110
0
      case 4: /* dtd_parts ::= attlist */ yytestcase(yyruleno==4);
1111
0
#line 117 "/src/wireshark/epan/dtd_grammar.lemon"
1112
0
{ g_ptr_array_add(bd->attributes,yymsp[0].minor.yy41); }
1113
0
#line 1138 "./dtd_grammar.c"
1114
0
        break;
1115
0
      case 5: /* attlist ::= TAG_START ATTLIST_KW NAME attrib_list TAG_STOP */
1116
0
{  yy_destructor(yypParser,1,&yymsp[-4].minor);
1117
0
#line 122 "/src/wireshark/epan/dtd_grammar.lemon"
1118
0
{
1119
0
  yymsp[-4].minor.yy41 = dtd_named_list_new(g_ascii_strdown(yymsp[-2].minor.yy0->text, -1),yymsp[-1].minor.yy9);
1120
0
  g_free(yymsp[-2].minor.yy0->text);
1121
0
  g_free(yymsp[-2].minor.yy0->location);
1122
0
  g_free(yymsp[-2].minor.yy0);
1123
0
}
1124
0
#line 1149 "./dtd_grammar.c"
1125
0
  yy_destructor(yypParser,7,&yymsp[-3].minor);
1126
0
  yy_destructor(yypParser,6,&yymsp[0].minor);
1127
0
}
1128
0
        break;
1129
0
      case 6: /* element ::= TAG_START ELEMENT_KW NAME sub_elements TAG_STOP */
1130
0
{  yy_destructor(yypParser,1,&yymsp[-4].minor);
1131
0
#line 130 "/src/wireshark/epan/dtd_grammar.lemon"
1132
0
{
1133
0
  yymsp[-4].minor.yy41 = dtd_named_list_new(g_ascii_strdown(yymsp[-2].minor.yy0->text, -1),yymsp[-1].minor.yy9);
1134
0
  g_free(yymsp[-2].minor.yy0->text);
1135
0
  g_free(yymsp[-2].minor.yy0->location);
1136
0
  g_free(yymsp[-2].minor.yy0);
1137
0
}
1138
0
#line 1163 "./dtd_grammar.c"
1139
0
  yy_destructor(yypParser,8,&yymsp[-3].minor);
1140
0
  yy_destructor(yypParser,6,&yymsp[0].minor);
1141
0
}
1142
0
        break;
1143
0
      case 7: /* attrib_list ::= attrib_list attrib */
1144
0
#line 138 "/src/wireshark/epan/dtd_grammar.lemon"
1145
0
{ g_ptr_array_add(yymsp[-1].minor.yy9,yymsp[0].minor.yy15); yylhsminor.yy9 = yymsp[-1].minor.yy9; }
1146
0
#line 1171 "./dtd_grammar.c"
1147
0
  yymsp[-1].minor.yy9 = yylhsminor.yy9;
1148
0
        break;
1149
0
      case 8: /* attrib_list ::= attrib */
1150
0
#line 139 "/src/wireshark/epan/dtd_grammar.lemon"
1151
0
{ yylhsminor.yy9 = g_ptr_array_new(); g_ptr_array_add(yylhsminor.yy9,yymsp[0].minor.yy15);  }
1152
0
#line 1177 "./dtd_grammar.c"
1153
0
  yymsp[0].minor.yy9 = yylhsminor.yy9;
1154
0
        break;
1155
0
      case 9: /* attrib ::= NAME att_type att_default */
1156
0
#line 142 "/src/wireshark/epan/dtd_grammar.lemon"
1157
0
{
1158
0
  yylhsminor.yy15 = g_ascii_strdown(yymsp[-2].minor.yy0->text, -1);
1159
0
  g_free(yymsp[-2].minor.yy0->text);
1160
0
  g_free(yymsp[-2].minor.yy0->location);
1161
0
  g_free(yymsp[-2].minor.yy0);
1162
0
}
1163
0
#line 1188 "./dtd_grammar.c"
1164
0
  yymsp[-2].minor.yy15 = yylhsminor.yy15;
1165
0
        break;
1166
0
      case 10: /* sub_elements ::= sub_elements STAR */
1167
0
#line 170 "/src/wireshark/epan/dtd_grammar.lemon"
1168
0
{yylhsminor.yy9=yymsp[-1].minor.yy9;}
1169
0
#line 1194 "./dtd_grammar.c"
1170
0
  yy_destructor(yypParser,18,&yymsp[0].minor);
1171
0
  yymsp[-1].minor.yy9 = yylhsminor.yy9;
1172
0
        break;
1173
0
      case 11: /* sub_elements ::= sub_elements PLUS */
1174
0
#line 171 "/src/wireshark/epan/dtd_grammar.lemon"
1175
0
{yylhsminor.yy9=yymsp[-1].minor.yy9;}
1176
0
#line 1201 "./dtd_grammar.c"
1177
0
  yy_destructor(yypParser,19,&yymsp[0].minor);
1178
0
  yymsp[-1].minor.yy9 = yylhsminor.yy9;
1179
0
        break;
1180
0
      case 12: /* sub_elements ::= sub_elements QUESTION */
1181
0
#line 172 "/src/wireshark/epan/dtd_grammar.lemon"
1182
0
{yylhsminor.yy9=yymsp[-1].minor.yy9;}
1183
0
#line 1208 "./dtd_grammar.c"
1184
0
  yy_destructor(yypParser,20,&yymsp[0].minor);
1185
0
  yymsp[-1].minor.yy9 = yylhsminor.yy9;
1186
0
        break;
1187
0
      case 13: /* sub_elements ::= OPEN_PARENS ELEM_DATA CLOSE_PARENS */
1188
0
{  yy_destructor(yypParser,15,&yymsp[-2].minor);
1189
0
#line 173 "/src/wireshark/epan/dtd_grammar.lemon"
1190
0
{ yymsp[-2].minor.yy9 = g_ptr_array_new(); }
1191
0
#line 1216 "./dtd_grammar.c"
1192
0
  yy_destructor(yypParser,21,&yymsp[-1].minor);
1193
0
  yy_destructor(yypParser,16,&yymsp[0].minor);
1194
0
}
1195
0
        break;
1196
0
      case 14: /* sub_elements ::= OPEN_PARENS element_list COMMA ELEM_DATA CLOSE_PARENS */
1197
0
{  yy_destructor(yypParser,15,&yymsp[-4].minor);
1198
0
#line 174 "/src/wireshark/epan/dtd_grammar.lemon"
1199
0
{ yymsp[-4].minor.yy9 = yymsp[-3].minor.yy9; }
1200
0
#line 1225 "./dtd_grammar.c"
1201
0
  yy_destructor(yypParser,22,&yymsp[-2].minor);
1202
0
  yy_destructor(yypParser,21,&yymsp[-1].minor);
1203
0
  yy_destructor(yypParser,16,&yymsp[0].minor);
1204
0
}
1205
0
        break;
1206
0
      case 15: /* sub_elements ::= OPEN_PARENS element_list PIPE ELEM_DATA CLOSE_PARENS */
1207
0
{  yy_destructor(yypParser,15,&yymsp[-4].minor);
1208
0
#line 175 "/src/wireshark/epan/dtd_grammar.lemon"
1209
0
{ yymsp[-4].minor.yy9 = yymsp[-3].minor.yy9; }
1210
0
#line 1235 "./dtd_grammar.c"
1211
0
  yy_destructor(yypParser,17,&yymsp[-2].minor);
1212
0
  yy_destructor(yypParser,21,&yymsp[-1].minor);
1213
0
  yy_destructor(yypParser,16,&yymsp[0].minor);
1214
0
}
1215
0
        break;
1216
0
      case 16: /* sub_elements ::= OPEN_PARENS element_list CLOSE_PARENS */
1217
0
{  yy_destructor(yypParser,15,&yymsp[-2].minor);
1218
0
#line 176 "/src/wireshark/epan/dtd_grammar.lemon"
1219
0
{ yymsp[-2].minor.yy9 = yymsp[-1].minor.yy9; }
1220
0
#line 1245 "./dtd_grammar.c"
1221
0
  yy_destructor(yypParser,16,&yymsp[0].minor);
1222
0
}
1223
0
        break;
1224
0
      case 17: /* sub_elements ::= EMPTY_KW */
1225
0
{  yy_destructor(yypParser,23,&yymsp[0].minor);
1226
0
#line 177 "/src/wireshark/epan/dtd_grammar.lemon"
1227
0
{ yymsp[0].minor.yy9 = g_ptr_array_new(); }
1228
0
#line 1253 "./dtd_grammar.c"
1229
0
}
1230
0
        break;
1231
0
      case 18: /* element_list ::= element_list COMMA element_child */
1232
0
#line 180 "/src/wireshark/epan/dtd_grammar.lemon"
1233
0
{ g_ptr_array_add(yymsp[-2].minor.yy9,yymsp[0].minor.yy15); yylhsminor.yy9 = yymsp[-2].minor.yy9; }
1234
0
#line 1259 "./dtd_grammar.c"
1235
0
  yy_destructor(yypParser,22,&yymsp[-1].minor);
1236
0
  yymsp[-2].minor.yy9 = yylhsminor.yy9;
1237
0
        break;
1238
0
      case 19: /* element_list ::= element_list PIPE element_child */
1239
0
#line 181 "/src/wireshark/epan/dtd_grammar.lemon"
1240
0
{ g_ptr_array_add(yymsp[-2].minor.yy9,yymsp[0].minor.yy15); yylhsminor.yy9 = yymsp[-2].minor.yy9; }
1241
0
#line 1266 "./dtd_grammar.c"
1242
0
  yy_destructor(yypParser,17,&yymsp[-1].minor);
1243
0
  yymsp[-2].minor.yy9 = yylhsminor.yy9;
1244
0
        break;
1245
0
      case 20: /* element_list ::= element_child */
1246
0
#line 182 "/src/wireshark/epan/dtd_grammar.lemon"
1247
0
{ yylhsminor.yy9 = g_ptr_array_new(); g_ptr_array_add(yylhsminor.yy9,yymsp[0].minor.yy15); }
1248
0
#line 1273 "./dtd_grammar.c"
1249
0
  yymsp[0].minor.yy9 = yylhsminor.yy9;
1250
0
        break;
1251
0
      case 21: /* element_list ::= sub_elements */
1252
0
#line 183 "/src/wireshark/epan/dtd_grammar.lemon"
1253
0
{ yylhsminor.yy9 = yymsp[0].minor.yy9; }
1254
0
#line 1279 "./dtd_grammar.c"
1255
0
  yymsp[0].minor.yy9 = yylhsminor.yy9;
1256
0
        break;
1257
0
      case 22: /* element_list ::= element_list COMMA sub_elements */
1258
0
#line 184 "/src/wireshark/epan/dtd_grammar.lemon"
1259
0
{ yylhsminor.yy9 = g_ptr_array_join(yymsp[-2].minor.yy9,yymsp[0].minor.yy9); }
1260
0
#line 1285 "./dtd_grammar.c"
1261
0
  yy_destructor(yypParser,22,&yymsp[-1].minor);
1262
0
  yymsp[-2].minor.yy9 = yylhsminor.yy9;
1263
0
        break;
1264
0
      case 23: /* element_list ::= element_list PIPE sub_elements */
1265
0
#line 185 "/src/wireshark/epan/dtd_grammar.lemon"
1266
0
{ yylhsminor.yy9 = g_ptr_array_join(yymsp[-2].minor.yy9,yymsp[0].minor.yy9); }
1267
0
#line 1292 "./dtd_grammar.c"
1268
0
  yy_destructor(yypParser,17,&yymsp[-1].minor);
1269
0
  yymsp[-2].minor.yy9 = yylhsminor.yy9;
1270
0
        break;
1271
0
      case 24: /* element_child ::= NAME */
1272
0
#line 188 "/src/wireshark/epan/dtd_grammar.lemon"
1273
0
{
1274
0
  yylhsminor.yy15 = g_ascii_strdown(yymsp[0].minor.yy0->text, -1);
1275
0
  g_free(yymsp[0].minor.yy0->text);
1276
0
  g_free(yymsp[0].minor.yy0->location);
1277
0
  g_free(yymsp[0].minor.yy0);
1278
0
}
1279
0
#line 1304 "./dtd_grammar.c"
1280
0
  yymsp[0].minor.yy15 = yylhsminor.yy15;
1281
0
        break;
1282
0
      case 25: /* element_child ::= NAME STAR */
1283
0
#line 195 "/src/wireshark/epan/dtd_grammar.lemon"
1284
0
{
1285
0
  yylhsminor.yy15 = g_ascii_strdown(yymsp[-1].minor.yy0->text, -1);
1286
0
  g_free(yymsp[-1].minor.yy0->text);
1287
0
  g_free(yymsp[-1].minor.yy0->location);
1288
0
  g_free(yymsp[-1].minor.yy0);
1289
0
}
1290
0
#line 1315 "./dtd_grammar.c"
1291
0
  yy_destructor(yypParser,18,&yymsp[0].minor);
1292
0
  yymsp[-1].minor.yy15 = yylhsminor.yy15;
1293
0
        break;
1294
0
      case 26: /* element_child ::= NAME QUESTION */
1295
0
#line 202 "/src/wireshark/epan/dtd_grammar.lemon"
1296
0
{
1297
0
  yylhsminor.yy15 = g_ascii_strdown(yymsp[-1].minor.yy0->text, -1);
1298
0
  g_free(yymsp[-1].minor.yy0->text);
1299
0
  g_free(yymsp[-1].minor.yy0->location);
1300
0
  g_free(yymsp[-1].minor.yy0);
1301
0
}
1302
0
#line 1327 "./dtd_grammar.c"
1303
0
  yy_destructor(yypParser,20,&yymsp[0].minor);
1304
0
  yymsp[-1].minor.yy15 = yylhsminor.yy15;
1305
0
        break;
1306
0
      case 27: /* element_child ::= NAME PLUS */
1307
0
#line 209 "/src/wireshark/epan/dtd_grammar.lemon"
1308
0
{
1309
0
  yylhsminor.yy15 = g_ascii_strdown(yymsp[-1].minor.yy0->text, -1);
1310
0
  g_free(yymsp[-1].minor.yy0->text);
1311
0
  g_free(yymsp[-1].minor.yy0->location);
1312
0
  g_free(yymsp[-1].minor.yy0);
1313
0
}
1314
0
#line 1339 "./dtd_grammar.c"
1315
0
  yy_destructor(yypParser,19,&yymsp[0].minor);
1316
0
  yymsp[-1].minor.yy15 = yylhsminor.yy15;
1317
0
        break;
1318
0
      case 30: /* att_type ::= ATT_TYPE */
1319
0
{  yy_destructor(yypParser,9,&yymsp[0].minor);
1320
0
#line 149 "/src/wireshark/epan/dtd_grammar.lemon"
1321
0
{
1322
0
}
1323
0
#line 1348 "./dtd_grammar.c"
1324
0
}
1325
0
        break;
1326
0
      case 32: /* att_default ::= ATT_DEF */
1327
0
{  yy_destructor(yypParser,10,&yymsp[0].minor);
1328
0
#line 152 "/src/wireshark/epan/dtd_grammar.lemon"
1329
0
{
1330
0
}
1331
0
#line 1356 "./dtd_grammar.c"
1332
0
}
1333
0
        break;
1334
0
      case 33: /* att_default ::= ATT_DEF_WITH_VALUE QUOTED */
1335
0
{  yy_destructor(yypParser,11,&yymsp[-1].minor);
1336
0
#line 153 "/src/wireshark/epan/dtd_grammar.lemon"
1337
0
{
1338
0
}
1339
0
#line 1364 "./dtd_grammar.c"
1340
0
  yy_destructor(yypParser,12,&yymsp[0].minor);
1341
0
}
1342
0
        break;
1343
0
      case 34: /* att_default ::= QUOTED */
1344
0
      case 43: /* enum_item ::= QUOTED */ yytestcase(yyruleno==43);
1345
0
{  yy_destructor(yypParser,12,&yymsp[0].minor);
1346
0
#line 154 "/src/wireshark/epan/dtd_grammar.lemon"
1347
0
{
1348
0
}
1349
0
#line 1374 "./dtd_grammar.c"
1350
0
}
1351
0
        break;
1352
0
      case 35: /* att_default ::= IMPLIED_KW */
1353
0
{  yy_destructor(yypParser,13,&yymsp[0].minor);
1354
0
#line 155 "/src/wireshark/epan/dtd_grammar.lemon"
1355
0
{
1356
0
}
1357
0
#line 1382 "./dtd_grammar.c"
1358
0
}
1359
0
        break;
1360
0
      case 36: /* att_default ::= REQUIRED_KW */
1361
0
{  yy_destructor(yypParser,14,&yymsp[0].minor);
1362
0
#line 156 "/src/wireshark/epan/dtd_grammar.lemon"
1363
0
{
1364
0
}
1365
0
#line 1390 "./dtd_grammar.c"
1366
0
}
1367
0
        break;
1368
0
      case 37: /* enumeration ::= OPEN_PARENS enum_list CLOSE_PARENS */
1369
0
{  yy_destructor(yypParser,15,&yymsp[-2].minor);
1370
0
#line 158 "/src/wireshark/epan/dtd_grammar.lemon"
1371
0
{
1372
0
}
1373
0
#line 1398 "./dtd_grammar.c"
1374
0
  yy_destructor(yypParser,16,&yymsp[0].minor);
1375
0
}
1376
0
        break;
1377
0
      case 38: /* enum_list ::= enum_list PIPE enum_item */
1378
0
      case 41: /* enum_list ::= enum_list PIPE enumeration */ yytestcase(yyruleno==41);
1379
0
#line 160 "/src/wireshark/epan/dtd_grammar.lemon"
1380
0
{
1381
0
}
1382
0
#line 1407 "./dtd_grammar.c"
1383
0
  yy_destructor(yypParser,17,&yymsp[-1].minor);
1384
0
        break;
1385
0
      case 42: /* enum_item ::= NAME */
1386
0
{  yy_destructor(yypParser,3,&yymsp[0].minor);
1387
0
#line 165 "/src/wireshark/epan/dtd_grammar.lemon"
1388
0
{
1389
0
}
1390
0
#line 1415 "./dtd_grammar.c"
1391
0
}
1392
0
        break;
1393
0
      default:
1394
0
      /* (28) dtd ::= doctype */ yytestcase(yyruleno==28);
1395
0
      /* (29) dtd ::= dtd_parts */ yytestcase(yyruleno==29);
1396
0
      /* (31) att_type ::= enumeration (OPTIMIZED OUT) */ assert(yyruleno!=31);
1397
0
      /* (39) enum_list ::= enum_item (OPTIMIZED OUT) */ assert(yyruleno!=39);
1398
0
      /* (40) enum_list ::= enumeration (OPTIMIZED OUT) */ assert(yyruleno!=40);
1399
0
        break;
1400
/********** End reduce actions ************************************************/
1401
0
  };
1402
0
  assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) );
1403
0
  yygoto = yyRuleInfoLhs[yyruleno];
1404
0
  yysize = yyRuleInfoNRhs[yyruleno];
1405
0
  yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto);
1406
1407
  /* There are no SHIFTREDUCE actions on nonterminals because the table
1408
  ** generator has simplified them to pure REDUCE actions. */
1409
0
  assert( !(yyact>YY_MAX_SHIFT && yyact<=YY_MAX_SHIFTREDUCE) );
1410
1411
  /* It is not possible for a REDUCE to be followed by an error */
1412
0
  assert( yyact!=YY_ERROR_ACTION );
1413
1414
0
  yymsp += yysize+1;
1415
0
  yypParser->yytos = yymsp;
1416
0
  yymsp->stateno = (YYACTIONTYPE)yyact;
1417
0
  yymsp->major = (YYCODETYPE)yygoto;
1418
0
  yyTraceShift(yypParser, yyact, "... then shift");
1419
0
  return yyact;
1420
0
}
1421
1422
/*
1423
** The following code executes when the parse fails
1424
*/
1425
#ifndef YYNOERRORRECOVERY
1426
static void yy_parse_failed(
1427
  yyParser *yypParser           /* The parser */
1428
0
){
1429
0
  DtdParseARG_FETCH
1430
0
  DtdParseCTX_FETCH
1431
#ifndef NDEBUG
1432
  if( yyTraceFILE ){
1433
    fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
1434
  }
1435
#endif
1436
0
  while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
1437
  /* Here code is inserted which will be executed whenever the
1438
  ** parser fails */
1439
/************ Begin %parse_failure code ***************************************/
1440
0
#line 72 "/src/wireshark/epan/dtd_grammar.lemon"
1441
1442
0
  g_string_append_printf(bd->error,"DTD parsing failure\n");
1443
0
#line 1468 "./dtd_grammar.c"
1444
/************ End %parse_failure code *****************************************/
1445
0
  DtdParseARG_STORE /* Suppress warning about unused %extra_argument variable */
1446
0
  DtdParseCTX_STORE
1447
0
}
1448
#endif /* YYNOERRORRECOVERY */
1449
1450
/*
1451
** The following code executes when a syntax error first occurs.
1452
*/
1453
static void yy_syntax_error(
1454
  yyParser *yypParser,           /* The parser */
1455
  int yymajor,                   /* The major type of the error token */
1456
  DtdParseTOKENTYPE yyminor         /* The minor type of the error token */
1457
0
){
1458
0
  DtdParseARG_FETCH
1459
0
  DtdParseCTX_FETCH
1460
0
#define TOKEN yyminor
1461
/************ Begin %syntax_error code ****************************************/
1462
0
#line 65 "/src/wireshark/epan/dtd_grammar.lemon"
1463
1464
0
  if (!TOKEN)
1465
0
    g_string_append_printf(bd->error,"syntax error at end of file");
1466
0
  else
1467
0
    g_string_append_printf(bd->error,"syntax error in %s at or before '%s': \n", TOKEN->location,TOKEN->text);
1468
0
#line 1493 "./dtd_grammar.c"
1469
/************ End %syntax_error code ******************************************/
1470
0
  DtdParseARG_STORE /* Suppress warning about unused %extra_argument variable */
1471
0
  DtdParseCTX_STORE
1472
0
}
1473
1474
/*
1475
** The following is executed when the parser accepts
1476
*/
1477
static void yy_accept(
1478
  yyParser *yypParser           /* The parser */
1479
0
){
1480
0
  DtdParseARG_FETCH
1481
0
  DtdParseCTX_FETCH
1482
#ifndef NDEBUG
1483
  if( yyTraceFILE ){
1484
    fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
1485
  }
1486
#endif
1487
0
#ifndef YYNOERRORRECOVERY
1488
0
  yypParser->yyerrcnt = -1;
1489
0
#endif
1490
0
  assert( yypParser->yytos==yypParser->yystack );
1491
  /* Here code is inserted which will be executed whenever the
1492
  ** parser accepts */
1493
/*********** Begin %parse_accept code *****************************************/
1494
/*********** End %parse_accept code *******************************************/
1495
0
  DtdParseARG_STORE /* Suppress warning about unused %extra_argument variable */
1496
0
  DtdParseCTX_STORE
1497
0
}
1498
1499
/* The main parser program.
1500
** The first argument is a pointer to a structure obtained from
1501
** "DtdParseAlloc" which describes the current state of the parser.
1502
** The second argument is the major token number.  The third is
1503
** the minor token.  The fourth optional argument is whatever the
1504
** user wants (and specified in the grammar) and is available for
1505
** use by the action routines.
1506
**
1507
** Inputs:
1508
** <ul>
1509
** <li> A pointer to the parser (an opaque structure.)
1510
** <li> The major token number.
1511
** <li> The minor token number.
1512
** <li> An option argument of a grammar-specified type.
1513
** </ul>
1514
**
1515
** Outputs:
1516
** None.
1517
*/
1518
void DtdParse(
1519
  void *yyp,                   /* The parser */
1520
  int yymajor,                 /* The major token code number */
1521
  DtdParseTOKENTYPE yyminor       /* The value for the token */
1522
  DtdParseARG_PDECL               /* Optional %extra_argument parameter */
1523
0
){
1524
0
  YYMINORTYPE yyminorunion;
1525
0
  YYACTIONTYPE yyact;   /* The parser action. */
1526
0
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
1527
0
  int yyendofinput;     /* True if we are at the end of input */
1528
0
#endif
1529
#ifdef YYERRORSYMBOL
1530
  int yyerrorhit = 0;   /* True if yymajor has invoked an error */
1531
#endif
1532
0
  yyParser *yypParser = (yyParser*)yyp;  /* The parser */
1533
0
  DtdParseCTX_FETCH
1534
0
  DtdParseARG_STORE
1535
1536
0
  assert( yypParser->yytos!=0 );
1537
0
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
1538
0
  yyendofinput = (yymajor==0);
1539
0
#endif
1540
1541
0
  yyact = yypParser->yytos->stateno;
1542
#ifndef NDEBUG
1543
  if( yyTraceFILE ){
1544
    if( yyact < YY_MIN_REDUCE ){
1545
      fprintf(yyTraceFILE,"%sInput '%s' in state %d\n",
1546
              yyTracePrompt,yyTokenName[yymajor],yyact);
1547
    }else{
1548
      fprintf(yyTraceFILE,"%sInput '%s' with pending reduce %d\n",
1549
              yyTracePrompt,yyTokenName[yymajor],yyact-YY_MIN_REDUCE);
1550
    }
1551
  }
1552
#endif
1553
1554
0
  while(1){ /* Exit by "break" */
1555
0
    assert( yypParser->yytos>=yypParser->yystack );
1556
0
    assert( yyact==yypParser->yytos->stateno );
1557
0
    yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact);
1558
0
    if( yyact >= YY_MIN_REDUCE ){
1559
0
      unsigned int yyruleno = yyact - YY_MIN_REDUCE; /* Reduce by this rule */
1560
#ifndef NDEBUG
1561
      assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) );
1562
      if( yyTraceFILE ){
1563
        int yysize = yyRuleInfoNRhs[yyruleno];
1564
        if( yysize ){
1565
          fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n",
1566
            yyTracePrompt,
1567
            yyruleno, yyRuleName[yyruleno],
1568
            yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action",
1569
            yypParser->yytos[yysize].stateno);
1570
        }else{
1571
          fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n",
1572
            yyTracePrompt, yyruleno, yyRuleName[yyruleno],
1573
            yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action");
1574
        }
1575
      }
1576
#endif /* NDEBUG */
1577
1578
      /* Check that the stack is large enough to grow by a single entry
1579
      ** if the RHS of the rule is empty.  This ensures that there is room
1580
      ** enough on the stack to push the LHS value */
1581
0
      if( yyRuleInfoNRhs[yyruleno]==0 ){
1582
#ifdef YYTRACKMAXSTACKDEPTH
1583
        if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
1584
          yypParser->yyhwm++;
1585
          assert( yypParser->yyhwm ==
1586
                  (int)(yypParser->yytos - yypParser->yystack));
1587
        }
1588
#endif
1589
0
#if YYSTACKDEPTH>0
1590
0
        if( yypParser->yytos>=yypParser->yystackEnd ){
1591
0
          yyStackOverflow(yypParser);
1592
0
          break;
1593
0
        }
1594
#else
1595
        if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
1596
          if( yyGrowStack(yypParser) ){
1597
            yyStackOverflow(yypParser);
1598
            break;
1599
          }
1600
        }
1601
#endif
1602
0
      }
1603
0
      yyact = yy_reduce(yypParser,yyruleno,yymajor,yyminor DtdParseCTX_PARAM);
1604
0
    }else if( yyact <= YY_MAX_SHIFTREDUCE ){
1605
0
      yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor);
1606
0
#ifndef YYNOERRORRECOVERY
1607
0
      yypParser->yyerrcnt--;
1608
0
#endif
1609
0
      break;
1610
0
    }else if( yyact==YY_ACCEPT_ACTION ){
1611
0
      yypParser->yytos--;
1612
0
      yy_accept(yypParser);
1613
0
      return;
1614
0
    }else{
1615
0
      assert( yyact == YY_ERROR_ACTION );
1616
0
      yyminorunion.yy0 = yyminor;
1617
#ifdef YYERRORSYMBOL
1618
      int yymx;
1619
#endif
1620
#ifndef NDEBUG
1621
      if( yyTraceFILE ){
1622
        fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
1623
      }
1624
#endif
1625
#ifdef YYERRORSYMBOL
1626
      /* A syntax error has occurred.
1627
      ** The response to an error depends upon whether or not the
1628
      ** grammar defines an error token "ERROR".
1629
      **
1630
      ** This is what we do if the grammar does define ERROR:
1631
      **
1632
      **  * Call the %syntax_error function.
1633
      **
1634
      **  * Begin popping the stack until we enter a state where
1635
      **    it is legal to shift the error symbol, then shift
1636
      **    the error symbol.
1637
      **
1638
      **  * Set the error count to three.
1639
      **
1640
      **  * Begin accepting and shifting new tokens.  No new error
1641
      **    processing will occur until three tokens have been
1642
      **    shifted successfully.
1643
      **
1644
      */
1645
      if( yypParser->yyerrcnt<0 ){
1646
        yy_syntax_error(yypParser,yymajor,yyminor);
1647
      }
1648
      yymx = yypParser->yytos->major;
1649
      if( yymx==YYERRORSYMBOL || yyerrorhit ){
1650
#ifndef NDEBUG
1651
        if( yyTraceFILE ){
1652
          fprintf(yyTraceFILE,"%sDiscard input token %s\n",
1653
             yyTracePrompt,yyTokenName[yymajor]);
1654
        }
1655
#endif
1656
        yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
1657
        yymajor = YYNOCODE;
1658
      }else{
1659
        while( yypParser->yytos > yypParser->yystack ){
1660
          yyact = yy_find_reduce_action(yypParser->yytos->stateno,
1661
                                        YYERRORSYMBOL);
1662
          if( yyact<=YY_MAX_SHIFTREDUCE ) break;
1663
          yy_pop_parser_stack(yypParser);
1664
        }
1665
        if( yypParser->yytos <= yypParser->yystack || yymajor==0 ){
1666
          yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
1667
          yy_parse_failed(yypParser);
1668
#ifndef YYNOERRORRECOVERY
1669
          yypParser->yyerrcnt = -1;
1670
#endif
1671
          yymajor = YYNOCODE;
1672
        }else if( yymx!=YYERRORSYMBOL ){
1673
          yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor);
1674
        }
1675
      }
1676
      yypParser->yyerrcnt = 3;
1677
      yyerrorhit = 1;
1678
      if( yymajor==YYNOCODE ) break;
1679
      yyact = yypParser->yytos->stateno;
1680
#elif defined(YYNOERRORRECOVERY)
1681
      /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
1682
      ** do any kind of error recovery.  Instead, simply invoke the syntax
1683
      ** error routine and continue going as if nothing had happened.
1684
      **
1685
      ** Applications can set this macro (for example inside %include) if
1686
      ** they intend to abandon the parse upon the first syntax error seen.
1687
      */
1688
      yy_syntax_error(yypParser,yymajor, yyminor);
1689
      yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
1690
      break;
1691
#else  /* YYERRORSYMBOL is not defined */
1692
      /* This is what we do if the grammar does not define ERROR:
1693
      **
1694
      **  * Report an error message, and throw away the input token.
1695
      **
1696
      **  * If the input token is $, then fail the parse.
1697
      **
1698
      ** As before, subsequent error messages are suppressed until
1699
      ** three input tokens have been successfully shifted.
1700
      */
1701
0
      if( yypParser->yyerrcnt<=0 ){
1702
0
        yy_syntax_error(yypParser,yymajor, yyminor);
1703
0
      }
1704
0
      yypParser->yyerrcnt = 3;
1705
0
      yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
1706
0
      if( yyendofinput ){
1707
0
        yy_parse_failed(yypParser);
1708
0
#ifndef YYNOERRORRECOVERY
1709
0
        yypParser->yyerrcnt = -1;
1710
0
#endif
1711
0
      }
1712
0
      break;
1713
0
#endif
1714
0
    }
1715
0
  }
1716
#ifndef NDEBUG
1717
  if( yyTraceFILE ){
1718
    yyStackEntry *i;
1719
    char cDiv = '[';
1720
    fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt);
1721
    for(i=&yypParser->yystack[1]; i<=yypParser->yytos; i++){
1722
      fprintf(yyTraceFILE,"%c%s", cDiv, yyTokenName[i->major]);
1723
      cDiv = ' ';
1724
    }
1725
    fprintf(yyTraceFILE,"]\n");
1726
  }
1727
#endif
1728
0
  return;
1729
0
}
1730
1731
/*
1732
** Return the fallback token corresponding to canonical token iToken, or
1733
** 0 if iToken has no fallback.
1734
*/
1735
0
int DtdParseFallback(int iToken){
1736
#ifdef YYFALLBACK
1737
  assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) );
1738
  return yyFallback[iToken];
1739
#else
1740
0
  (void)iToken;
1741
0
  return 0;
1742
0
#endif
1743
0
}
1744
#line 48 "/src/wireshark/epan/dtd_grammar.lemon"
1745
1746
DIAG_ON_LEMON()
1747
#line 1772 "./dtd_grammar.c"