Coverage Report

Created: 2025-08-04 07:15

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