/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 | | #include "config.h" |
15 | | #include <assert.h> |
16 | | #include <string.h> |
17 | | #include <wireshark.h> |
18 | | #include <wiretap/file_wrappers.h> |
19 | | #include <wsutil/array.h> |
20 | | #include "busmaster_priv.h" |
21 | | |
22 | | extern void *BusmasterParserAlloc(void *(*mallocProc)(size_t)); |
23 | | extern void BusmasterParser(void *yyp, int yymajor, token_t yyminor, busmaster_state_t *state); |
24 | | extern void BusmasterParserFree(void *p, void (*freeProc)(void*)); |
25 | | |
26 | | #if defined(BUSMASTER_DEBUG) || defined(BUSMASTER_PARSER_TRACE) |
27 | | extern void BusmasterParserTrace(FILE *TraceFILE, char *zTracePrompt); |
28 | | #undef NDEBUG |
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 "./busmaster_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_INVALID_CHAR |
44 | | #define TOKEN_INVALID_CHAR 1 |
45 | | #define TOKEN_INVALID_NUMBER 2 |
46 | | #define TOKEN_ENDL 3 |
47 | | #define TOKEN_PROTOCOL_TYPE 4 |
48 | | #define TOKEN_START_SESSION 5 |
49 | | #define TOKEN_DATA_MODE 6 |
50 | | #define TOKEN_TIME_MODE 7 |
51 | | #define TOKEN_HEADER_VER 8 |
52 | | #define TOKEN_HEADER_CHAR 9 |
53 | | #define TOKEN_START_TIME 10 |
54 | | #define TOKEN_STOP_SESSION 11 |
55 | | #define TOKEN_END_TIME 12 |
56 | | #define TOKEN_MSG_DIR 13 |
57 | | #define TOKEN_INT 14 |
58 | | #define TOKEN_J1939_MSG_TYPE 15 |
59 | | #define TOKEN_COLON 16 |
60 | | #define TOKEN_MSG_TIME 17 |
61 | | #define TOKEN_MSG_TYPE 18 |
62 | | #define TOKEN_ERR_MSG_TYPE 19 |
63 | | #endif |
64 | | /**************** End token definitions ***************************************/ |
65 | | |
66 | | /* The next sections is a series of control #defines. |
67 | | ** various aspects of the generated parser. |
68 | | ** YYCODETYPE is the data type used to store the integer codes |
69 | | ** that represent terminal and non-terminal symbols. |
70 | | ** "unsigned char" is used if there are fewer than |
71 | | ** 256 symbols. Larger types otherwise. |
72 | | ** YYNOCODE is a number of type YYCODETYPE that is not used for |
73 | | ** any terminal or nonterminal symbol. |
74 | | ** YYFALLBACK If defined, this indicates that one or more tokens |
75 | | ** (also known as: "terminal symbols") have fall-back |
76 | | ** values which should be used if the original symbol |
77 | | ** would not parse. This permits keywords to sometimes |
78 | | ** be used as identifiers, for example. |
79 | | ** YYACTIONTYPE is the data type used for "action codes" - numbers |
80 | | ** that indicate what to do in response to the next |
81 | | ** token. |
82 | | ** BusmasterParserTOKENTYPE is the data type used for minor type for terminal |
83 | | ** symbols. Background: A "minor type" is a semantic |
84 | | ** value associated with a terminal or non-terminal |
85 | | ** symbols. For example, for an "ID" terminal symbol, |
86 | | ** the minor type might be the name of the identifier. |
87 | | ** Each non-terminal can have a different minor type. |
88 | | ** Terminal symbols all have the same minor type, though. |
89 | | ** This macros defines the minor type for terminal |
90 | | ** symbols. |
91 | | ** YYMINORTYPE is the data type used for all minor types. |
92 | | ** This is typically a union of many types, one of |
93 | | ** which is BusmasterParserTOKENTYPE. The entry in the union |
94 | | ** for terminal symbols is called "yy0". |
95 | | ** YYSTACKDEPTH is the maximum depth of the parser's stack. If |
96 | | ** zero the stack is dynamically sized using realloc() |
97 | | ** BusmasterParserARG_SDECL A static variable declaration for the %extra_argument |
98 | | ** BusmasterParserARG_PDECL A parameter declaration for the %extra_argument |
99 | | ** BusmasterParserARG_PARAM Code to pass %extra_argument as a subroutine parameter |
100 | | ** BusmasterParserARG_STORE Code to store %extra_argument into yypParser |
101 | | ** BusmasterParserARG_FETCH Code to extract %extra_argument from yypParser |
102 | | ** BusmasterParserCTX_* As BusmasterParserARG_ except for %extra_context |
103 | | ** YYERRORSYMBOL is the code number of the error symbol. If not |
104 | | ** defined, then do no error processing. |
105 | | ** YYNSTATE the combined number of states. |
106 | | ** YYNRULE the number of rules in the grammar |
107 | | ** YYNTOKEN Number of terminal symbols |
108 | | ** YY_MAX_SHIFT Maximum value for shift actions |
109 | | ** YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions |
110 | | ** YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions |
111 | | ** YY_ERROR_ACTION The yy_action[] code for syntax error |
112 | | ** YY_ACCEPT_ACTION The yy_action[] code for accept |
113 | | ** YY_NO_ACTION The yy_action[] code for no-op |
114 | | ** YY_MIN_REDUCE Minimum value for reduce actions |
115 | | ** YY_MAX_REDUCE Maximum value for reduce actions |
116 | | */ |
117 | | #ifndef INTERFACE |
118 | | # define INTERFACE 1 |
119 | | #endif |
120 | | /************* Begin control #defines *****************************************/ |
121 | | #define YYCODETYPE unsigned char |
122 | | #define YYNOCODE 59 |
123 | 0 | #define YYACTIONTYPE unsigned char |
124 | | #define BusmasterParserTOKENTYPE token_t |
125 | | typedef union { |
126 | | int yyinit; |
127 | | BusmasterParserTOKENTYPE yy0; |
128 | | unsigned yy18; |
129 | | msg_type_t yy32; |
130 | | msg_data_t yy48; |
131 | | uint8_t yy54; |
132 | | msg_time_t yy63; |
133 | | uint32_t yy64; |
134 | | msg_date_t yy74; |
135 | | msg_date_time_t yy80; |
136 | | } YYMINORTYPE; |
137 | | #ifndef YYSTACKDEPTH |
138 | 0 | #define YYSTACKDEPTH 100 |
139 | | #endif |
140 | | #define BusmasterParserARG_SDECL busmaster_state_t* state ; |
141 | | #define BusmasterParserARG_PDECL , busmaster_state_t* state |
142 | | #define BusmasterParserARG_PARAM ,state |
143 | 0 | #define BusmasterParserARG_FETCH busmaster_state_t* state =yypParser->state ; |
144 | 0 | #define BusmasterParserARG_STORE yypParser->state =state ; |
145 | | #define BusmasterParserCTX_SDECL |
146 | | #define BusmasterParserCTX_PDECL |
147 | | #define BusmasterParserCTX_PARAM |
148 | | #define BusmasterParserCTX_FETCH |
149 | | #define BusmasterParserCTX_STORE |
150 | | #define YYNSTATE 78 |
151 | | #define YYNRULE 64 |
152 | | #define YYNRULE_WITH_ACTION 48 |
153 | | #define YYNTOKEN 20 |
154 | 0 | #define YY_MAX_SHIFT 77 |
155 | 0 | #define YY_MIN_SHIFTREDUCE 117 |
156 | 0 | #define YY_MAX_SHIFTREDUCE 180 |
157 | | #define YY_ERROR_ACTION 181 |
158 | 0 | #define YY_ACCEPT_ACTION 182 |
159 | | #define YY_NO_ACTION 183 |
160 | 0 | #define YY_MIN_REDUCE 184 |
161 | | #define YY_MAX_REDUCE 247 |
162 | | /************* End control #defines *******************************************/ |
163 | | #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) |
164 | | |
165 | | /* Define the yytestcase() macro to be a no-op if is not already defined |
166 | | ** otherwise. |
167 | | ** |
168 | | ** Applications can choose to define yytestcase() in the %include section |
169 | | ** to a macro that can assist in verifying code coverage. For production |
170 | | ** code the yytestcase() macro should be turned off. But it is useful |
171 | | ** for testing. |
172 | | */ |
173 | | #ifndef yytestcase |
174 | | # define yytestcase(X) |
175 | | #endif |
176 | | |
177 | | |
178 | | /* Next are the tables used to determine what action to take based on the |
179 | | ** current state and lookahead token. These tables are used to implement |
180 | | ** functions that take a state number and lookahead value and return an |
181 | | ** action integer. |
182 | | ** |
183 | | ** Suppose the action integer is N. Then the action is determined as |
184 | | ** follows |
185 | | ** |
186 | | ** 0 <= N <= YY_MAX_SHIFT Shift N. That is, push the lookahead |
187 | | ** token onto the stack and goto state N. |
188 | | ** |
189 | | ** N between YY_MIN_SHIFTREDUCE Shift to an arbitrary state then |
190 | | ** and YY_MAX_SHIFTREDUCE reduce by rule N-YY_MIN_SHIFTREDUCE. |
191 | | ** |
192 | | ** N == YY_ERROR_ACTION A syntax error has occurred. |
193 | | ** |
194 | | ** N == YY_ACCEPT_ACTION The parser accepts its input. |
195 | | ** |
196 | | ** N == YY_NO_ACTION No such action. Denotes unused |
197 | | ** slots in the yy_action[] table. |
198 | | ** |
199 | | ** N between YY_MIN_REDUCE Reduce by rule N-YY_MIN_REDUCE |
200 | | ** and YY_MAX_REDUCE |
201 | | ** |
202 | | ** The action table is constructed as a single large table named yy_action[]. |
203 | | ** Given state S and lookahead X, the action is computed as either: |
204 | | ** |
205 | | ** (A) N = yy_action[ yy_shift_ofst[S] + X ] |
206 | | ** (B) N = yy_default[S] |
207 | | ** |
208 | | ** The (A) formula is preferred. The B formula is used instead if |
209 | | ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X. |
210 | | ** |
211 | | ** The formulas above are for computing the action when the lookahead is |
212 | | ** a terminal symbol. If the lookahead is a non-terminal (as occurs after |
213 | | ** a reduce action) then the yy_reduce_ofst[] array is used in place of |
214 | | ** the yy_shift_ofst[] array. |
215 | | ** |
216 | | ** The following are the tables generated in this section: |
217 | | ** |
218 | | ** yy_action[] A single table containing all actions. |
219 | | ** yy_lookahead[] A table containing the lookahead for each entry in |
220 | | ** yy_action. Used to detect hash collisions. |
221 | | ** yy_shift_ofst[] For each state, the offset into yy_action for |
222 | | ** shifting terminals. |
223 | | ** yy_reduce_ofst[] For each state, the offset into yy_action for |
224 | | ** shifting non-terminals after a reduce. |
225 | | ** yy_default[] Default action for each state. |
226 | | ** |
227 | | *********** Begin parsing tables **********************************************/ |
228 | | #define YY_ACTTAB_COUNT (158) |
229 | | static const YYACTIONTYPE yy_action[] = { |
230 | | /* 0 */ 23, 191, 199, 200, 201, 202, 4, 204, 205, 206, |
231 | | /* 10 */ 9, 208, 6, 210, 211, 3, 213, 214, 23, 189, |
232 | | /* 20 */ 199, 200, 201, 202, 4, 204, 205, 206, 9, 208, |
233 | | /* 30 */ 6, 210, 211, 3, 213, 214, 42, 20, 20, 20, |
234 | | /* 40 */ 52, 16, 35, 10, 10, 224, 28, 7, 226, 5, |
235 | | /* 50 */ 23, 127, 231, 221, 222, 223, 224, 71, 235, 148, |
236 | | /* 60 */ 30, 14, 182, 77, 76, 75, 45, 57, 56, 55, |
237 | | /* 70 */ 74, 20, 20, 35, 54, 185, 129, 12, 10, 20, |
238 | | /* 80 */ 74, 226, 7, 1, 229, 11, 176, 43, 179, 8, |
239 | | /* 90 */ 128, 229, 174, 51, 178, 190, 131, 130, 220, 18, |
240 | | /* 100 */ 19, 2, 21, 22, 17, 24, 25, 68, 62, 69, |
241 | | /* 110 */ 43, 70, 247, 27, 72, 187, 29, 73, 58, 44, |
242 | | /* 120 */ 15, 31, 32, 13, 46, 47, 48, 53, 238, 49, |
243 | | /* 130 */ 50, 26, 121, 237, 236, 33, 34, 125, 174, 183, |
244 | | /* 140 */ 60, 59, 36, 61, 126, 37, 64, 63, 38, 39, |
245 | | /* 150 */ 66, 65, 40, 67, 41, 234, 233, 232, |
246 | | }; |
247 | | static const YYCODETYPE yy_lookahead[] = { |
248 | | /* 0 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, |
249 | | /* 10 */ 38, 39, 40, 41, 42, 43, 44, 45, 28, 29, |
250 | | /* 20 */ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, |
251 | | /* 30 */ 40, 41, 42, 43, 44, 45, 20, 28, 28, 28, |
252 | | /* 40 */ 13, 14, 8, 34, 34, 34, 12, 38, 38, 40, |
253 | | /* 50 */ 28, 17, 43, 31, 32, 33, 34, 27, 0, 14, |
254 | | /* 60 */ 10, 3, 46, 47, 48, 49, 50, 51, 52, 53, |
255 | | /* 70 */ 54, 28, 28, 8, 58, 49, 14, 34, 34, 28, |
256 | | /* 80 */ 54, 38, 38, 23, 40, 34, 3, 57, 3, 38, |
257 | | /* 90 */ 14, 40, 9, 24, 9, 22, 19, 18, 28, 28, |
258 | | /* 100 */ 28, 23, 28, 28, 14, 21, 24, 14, 14, 7, |
259 | | /* 110 */ 57, 6, 26, 25, 5, 26, 25, 4, 57, 56, |
260 | | /* 120 */ 13, 55, 55, 55, 14, 14, 14, 3, 0, 15, |
261 | | /* 130 */ 14, 14, 11, 0, 0, 55, 55, 14, 9, 59, |
262 | | /* 140 */ 14, 16, 3, 16, 14, 3, 14, 16, 3, 3, |
263 | | /* 150 */ 14, 16, 3, 16, 3, 0, 0, 0, 59, 59, |
264 | | /* 160 */ 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, |
265 | | /* 170 */ 59, 59, 59, 59, 59, 59, 59, 59, |
266 | | }; |
267 | | #define YY_SHIFT_COUNT (77) |
268 | | #define YY_SHIFT_MIN (0) |
269 | | #define YY_SHIFT_MAX (157) |
270 | | static const unsigned char yy_shift_ofst[] = { |
271 | | /* 0 */ 34, 45, 45, 45, 45, 45, 45, 45, 45, 45, |
272 | | /* 10 */ 45, 45, 45, 50, 65, 62, 76, 77, 45, 45, |
273 | | /* 20 */ 45, 45, 45, 45, 62, 79, 90, 93, 94, 93, |
274 | | /* 30 */ 94, 102, 105, 109, 113, 158, 158, 158, 158, 158, |
275 | | /* 40 */ 158, 158, 27, 83, 85, 58, 107, 110, 111, 112, |
276 | | /* 50 */ 114, 116, 117, 121, 124, 128, 133, 134, 129, 123, |
277 | | /* 60 */ 125, 126, 127, 130, 131, 132, 135, 136, 137, 139, |
278 | | /* 70 */ 142, 145, 146, 149, 151, 155, 156, 157, |
279 | | }; |
280 | | #define YY_REDUCE_COUNT (41) |
281 | | #define YY_REDUCE_MIN (-28) |
282 | | #define YY_REDUCE_MAX (91) |
283 | | static const signed char yy_reduce_ofst[] = { |
284 | | /* 0 */ 16, -28, -10, 9, 22, 44, 51, 10, 10, 43, |
285 | | /* 10 */ 11, 11, 11, 30, 26, 60, 69, 73, 70, 71, |
286 | | /* 20 */ 72, 70, 74, 75, 78, 84, 82, 86, 88, 89, |
287 | | /* 30 */ 91, 53, 53, 53, 53, 61, 63, 66, 67, 68, |
288 | | /* 40 */ 80, 81, |
289 | | }; |
290 | | static const YYACTIONTYPE yy_default[] = { |
291 | | /* 0 */ 184, 216, 216, 212, 203, 230, 209, 181, 228, 207, |
292 | | /* 10 */ 181, 227, 225, 240, 181, 181, 181, 195, 181, 181, |
293 | | /* 20 */ 181, 219, 218, 217, 181, 181, 181, 181, 181, 181, |
294 | | /* 30 */ 181, 240, 240, 240, 240, 240, 244, 242, 242, 242, |
295 | | /* 40 */ 242, 242, 181, 181, 186, 181, 181, 181, 181, 181, |
296 | | /* 50 */ 181, 181, 181, 181, 181, 181, 181, 181, 239, 181, |
297 | | /* 60 */ 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, |
298 | | /* 70 */ 181, 181, 181, 181, 181, 181, 181, 181, |
299 | | }; |
300 | | /********** End of lemon-generated parsing tables *****************************/ |
301 | | |
302 | | /* The next table maps tokens (terminal symbols) into fallback tokens. |
303 | | ** If a construct like the following: |
304 | | ** |
305 | | ** %fallback ID X Y Z. |
306 | | ** |
307 | | ** appears in the grammar, then ID becomes a fallback token for X, Y, |
308 | | ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser |
309 | | ** but it does not parse, the type of the token is changed to ID and |
310 | | ** the parse is retried before an error is thrown. |
311 | | ** |
312 | | ** This feature can be used, for example, to cause some keywords in a language |
313 | | ** to revert to identifiers if they keyword does not apply in the context where |
314 | | ** it appears. |
315 | | */ |
316 | | #ifdef YYFALLBACK |
317 | | static const YYCODETYPE yyFallback[] = { |
318 | | }; |
319 | | #endif /* YYFALLBACK */ |
320 | | |
321 | | /* The following structure represents a single element of the |
322 | | ** parser's stack. Information stored includes: |
323 | | ** |
324 | | ** + The state number for the parser at this level of the stack. |
325 | | ** |
326 | | ** + The value of the token stored at this level of the stack. |
327 | | ** (In other words, the "major" token.) |
328 | | ** |
329 | | ** + The semantic value stored at this level of the stack. This is |
330 | | ** the information used by the action routines in the grammar. |
331 | | ** It is sometimes called the "minor" token. |
332 | | ** |
333 | | ** After the "shift" half of a SHIFTREDUCE action, the stateno field |
334 | | ** actually contains the reduce action for the second half of the |
335 | | ** SHIFTREDUCE. |
336 | | */ |
337 | | struct yyStackEntry { |
338 | | YYACTIONTYPE stateno; /* The state-number, or reduce action in SHIFTREDUCE */ |
339 | | YYCODETYPE major; /* The major token value. This is the code |
340 | | ** number for the token at this stack level */ |
341 | | YYMINORTYPE minor; /* The user-supplied minor token value. This |
342 | | ** is the value of the token */ |
343 | | }; |
344 | | typedef struct yyStackEntry yyStackEntry; |
345 | | |
346 | | /* The state of the parser is completely contained in an instance of |
347 | | ** the following structure */ |
348 | | struct yyParser { |
349 | | yyStackEntry *yytos; /* Pointer to top element of the stack */ |
350 | | #ifdef YYTRACKMAXSTACKDEPTH |
351 | | int yyhwm; /* High-water mark of the stack */ |
352 | | #endif |
353 | | #ifndef YYNOERRORRECOVERY |
354 | | int yyerrcnt; /* Shifts left before out of the error */ |
355 | | #endif |
356 | | BusmasterParserARG_SDECL /* A place to hold %extra_argument */ |
357 | | BusmasterParserCTX_SDECL /* A place to hold %extra_context */ |
358 | | #if YYSTACKDEPTH<=0 |
359 | | int yystksz; /* Current side of the stack */ |
360 | | yyStackEntry *yystack; /* The parser's stack */ |
361 | | yyStackEntry yystk0; /* First stack entry */ |
362 | | #else |
363 | | yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ |
364 | | yyStackEntry *yystackEnd; /* Last entry in the stack */ |
365 | | #endif |
366 | | }; |
367 | | typedef struct yyParser yyParser; |
368 | | |
369 | | #include <assert.h> |
370 | | #ifndef NDEBUG |
371 | | #include <stdio.h> |
372 | | static FILE *yyTraceFILE = 0; |
373 | | static char *yyTracePrompt = 0; |
374 | | #endif /* NDEBUG */ |
375 | | |
376 | | #ifndef NDEBUG |
377 | | /* |
378 | | ** Turn parser tracing on by giving a stream to which to write the trace |
379 | | ** and a prompt to preface each trace message. Tracing is turned off |
380 | | ** by making either argument NULL |
381 | | ** |
382 | | ** Inputs: |
383 | | ** <ul> |
384 | | ** <li> A FILE* to which trace output should be written. |
385 | | ** If NULL, then tracing is turned off. |
386 | | ** <li> A prefix string written at the beginning of every |
387 | | ** line of trace output. If NULL, then tracing is |
388 | | ** turned off. |
389 | | ** </ul> |
390 | | ** |
391 | | ** Outputs: |
392 | | ** None. |
393 | | */ |
394 | | void BusmasterParserTrace(FILE *TraceFILE, char *zTracePrompt){ |
395 | | yyTraceFILE = TraceFILE; |
396 | | yyTracePrompt = zTracePrompt; |
397 | | if( yyTraceFILE==0 ) yyTracePrompt = 0; |
398 | | else if( yyTracePrompt==0 ) yyTraceFILE = 0; |
399 | | } |
400 | | #endif /* NDEBUG */ |
401 | | |
402 | | #if defined(YYCOVERAGE) || !defined(NDEBUG) |
403 | | /* For tracing shifts, the names of all terminals and nonterminals |
404 | | ** are required. The following table supplies these names */ |
405 | | static const char *const yyTokenName[] = { |
406 | | /* 0 */ "$", |
407 | | /* 1 */ "INVALID_CHAR", |
408 | | /* 2 */ "INVALID_NUMBER", |
409 | | /* 3 */ "ENDL", |
410 | | /* 4 */ "PROTOCOL_TYPE", |
411 | | /* 5 */ "START_SESSION", |
412 | | /* 6 */ "DATA_MODE", |
413 | | /* 7 */ "TIME_MODE", |
414 | | /* 8 */ "HEADER_VER", |
415 | | /* 9 */ "HEADER_CHAR", |
416 | | /* 10 */ "START_TIME", |
417 | | /* 11 */ "STOP_SESSION", |
418 | | /* 12 */ "END_TIME", |
419 | | /* 13 */ "MSG_DIR", |
420 | | /* 14 */ "INT", |
421 | | /* 15 */ "J1939_MSG_TYPE", |
422 | | /* 16 */ "COLON", |
423 | | /* 17 */ "MSG_TIME", |
424 | | /* 18 */ "MSG_TYPE", |
425 | | /* 19 */ "ERR_MSG_TYPE", |
426 | | /* 20 */ "msg_time", |
427 | | /* 21 */ "msg_type", |
428 | | /* 22 */ "err_msg_type", |
429 | | /* 23 */ "msg_length", |
430 | | /* 24 */ "msg_id", |
431 | | /* 25 */ "ref_date", |
432 | | /* 26 */ "ref_time", |
433 | | /* 27 */ "start_time", |
434 | | /* 28 */ "byte", |
435 | | /* 29 */ "data", |
436 | | /* 30 */ "data0", |
437 | | /* 31 */ "data1", |
438 | | /* 32 */ "data2", |
439 | | /* 33 */ "data3", |
440 | | /* 34 */ "data4", |
441 | | /* 35 */ "data5", |
442 | | /* 36 */ "data6", |
443 | | /* 37 */ "data7", |
444 | | /* 38 */ "data8", |
445 | | /* 39 */ "data12", |
446 | | /* 40 */ "data16", |
447 | | /* 41 */ "data20", |
448 | | /* 42 */ "data24", |
449 | | /* 43 */ "data32", |
450 | | /* 44 */ "data48", |
451 | | /* 45 */ "data64", |
452 | | /* 46 */ "entry", |
453 | | /* 47 */ "empty_line", |
454 | | /* 48 */ "footer_and_header", |
455 | | /* 49 */ "header", |
456 | | /* 50 */ "footer", |
457 | | /* 51 */ "msg", |
458 | | /* 52 */ "err_msg", |
459 | | /* 53 */ "j1939_msg", |
460 | | /* 54 */ "version", |
461 | | /* 55 */ "maybe_lines", |
462 | | /* 56 */ "anything", |
463 | | /* 57 */ "maybe_chars", |
464 | | /* 58 */ "end_time", |
465 | | }; |
466 | | #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ |
467 | | |
468 | | #ifndef NDEBUG |
469 | | /* For tracing reduce actions, the names of all rules are required. |
470 | | */ |
471 | | static const char *const yyRuleName[] = { |
472 | | /* 0 */ "empty_line ::=", |
473 | | /* 1 */ "footer_and_header ::= footer ENDL header", |
474 | | /* 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", |
475 | | /* 3 */ "start_time ::= START_TIME ref_date ref_time", |
476 | | /* 4 */ "footer ::= end_time ENDL STOP_SESSION", |
477 | | /* 5 */ "msg ::= msg_time MSG_DIR INT msg_id msg_type msg_length data", |
478 | | /* 6 */ "err_msg ::= msg_time MSG_DIR INT INT err_msg_type", |
479 | | /* 7 */ "j1939_msg ::= msg_time INT msg_id INT J1939_MSG_TYPE INT INT INT MSG_DIR msg_length data", |
480 | | /* 8 */ "ref_date ::= INT COLON INT COLON INT", |
481 | | /* 9 */ "ref_time ::= INT COLON INT COLON INT COLON INT", |
482 | | /* 10 */ "msg_time ::= MSG_TIME", |
483 | | /* 11 */ "msg_id ::= INT", |
484 | | /* 12 */ "msg_length ::= INT", |
485 | | /* 13 */ "msg_type ::= MSG_TYPE", |
486 | | /* 14 */ "err_msg_type ::= ERR_MSG_TYPE", |
487 | | /* 15 */ "data ::= data0", |
488 | | /* 16 */ "data ::= data1", |
489 | | /* 17 */ "data ::= data2", |
490 | | /* 18 */ "data ::= data3", |
491 | | /* 19 */ "data ::= data4", |
492 | | /* 20 */ "data ::= data5", |
493 | | /* 21 */ "data ::= data6", |
494 | | /* 22 */ "data ::= data7", |
495 | | /* 23 */ "data ::= data8", |
496 | | /* 24 */ "data ::= data12", |
497 | | /* 25 */ "data ::= data16", |
498 | | /* 26 */ "data ::= data20", |
499 | | /* 27 */ "data ::= data24", |
500 | | /* 28 */ "data ::= data32", |
501 | | /* 29 */ "data ::= data48", |
502 | | /* 30 */ "data ::= data64", |
503 | | /* 31 */ "byte ::= INT", |
504 | | /* 32 */ "data0 ::=", |
505 | | /* 33 */ "data1 ::= byte", |
506 | | /* 34 */ "data2 ::= byte byte", |
507 | | /* 35 */ "data3 ::= byte byte byte", |
508 | | /* 36 */ "data4 ::= byte byte byte byte", |
509 | | /* 37 */ "data5 ::= data4 data1", |
510 | | /* 38 */ "data6 ::= data4 data2", |
511 | | /* 39 */ "data7 ::= data4 data3", |
512 | | /* 40 */ "data8 ::= data4 data4", |
513 | | /* 41 */ "data12 ::= data8 data4", |
514 | | /* 42 */ "data16 ::= data8 data8", |
515 | | /* 43 */ "data20 ::= data16 data4", |
516 | | /* 44 */ "data24 ::= data16 data8", |
517 | | /* 45 */ "data32 ::= data16 data16", |
518 | | /* 46 */ "data48 ::= data32 data16", |
519 | | /* 47 */ "data64 ::= data32 data32", |
520 | | /* 48 */ "entry ::= empty_line", |
521 | | /* 49 */ "entry ::= footer_and_header", |
522 | | /* 50 */ "entry ::= header", |
523 | | /* 51 */ "entry ::= footer", |
524 | | /* 52 */ "entry ::= msg", |
525 | | /* 53 */ "entry ::= err_msg", |
526 | | /* 54 */ "entry ::= j1939_msg", |
527 | | /* 55 */ "version ::= HEADER_VER maybe_chars", |
528 | | /* 56 */ "maybe_chars ::=", |
529 | | /* 57 */ "maybe_chars ::= maybe_chars HEADER_CHAR", |
530 | | /* 58 */ "maybe_lines ::=", |
531 | | /* 59 */ "maybe_lines ::= maybe_lines maybe_chars ENDL", |
532 | | /* 60 */ "anything ::=", |
533 | | /* 61 */ "anything ::= anything HEADER_CHAR", |
534 | | /* 62 */ "anything ::= anything ENDL", |
535 | | /* 63 */ "end_time ::= END_TIME ref_date ref_time", |
536 | | }; |
537 | | #endif /* NDEBUG */ |
538 | | |
539 | | |
540 | | #if YYSTACKDEPTH<=0 |
541 | | /* |
542 | | ** Try to increase the size of the parser stack. Return the number |
543 | | ** of errors. Return 0 on success. |
544 | | */ |
545 | | static int yyGrowStack(yyParser *p){ |
546 | | int newSize; |
547 | | int idx; |
548 | | yyStackEntry *pNew; |
549 | | |
550 | | newSize = p->yystksz*2 + 100; |
551 | | idx = p->yytos ? (int)(p->yytos - p->yystack) : 0; |
552 | | if( p->yystack==&p->yystk0 ){ |
553 | | pNew = malloc(newSize*sizeof(pNew[0])); |
554 | | if( pNew ) pNew[0] = p->yystk0; |
555 | | }else{ |
556 | | pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); |
557 | | } |
558 | | if( pNew ){ |
559 | | p->yystack = pNew; |
560 | | p->yytos = &p->yystack[idx]; |
561 | | #ifndef NDEBUG |
562 | | if( yyTraceFILE ){ |
563 | | fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n", |
564 | | yyTracePrompt, p->yystksz, newSize); |
565 | | } |
566 | | #endif |
567 | | p->yystksz = newSize; |
568 | | } |
569 | | return pNew==0; |
570 | | } |
571 | | #endif |
572 | | |
573 | | /* Datatype of the argument to the memory allocated passed as the |
574 | | ** second argument to BusmasterParserAlloc() below. This can be changed by |
575 | | ** putting an appropriate #define in the %include section of the input |
576 | | ** grammar. |
577 | | */ |
578 | | #ifndef YYMALLOCARGTYPE |
579 | | # define YYMALLOCARGTYPE size_t |
580 | | #endif |
581 | | |
582 | | /* Initialize a new parser that has already been allocated. |
583 | | */ |
584 | 0 | void BusmasterParserInit(void *yypRawParser BusmasterParserCTX_PDECL){ |
585 | 0 | yyParser *yypParser = (yyParser*)yypRawParser; |
586 | 0 | BusmasterParserCTX_STORE |
587 | | #ifdef YYTRACKMAXSTACKDEPTH |
588 | | yypParser->yyhwm = 0; |
589 | | #endif |
590 | | #if YYSTACKDEPTH<=0 |
591 | | yypParser->yytos = NULL; |
592 | | yypParser->yystack = NULL; |
593 | | yypParser->yystksz = 0; |
594 | | if( yyGrowStack(yypParser) ){ |
595 | | yypParser->yystack = &yypParser->yystk0; |
596 | | yypParser->yystksz = 1; |
597 | | } |
598 | | #endif |
599 | 0 | #ifndef YYNOERRORRECOVERY |
600 | 0 | yypParser->yyerrcnt = -1; |
601 | 0 | #endif |
602 | 0 | yypParser->yytos = yypParser->yystack; |
603 | 0 | yypParser->yystack[0].stateno = 0; |
604 | 0 | yypParser->yystack[0].major = 0; |
605 | 0 | #if YYSTACKDEPTH>0 |
606 | 0 | yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1]; |
607 | 0 | #endif |
608 | 0 | } |
609 | | |
610 | | #ifndef BusmasterParser_ENGINEALWAYSONSTACK |
611 | | /* |
612 | | ** This function allocates a new parser. |
613 | | ** The only argument is a pointer to a function which works like |
614 | | ** malloc. |
615 | | ** |
616 | | ** Inputs: |
617 | | ** A pointer to the function used to allocate memory. |
618 | | ** |
619 | | ** Outputs: |
620 | | ** A pointer to a parser. This pointer is used in subsequent calls |
621 | | ** to BusmasterParser and BusmasterParserFree. |
622 | | */ |
623 | 0 | void *BusmasterParserAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) BusmasterParserCTX_PDECL){ |
624 | 0 | yyParser *yypParser; |
625 | 0 | yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); |
626 | 0 | if( yypParser ){ |
627 | 0 | BusmasterParserCTX_STORE |
628 | 0 | BusmasterParserInit(yypParser BusmasterParserCTX_PARAM); |
629 | 0 | } |
630 | 0 | return (void*)yypParser; |
631 | 0 | } |
632 | | #endif /* BusmasterParser_ENGINEALWAYSONSTACK */ |
633 | | |
634 | | |
635 | | /* The following function deletes the "minor type" or semantic value |
636 | | ** associated with a symbol. The symbol can be either a terminal |
637 | | ** or nonterminal. "yymajor" is the symbol code, and "yypminor" is |
638 | | ** a pointer to the value to be deleted. The code used to do the |
639 | | ** deletions is derived from the %destructor and/or %token_destructor |
640 | | ** directives of the input grammar. |
641 | | */ |
642 | | static void yy_destructor( |
643 | | yyParser *yypParser, /* The parser */ |
644 | | YYCODETYPE yymajor, /* Type code for object to destroy */ |
645 | | YYMINORTYPE *yypminor /* The object to be destroyed */ |
646 | 0 | ){ |
647 | 0 | BusmasterParserARG_FETCH |
648 | 0 | BusmasterParserCTX_FETCH |
649 | 0 | switch( yymajor ){ |
650 | | /* Here is inserted the actions which take place when a |
651 | | ** terminal or non-terminal is destroyed. This can happen |
652 | | ** when the symbol is popped from the stack during a |
653 | | ** reduce or during error processing or when a parser is |
654 | | ** being destroyed before it is finished parsing. |
655 | | ** |
656 | | ** Note: during a reduce, the only symbols destroyed are those |
657 | | ** which appear on the RHS of the rule, but which are *not* used |
658 | | ** inside the C code. |
659 | | */ |
660 | | /********* Begin destructor definitions ***************************************/ |
661 | | /* TERMINAL Destructor */ |
662 | 0 | case 1: /* INVALID_CHAR */ |
663 | 0 | case 2: /* INVALID_NUMBER */ |
664 | 0 | case 3: /* ENDL */ |
665 | 0 | case 4: /* PROTOCOL_TYPE */ |
666 | 0 | case 5: /* START_SESSION */ |
667 | 0 | case 6: /* DATA_MODE */ |
668 | 0 | case 7: /* TIME_MODE */ |
669 | 0 | case 8: /* HEADER_VER */ |
670 | 0 | case 9: /* HEADER_CHAR */ |
671 | 0 | case 10: /* START_TIME */ |
672 | 0 | case 11: /* STOP_SESSION */ |
673 | 0 | case 12: /* END_TIME */ |
674 | 0 | case 13: /* MSG_DIR */ |
675 | 0 | case 14: /* INT */ |
676 | 0 | case 15: /* J1939_MSG_TYPE */ |
677 | 0 | case 16: /* COLON */ |
678 | 0 | case 17: /* MSG_TIME */ |
679 | 0 | case 18: /* MSG_TYPE */ |
680 | 0 | case 19: /* ERR_MSG_TYPE */ |
681 | 0 | { |
682 | 0 | #line 52 "/src/wireshark/wiretap/busmaster_parser.lemon" |
683 | |
|
684 | 0 | (void)state; |
685 | 0 | (void)yypParser; |
686 | 0 | (void)yypminor; |
687 | |
|
688 | 0 | #line 713 "./busmaster_parser.c" |
689 | 0 | } |
690 | 0 | break; |
691 | | /********* End destructor definitions *****************************************/ |
692 | 0 | default: break; /* If no destructor action specified: do nothing */ |
693 | 0 | } |
694 | 0 | } |
695 | | |
696 | | /* |
697 | | ** Pop the parser's stack once. |
698 | | ** |
699 | | ** If there is a destructor routine associated with the token which |
700 | | ** is popped from the stack, then call it. |
701 | | */ |
702 | 0 | static void yy_pop_parser_stack(yyParser *pParser){ |
703 | 0 | yyStackEntry *yytos; |
704 | 0 | assert( pParser->yytos!=0 ); |
705 | 0 | assert( pParser->yytos > pParser->yystack ); |
706 | 0 | yytos = pParser->yytos--; |
707 | | #ifndef NDEBUG |
708 | | if( yyTraceFILE ){ |
709 | | fprintf(yyTraceFILE,"%sPopping %s\n", |
710 | | yyTracePrompt, |
711 | | yyTokenName[yytos->major]); |
712 | | } |
713 | | #endif |
714 | 0 | yy_destructor(pParser, yytos->major, &yytos->minor); |
715 | 0 | } |
716 | | |
717 | | /* |
718 | | ** Clear all secondary memory allocations from the parser |
719 | | */ |
720 | 0 | void BusmasterParserFinalize(void *p){ |
721 | 0 | yyParser *pParser = (yyParser*)p; |
722 | 0 | while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser); |
723 | | #if YYSTACKDEPTH<=0 |
724 | | if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack); |
725 | | #endif |
726 | 0 | } |
727 | | |
728 | | #ifndef BusmasterParser_ENGINEALWAYSONSTACK |
729 | | /* |
730 | | ** Deallocate and destroy a parser. Destructors are called for |
731 | | ** all stack elements before shutting the parser down. |
732 | | ** |
733 | | ** If the YYPARSEFREENEVERNULL macro exists (for example because it |
734 | | ** is defined in a %include section of the input grammar) then it is |
735 | | ** assumed that the input pointer is never NULL. |
736 | | */ |
737 | | void BusmasterParserFree( |
738 | | void *p, /* The parser to be deleted */ |
739 | | void (*freeProc)(void*) /* Function used to reclaim memory */ |
740 | 0 | ){ |
741 | 0 | #ifndef YYPARSEFREENEVERNULL |
742 | 0 | if( p==0 ) return; |
743 | 0 | #endif |
744 | 0 | BusmasterParserFinalize(p); |
745 | 0 | (*freeProc)(p); |
746 | 0 | } |
747 | | #endif /* BusmasterParser_ENGINEALWAYSONSTACK */ |
748 | | |
749 | | /* |
750 | | ** Return the peak depth of the stack for a parser. |
751 | | */ |
752 | | #ifdef YYTRACKMAXSTACKDEPTH |
753 | | int BusmasterParserStackPeak(void *p){ |
754 | | yyParser *pParser = (yyParser*)p; |
755 | | return pParser->yyhwm; |
756 | | } |
757 | | #endif |
758 | | |
759 | | /* This array of booleans keeps track of the parser statement |
760 | | ** coverage. The element yycoverage[X][Y] is set when the parser |
761 | | ** is in state X and has a lookahead token Y. In a well-tested |
762 | | ** systems, every element of this matrix should end up being set. |
763 | | */ |
764 | | #if defined(YYCOVERAGE) |
765 | | static unsigned char yycoverage[YYNSTATE][YYNTOKEN]; |
766 | | #endif |
767 | | |
768 | | /* |
769 | | ** Write into out a description of every state/lookahead combination that |
770 | | ** |
771 | | ** (1) has not been used by the parser, and |
772 | | ** (2) is not a syntax error. |
773 | | ** |
774 | | ** Return the number of missed state/lookahead combinations. |
775 | | */ |
776 | | #if defined(YYCOVERAGE) |
777 | | int BusmasterParserCoverage(FILE *out){ |
778 | | int stateno, iLookAhead, i; |
779 | | int nMissed = 0; |
780 | | for(stateno=0; stateno<YYNSTATE; stateno++){ |
781 | | i = yy_shift_ofst[stateno]; |
782 | | for(iLookAhead=0; iLookAhead<YYNTOKEN; iLookAhead++){ |
783 | | if( yy_lookahead[i+iLookAhead]!=iLookAhead ) continue; |
784 | | if( yycoverage[stateno][iLookAhead]==0 ) nMissed++; |
785 | | if( out ){ |
786 | | fprintf(out,"State %d lookahead %s %s\n", stateno, |
787 | | yyTokenName[iLookAhead], |
788 | | yycoverage[stateno][iLookAhead] ? "ok" : "missed"); |
789 | | } |
790 | | } |
791 | | } |
792 | | return nMissed; |
793 | | } |
794 | | #endif |
795 | | |
796 | | /* |
797 | | ** Find the appropriate action for a parser given the terminal |
798 | | ** look-ahead token iLookAhead. |
799 | | */ |
800 | | static YYACTIONTYPE yy_find_shift_action( |
801 | | YYCODETYPE iLookAhead, /* The look-ahead token */ |
802 | | YYACTIONTYPE stateno /* Current state number */ |
803 | 0 | ){ |
804 | 0 | int i; |
805 | |
|
806 | 0 | if( stateno>YY_MAX_SHIFT ) return stateno; |
807 | 0 | assert( stateno <= YY_SHIFT_COUNT ); |
808 | | #if defined(YYCOVERAGE) |
809 | | yycoverage[stateno][iLookAhead] = 1; |
810 | | #endif |
811 | 0 | do{ |
812 | 0 | i = yy_shift_ofst[stateno]; |
813 | 0 | assert( i>=0 ); |
814 | 0 | assert( i<=YY_ACTTAB_COUNT ); |
815 | 0 | assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); |
816 | 0 | assert( iLookAhead!=YYNOCODE ); |
817 | 0 | assert( iLookAhead < YYNTOKEN ); |
818 | 0 | i += iLookAhead; |
819 | 0 | assert( i<(int)YY_NLOOKAHEAD ); |
820 | 0 | if( yy_lookahead[i]!=iLookAhead ){ |
821 | | #ifdef YYFALLBACK |
822 | | YYCODETYPE iFallback; /* Fallback token */ |
823 | | assert( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0]) ); |
824 | | iFallback = yyFallback[iLookAhead]; |
825 | | if( iFallback!=0 ){ |
826 | | #ifndef NDEBUG |
827 | | if( yyTraceFILE ){ |
828 | | fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n", |
829 | | yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); |
830 | | } |
831 | | #endif |
832 | | assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */ |
833 | | iLookAhead = iFallback; |
834 | | continue; |
835 | | } |
836 | | #endif |
837 | | #ifdef YYWILDCARD |
838 | | { |
839 | | int j = i - iLookAhead + YYWILDCARD; |
840 | | assert( j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) ); |
841 | | if( yy_lookahead[j]==YYWILDCARD && iLookAhead>0 ){ |
842 | | #ifndef NDEBUG |
843 | | if( yyTraceFILE ){ |
844 | | fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", |
845 | | yyTracePrompt, yyTokenName[iLookAhead], |
846 | | yyTokenName[YYWILDCARD]); |
847 | | } |
848 | | #endif /* NDEBUG */ |
849 | | return yy_action[j]; |
850 | | } |
851 | | } |
852 | | #endif /* YYWILDCARD */ |
853 | 0 | return yy_default[stateno]; |
854 | 0 | }else{ |
855 | 0 | assert( i>=0 && i<(int)(sizeof(yy_action)/sizeof(yy_action[0])) ); |
856 | 0 | return yy_action[i]; |
857 | 0 | } |
858 | 0 | }while(1); |
859 | 0 | } |
860 | | |
861 | | /* |
862 | | ** Find the appropriate action for a parser given the non-terminal |
863 | | ** look-ahead token iLookAhead. |
864 | | */ |
865 | | static YYACTIONTYPE yy_find_reduce_action( |
866 | | YYACTIONTYPE stateno, /* Current state number */ |
867 | | YYCODETYPE iLookAhead /* The look-ahead token */ |
868 | 0 | ){ |
869 | 0 | int i; |
870 | | #ifdef YYERRORSYMBOL |
871 | | if( stateno>YY_REDUCE_COUNT ){ |
872 | | return yy_default[stateno]; |
873 | | } |
874 | | #else |
875 | 0 | assert( stateno<=YY_REDUCE_COUNT ); |
876 | 0 | #endif |
877 | 0 | i = yy_reduce_ofst[stateno]; |
878 | 0 | assert( iLookAhead!=YYNOCODE ); |
879 | 0 | i += iLookAhead; |
880 | | #ifdef YYERRORSYMBOL |
881 | | if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ |
882 | | return yy_default[stateno]; |
883 | | } |
884 | | #else |
885 | 0 | assert( i>=0 && i<YY_ACTTAB_COUNT ); |
886 | 0 | assert( yy_lookahead[i]==iLookAhead ); |
887 | 0 | #endif |
888 | 0 | return yy_action[i]; |
889 | 0 | } |
890 | | |
891 | | /* |
892 | | ** The following routine is called if the stack overflows. |
893 | | */ |
894 | 0 | static void yyStackOverflow(yyParser *yypParser){ |
895 | 0 | BusmasterParserARG_FETCH |
896 | 0 | BusmasterParserCTX_FETCH |
897 | | #ifndef NDEBUG |
898 | | if( yyTraceFILE ){ |
899 | | fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); |
900 | | } |
901 | | #endif |
902 | 0 | while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser); |
903 | | /* Here code is inserted which will execute if the parser |
904 | | ** stack every overflows */ |
905 | | /******** Begin %stack_overflow code ******************************************/ |
906 | 0 | #line 91 "/src/wireshark/wiretap/busmaster_parser.lemon" |
907 | |
|
908 | 0 | g_free(state->parse_error); |
909 | 0 | state->entry_type = LOG_ENTRY_ERROR; |
910 | 0 | state->parse_error = g_strdup("Parser stack overflow"); |
911 | 0 | busmaster_debug_printf("%s: Parser stack overflow\n", G_STRFUNC); |
912 | 0 | #line 937 "./busmaster_parser.c" |
913 | | /******** End %stack_overflow code ********************************************/ |
914 | 0 | BusmasterParserARG_STORE /* Suppress warning about unused %extra_argument var */ |
915 | 0 | BusmasterParserCTX_STORE |
916 | 0 | } |
917 | | |
918 | | /* |
919 | | ** Print tracing information for a SHIFT action |
920 | | */ |
921 | | #ifndef NDEBUG |
922 | | static void yyTraceShift(yyParser *yypParser, int yyNewState, const char *zTag){ |
923 | | if( yyTraceFILE ){ |
924 | | if( yyNewState<YYNSTATE ){ |
925 | | fprintf(yyTraceFILE,"%s%s '%s', go to state %d\n", |
926 | | yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major], |
927 | | yyNewState); |
928 | | }else{ |
929 | | fprintf(yyTraceFILE,"%s%s '%s', pending reduce %d\n", |
930 | | yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major], |
931 | | yyNewState - YY_MIN_REDUCE); |
932 | | } |
933 | | } |
934 | | } |
935 | | #else |
936 | | # define yyTraceShift(X,Y,Z) |
937 | | #endif |
938 | | |
939 | | /* |
940 | | ** Perform a shift action. |
941 | | */ |
942 | | static void yy_shift( |
943 | | yyParser *yypParser, /* The parser to be shifted */ |
944 | | YYACTIONTYPE yyNewState, /* The new state to shift in */ |
945 | | YYCODETYPE yyMajor, /* The major token to shift in */ |
946 | | BusmasterParserTOKENTYPE yyMinor /* The minor token to shift in */ |
947 | 0 | ){ |
948 | 0 | yyStackEntry *yytos; |
949 | 0 | yypParser->yytos++; |
950 | | #ifdef YYTRACKMAXSTACKDEPTH |
951 | | if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){ |
952 | | yypParser->yyhwm++; |
953 | | assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) ); |
954 | | } |
955 | | #endif |
956 | 0 | #if YYSTACKDEPTH>0 |
957 | 0 | if( yypParser->yytos>yypParser->yystackEnd ){ |
958 | 0 | yypParser->yytos--; |
959 | 0 | yyStackOverflow(yypParser); |
960 | 0 | return; |
961 | 0 | } |
962 | | #else |
963 | | if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){ |
964 | | if( yyGrowStack(yypParser) ){ |
965 | | yypParser->yytos--; |
966 | | yyStackOverflow(yypParser); |
967 | | return; |
968 | | } |
969 | | } |
970 | | #endif |
971 | 0 | if( yyNewState > YY_MAX_SHIFT ){ |
972 | 0 | yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; |
973 | 0 | } |
974 | 0 | yytos = yypParser->yytos; |
975 | 0 | yytos->stateno = yyNewState; |
976 | 0 | yytos->major = yyMajor; |
977 | 0 | yytos->minor.yy0 = yyMinor; |
978 | 0 | yyTraceShift(yypParser, yyNewState, "Shift"); |
979 | 0 | } |
980 | | |
981 | | /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side |
982 | | ** of that rule */ |
983 | | static const YYCODETYPE yyRuleInfoLhs[] = { |
984 | | 47, /* (0) empty_line ::= */ |
985 | | 48, /* (1) footer_and_header ::= footer ENDL header */ |
986 | | 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 */ |
987 | | 27, /* (3) start_time ::= START_TIME ref_date ref_time */ |
988 | | 50, /* (4) footer ::= end_time ENDL STOP_SESSION */ |
989 | | 51, /* (5) msg ::= msg_time MSG_DIR INT msg_id msg_type msg_length data */ |
990 | | 52, /* (6) err_msg ::= msg_time MSG_DIR INT INT err_msg_type */ |
991 | | 53, /* (7) j1939_msg ::= msg_time INT msg_id INT J1939_MSG_TYPE INT INT INT MSG_DIR msg_length data */ |
992 | | 25, /* (8) ref_date ::= INT COLON INT COLON INT */ |
993 | | 26, /* (9) ref_time ::= INT COLON INT COLON INT COLON INT */ |
994 | | 20, /* (10) msg_time ::= MSG_TIME */ |
995 | | 24, /* (11) msg_id ::= INT */ |
996 | | 23, /* (12) msg_length ::= INT */ |
997 | | 21, /* (13) msg_type ::= MSG_TYPE */ |
998 | | 22, /* (14) err_msg_type ::= ERR_MSG_TYPE */ |
999 | | 29, /* (15) data ::= data0 */ |
1000 | | 29, /* (16) data ::= data1 */ |
1001 | | 29, /* (17) data ::= data2 */ |
1002 | | 29, /* (18) data ::= data3 */ |
1003 | | 29, /* (19) data ::= data4 */ |
1004 | | 29, /* (20) data ::= data5 */ |
1005 | | 29, /* (21) data ::= data6 */ |
1006 | | 29, /* (22) data ::= data7 */ |
1007 | | 29, /* (23) data ::= data8 */ |
1008 | | 29, /* (24) data ::= data12 */ |
1009 | | 29, /* (25) data ::= data16 */ |
1010 | | 29, /* (26) data ::= data20 */ |
1011 | | 29, /* (27) data ::= data24 */ |
1012 | | 29, /* (28) data ::= data32 */ |
1013 | | 29, /* (29) data ::= data48 */ |
1014 | | 29, /* (30) data ::= data64 */ |
1015 | | 28, /* (31) byte ::= INT */ |
1016 | | 30, /* (32) data0 ::= */ |
1017 | | 31, /* (33) data1 ::= byte */ |
1018 | | 32, /* (34) data2 ::= byte byte */ |
1019 | | 33, /* (35) data3 ::= byte byte byte */ |
1020 | | 34, /* (36) data4 ::= byte byte byte byte */ |
1021 | | 35, /* (37) data5 ::= data4 data1 */ |
1022 | | 36, /* (38) data6 ::= data4 data2 */ |
1023 | | 37, /* (39) data7 ::= data4 data3 */ |
1024 | | 38, /* (40) data8 ::= data4 data4 */ |
1025 | | 39, /* (41) data12 ::= data8 data4 */ |
1026 | | 40, /* (42) data16 ::= data8 data8 */ |
1027 | | 41, /* (43) data20 ::= data16 data4 */ |
1028 | | 42, /* (44) data24 ::= data16 data8 */ |
1029 | | 43, /* (45) data32 ::= data16 data16 */ |
1030 | | 44, /* (46) data48 ::= data32 data16 */ |
1031 | | 45, /* (47) data64 ::= data32 data32 */ |
1032 | | 46, /* (48) entry ::= empty_line */ |
1033 | | 46, /* (49) entry ::= footer_and_header */ |
1034 | | 46, /* (50) entry ::= header */ |
1035 | | 46, /* (51) entry ::= footer */ |
1036 | | 46, /* (52) entry ::= msg */ |
1037 | | 46, /* (53) entry ::= err_msg */ |
1038 | | 46, /* (54) entry ::= j1939_msg */ |
1039 | | 54, /* (55) version ::= HEADER_VER maybe_chars */ |
1040 | | 57, /* (56) maybe_chars ::= */ |
1041 | | 57, /* (57) maybe_chars ::= maybe_chars HEADER_CHAR */ |
1042 | | 55, /* (58) maybe_lines ::= */ |
1043 | | 55, /* (59) maybe_lines ::= maybe_lines maybe_chars ENDL */ |
1044 | | 56, /* (60) anything ::= */ |
1045 | | 56, /* (61) anything ::= anything HEADER_CHAR */ |
1046 | | 56, /* (62) anything ::= anything ENDL */ |
1047 | | 58, /* (63) end_time ::= END_TIME ref_date ref_time */ |
1048 | | }; |
1049 | | |
1050 | | /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number |
1051 | | ** of symbols on the right-hand side of that rule. */ |
1052 | | static const signed char yyRuleInfoNRhs[] = { |
1053 | | 0, /* (0) empty_line ::= */ |
1054 | | -3, /* (1) footer_and_header ::= footer ENDL header */ |
1055 | | -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 */ |
1056 | | -3, /* (3) start_time ::= START_TIME ref_date ref_time */ |
1057 | | -3, /* (4) footer ::= end_time ENDL STOP_SESSION */ |
1058 | | -7, /* (5) msg ::= msg_time MSG_DIR INT msg_id msg_type msg_length data */ |
1059 | | -5, /* (6) err_msg ::= msg_time MSG_DIR INT INT err_msg_type */ |
1060 | | -11, /* (7) j1939_msg ::= msg_time INT msg_id INT J1939_MSG_TYPE INT INT INT MSG_DIR msg_length data */ |
1061 | | -5, /* (8) ref_date ::= INT COLON INT COLON INT */ |
1062 | | -7, /* (9) ref_time ::= INT COLON INT COLON INT COLON INT */ |
1063 | | -1, /* (10) msg_time ::= MSG_TIME */ |
1064 | | -1, /* (11) msg_id ::= INT */ |
1065 | | -1, /* (12) msg_length ::= INT */ |
1066 | | -1, /* (13) msg_type ::= MSG_TYPE */ |
1067 | | -1, /* (14) err_msg_type ::= ERR_MSG_TYPE */ |
1068 | | -1, /* (15) data ::= data0 */ |
1069 | | -1, /* (16) data ::= data1 */ |
1070 | | -1, /* (17) data ::= data2 */ |
1071 | | -1, /* (18) data ::= data3 */ |
1072 | | -1, /* (19) data ::= data4 */ |
1073 | | -1, /* (20) data ::= data5 */ |
1074 | | -1, /* (21) data ::= data6 */ |
1075 | | -1, /* (22) data ::= data7 */ |
1076 | | -1, /* (23) data ::= data8 */ |
1077 | | -1, /* (24) data ::= data12 */ |
1078 | | -1, /* (25) data ::= data16 */ |
1079 | | -1, /* (26) data ::= data20 */ |
1080 | | -1, /* (27) data ::= data24 */ |
1081 | | -1, /* (28) data ::= data32 */ |
1082 | | -1, /* (29) data ::= data48 */ |
1083 | | -1, /* (30) data ::= data64 */ |
1084 | | -1, /* (31) byte ::= INT */ |
1085 | | 0, /* (32) data0 ::= */ |
1086 | | -1, /* (33) data1 ::= byte */ |
1087 | | -2, /* (34) data2 ::= byte byte */ |
1088 | | -3, /* (35) data3 ::= byte byte byte */ |
1089 | | -4, /* (36) data4 ::= byte byte byte byte */ |
1090 | | -2, /* (37) data5 ::= data4 data1 */ |
1091 | | -2, /* (38) data6 ::= data4 data2 */ |
1092 | | -2, /* (39) data7 ::= data4 data3 */ |
1093 | | -2, /* (40) data8 ::= data4 data4 */ |
1094 | | -2, /* (41) data12 ::= data8 data4 */ |
1095 | | -2, /* (42) data16 ::= data8 data8 */ |
1096 | | -2, /* (43) data20 ::= data16 data4 */ |
1097 | | -2, /* (44) data24 ::= data16 data8 */ |
1098 | | -2, /* (45) data32 ::= data16 data16 */ |
1099 | | -2, /* (46) data48 ::= data32 data16 */ |
1100 | | -2, /* (47) data64 ::= data32 data32 */ |
1101 | | -1, /* (48) entry ::= empty_line */ |
1102 | | -1, /* (49) entry ::= footer_and_header */ |
1103 | | -1, /* (50) entry ::= header */ |
1104 | | -1, /* (51) entry ::= footer */ |
1105 | | -1, /* (52) entry ::= msg */ |
1106 | | -1, /* (53) entry ::= err_msg */ |
1107 | | -1, /* (54) entry ::= j1939_msg */ |
1108 | | -2, /* (55) version ::= HEADER_VER maybe_chars */ |
1109 | | 0, /* (56) maybe_chars ::= */ |
1110 | | -2, /* (57) maybe_chars ::= maybe_chars HEADER_CHAR */ |
1111 | | 0, /* (58) maybe_lines ::= */ |
1112 | | -3, /* (59) maybe_lines ::= maybe_lines maybe_chars ENDL */ |
1113 | | 0, /* (60) anything ::= */ |
1114 | | -2, /* (61) anything ::= anything HEADER_CHAR */ |
1115 | | -2, /* (62) anything ::= anything ENDL */ |
1116 | | -3, /* (63) end_time ::= END_TIME ref_date ref_time */ |
1117 | | }; |
1118 | | |
1119 | | static void yy_accept(yyParser*); /* Forward Declaration */ |
1120 | | |
1121 | | /* |
1122 | | ** Perform a reduce action and the shift that must immediately |
1123 | | ** follow the reduce. |
1124 | | ** |
1125 | | ** The yyLookahead and yyLookaheadToken parameters provide reduce actions |
1126 | | ** access to the lookahead token (if any). The yyLookahead will be YYNOCODE |
1127 | | ** if the lookahead token has already been consumed. As this procedure is |
1128 | | ** only called from one place, optimizing compilers will in-line it, which |
1129 | | ** means that the extra parameters have no performance impact. |
1130 | | */ |
1131 | | static YYACTIONTYPE yy_reduce( |
1132 | | yyParser *yypParser, /* The parser */ |
1133 | | unsigned int yyruleno, /* Number of the rule by which to reduce */ |
1134 | | int yyLookahead, /* Lookahead token, or YYNOCODE if none */ |
1135 | | BusmasterParserTOKENTYPE yyLookaheadToken /* Value of the lookahead token */ |
1136 | | BusmasterParserCTX_PDECL /* %extra_context */ |
1137 | 0 | ){ |
1138 | 0 | int yygoto; /* The next state */ |
1139 | 0 | YYACTIONTYPE yyact; /* The next action */ |
1140 | 0 | yyStackEntry *yymsp; /* The top of the parser's stack */ |
1141 | 0 | int yysize; /* Amount to pop the stack */ |
1142 | 0 | BusmasterParserARG_FETCH |
1143 | 0 | (void)yyLookahead; |
1144 | 0 | (void)yyLookaheadToken; |
1145 | 0 | yymsp = yypParser->yytos; |
1146 | |
|
1147 | 0 | switch( yyruleno ){ |
1148 | | /* Beginning here are the reduction cases. A typical example |
1149 | | ** follows: |
1150 | | ** case 0: |
1151 | | ** #line <lineno> <grammarfile> |
1152 | | ** { ... } // User supplied code |
1153 | | ** #line <lineno> <thisfile> |
1154 | | ** break; |
1155 | | */ |
1156 | | /********** Begin reduce actions **********************************************/ |
1157 | 0 | YYMINORTYPE yylhsminor; |
1158 | 0 | case 0: /* empty_line ::= */ |
1159 | 0 | #line 142 "/src/wireshark/wiretap/busmaster_parser.lemon" |
1160 | 0 | { |
1161 | 0 | busmaster_debug_printf("%s: EMPTY\n", G_STRFUNC); |
1162 | 0 | state->entry_type = LOG_ENTRY_EMPTY; |
1163 | 0 | } |
1164 | 0 | #line 1189 "./busmaster_parser.c" |
1165 | 0 | break; |
1166 | 0 | case 1: /* footer_and_header ::= footer ENDL header */ |
1167 | 0 | #line 148 "/src/wireshark/wiretap/busmaster_parser.lemon" |
1168 | 0 | { |
1169 | 0 | busmaster_debug_printf("%s: FOOTER AND HEADER\n", G_STRFUNC); |
1170 | 0 | state->entry_type = LOG_ENTRY_FOOTER_AND_HEADER; |
1171 | 0 | } |
1172 | 0 | #line 1197 "./busmaster_parser.c" |
1173 | 0 | yy_destructor(yypParser,3,&yymsp[-1].minor); |
1174 | 0 | break; |
1175 | 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 */ |
1176 | 0 | #line 159 "/src/wireshark/wiretap/busmaster_parser.lemon" |
1177 | 0 | { |
1178 | 0 | busmaster_debug_printf("%s: HEADER\n", G_STRFUNC); |
1179 | |
|
1180 | 0 | state->entry_type = LOG_ENTRY_HEADER; |
1181 | 0 | state->header.start_date = yymsp[-8].minor.yy80.date; |
1182 | 0 | state->header.start_time = yymsp[-8].minor.yy80.time; |
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.date = yymsp[-1].minor.yy74; |
1201 | 0 | yymsp[-2].minor.yy80.time = 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 | busmaster_debug_printf("%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.yy32 == MSG_TYPE_STD_RTR || |
1231 | 0 | yymsp[-2].minor.yy32 == MSG_TYPE_EXT_RTR) |
1232 | 0 | { |
1233 | 0 | memset(&yymsp[0].minor.yy48, 0, sizeof(yymsp[0].minor.yy48)); |
1234 | 0 | yymsp[0].minor.yy48.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.yy32; |
1240 | 0 | msg.data = yymsp[0].minor.yy48; |
1241 | |
|
1242 | 0 | busmaster_debug_printf("%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.yy32; |
1259 | 0 | msg.data.length = CAN_MAX_DLEN; |
1260 | |
|
1261 | 0 | memset(msg.data.data, 0, sizeof(msg.data.data)); |
1262 | |
|
1263 | 0 | busmaster_debug_printf("%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.yy48; |
1282 | |
|
1283 | 0 | busmaster_debug_printf("%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.yy32 = (msg_type_t)yymsp[0].minor.yy0.v0; |
1355 | 0 | } |
1356 | 0 | #line 1381 "./busmaster_parser.c" |
1357 | 0 | yymsp[0].minor.yy32 = yylhsminor.yy32; |
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.yy48 = yymsp[0].minor.yy48; } |
1377 | 0 | #line 1402 "./busmaster_parser.c" |
1378 | 0 | yymsp[0].minor.yy48 = yylhsminor.yy48; |
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.yy48.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.yy48.length = 1; |
1399 | 0 | yylhsminor.yy48.data[0] = yymsp[0].minor.yy54; |
1400 | 0 | } |
1401 | 0 | #line 1426 "./busmaster_parser.c" |
1402 | 0 | yymsp[0].minor.yy48 = yylhsminor.yy48; |
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.yy48.length = 2; |
1408 | 0 | yylhsminor.yy48.data[0] = yymsp[-1].minor.yy54; |
1409 | 0 | yylhsminor.yy48.data[1] = yymsp[0].minor.yy54; |
1410 | 0 | } |
1411 | 0 | #line 1436 "./busmaster_parser.c" |
1412 | 0 | yymsp[-1].minor.yy48 = yylhsminor.yy48; |
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.yy48.length = 3; |
1418 | 0 | yylhsminor.yy48.data[0] = yymsp[-2].minor.yy54; |
1419 | 0 | yylhsminor.yy48.data[1] = yymsp[-1].minor.yy54; |
1420 | 0 | yylhsminor.yy48.data[2] = yymsp[0].minor.yy54; |
1421 | 0 | } |
1422 | 0 | #line 1447 "./busmaster_parser.c" |
1423 | 0 | yymsp[-2].minor.yy48 = yylhsminor.yy48; |
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.yy48.length = 4; |
1429 | 0 | yylhsminor.yy48.data[0] = yymsp[-3].minor.yy54; |
1430 | 0 | yylhsminor.yy48.data[1] = yymsp[-2].minor.yy54; |
1431 | 0 | yylhsminor.yy48.data[2] = yymsp[-1].minor.yy54; |
1432 | 0 | yylhsminor.yy48.data[3] = yymsp[0].minor.yy54; |
1433 | 0 | } |
1434 | 0 | #line 1459 "./busmaster_parser.c" |
1435 | 0 | yymsp[-3].minor.yy48 = yylhsminor.yy48; |
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.yy48, &yymsp[-1].minor.yy48, &yymsp[0].minor.yy48); } |
1450 | 0 | #line 1475 "./busmaster_parser.c" |
1451 | 0 | yymsp[-1].minor.yy48 = yylhsminor.yy48; |
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 83 "/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 | busmaster_debug_printf("%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 61 "/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 | | busmaster_debug_printf("%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 | | busmaster_debug_printf("%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 | busmaster_debug_printf("%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 41 "/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 | busmaster_debug_printf("%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 | | busmaster_debug_printf("%s: Feeding %s '%s'\n", |
1902 | | G_STRFUNC, yyTokenName[lex_code], |
1903 | | busmaster_get_text(scanner)); |
1904 | | else |
1905 | | busmaster_debug_printf("%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 | busmaster_debug_printf("%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" |