Coverage Report

Created: 2025-02-15 06:25

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