Coverage Report

Created: 2024-06-18 06:40

/src/open62541/src/util/ua_eventfilter_grammar.c
Line
Count
Source (jump to first uncovered line)
1
/* This file is automatically generated by Lemon from input grammar
2
** source file "ua_eventfilter_grammar.y".
3
*/
4
/*
5
** 2000-05-29
6
**
7
** The author disclaims copyright to this source code.  In place of
8
** a legal notice, here is a blessing:
9
**
10
**    May you do good and not evil.
11
**    May you find forgiveness for yourself and forgive others.
12
**    May you share freely, never taking more than you give.
13
**
14
*************************************************************************
15
** Driver template for the LEMON parser generator.
16
**
17
** The "lemon" program processes an LALR(1) input grammar file, then uses
18
** this template to construct a parser.  The "lemon" program inserts text
19
** at each "%%" line.  Also, any "P-a-r-s-e" identifer prefix (without the
20
** interstitial "-" characters) contained in this template is changed into
21
** the value of the %name directive from the grammar.  Otherwise, the content
22
** of this template is copied straight through into the generate parser
23
** source file.
24
**
25
** The following is the concatenation of all %include directives from the
26
** input grammar file:
27
*/
28
/************ Begin %include sections from the grammar ************************/
29
#include <open62541/util.h>
30
#include "ua_eventfilter_parser.h"
31
32
#define UA_EventFilterParse_ENGINEALWAYSONSTACK 1
33
#define NDEBUG 1
34
35
/* Declare methods to prevent errors due to missing "static" keyword */
36
static void UA_EventFilterParseInit(void *);
37
static void UA_EventFilterParseFinalize(void *p);
38
int UA_EventFilterParseFallback(int iToken);
39
static void UA_EventFilterParse(void *yyp, int yymajor, Operand *token, EFParseContext *ctx);
40
/**************** End of %include directives **********************************/
41
/* These constants specify the various numeric values for terminal symbols.
42
***************** Begin token definitions *************************************/
43
#ifndef EF_TOK_AND
44
#define EF_TOK_AND                             1
45
#define EF_TOK_OR                              2
46
#define EF_TOK_BINARY_OP                       3
47
#define EF_TOK_BETWEEN                         4
48
#define EF_TOK_INLIST                          5
49
#define EF_TOK_UNARY_OP                        6
50
#define EF_TOK_SELECT                          7
51
#define EF_TOK_COMMA                           8
52
#define EF_TOK_WHERE                           9
53
#define EF_TOK_LPAREN                         10
54
#define EF_TOK_RPAREN                         11
55
#define EF_TOK_LITERAL                        12
56
#define EF_TOK_SAO                            13
57
#define EF_TOK_NAMEDOPERAND                   14
58
#define EF_TOK_LBRACKET                       15
59
#define EF_TOK_RBRACKET                       16
60
#define EF_TOK_FOR                            17
61
#define EF_TOK_COLONEQUAL                     18
62
#endif
63
/**************** End token definitions ***************************************/
64
65
/* The next sections is a series of control #defines.
66
** various aspects of the generated parser.
67
**    YYCODETYPE         is the data type used to store the integer codes
68
**                       that represent terminal and non-terminal symbols.
69
**                       "unsigned char" is used if there are fewer than
70
**                       256 symbols.  Larger types otherwise.
71
**    YYNOCODE           is a number of type YYCODETYPE that is not used for
72
**                       any terminal or nonterminal symbol.
73
**    YYFALLBACK         If defined, this indicates that one or more tokens
74
**                       (also known as: "terminal symbols") have fall-back
75
**                       values which should be used if the original symbol
76
**                       would not parse.  This permits keywords to sometimes
77
**                       be used as identifiers, for example.
78
**    YYACTIONTYPE       is the data type used for "action codes" - numbers
79
**                       that indicate what to do in response to the next
80
**                       token.
81
**    UA_EventFilterParseTOKENTYPE     is the data type used for minor type for terminal
82
**                       symbols.  Background: A "minor type" is a semantic
83
**                       value associated with a terminal or non-terminal
84
**                       symbols.  For example, for an "ID" terminal symbol,
85
**                       the minor type might be the name of the identifier.
86
**                       Each non-terminal can have a different minor type.
87
**                       Terminal symbols all have the same minor type, though.
88
**                       This macros defines the minor type for terminal 
89
**                       symbols.
90
**    YYMINORTYPE        is the data type used for all minor types.
91
**                       This is typically a union of many types, one of
92
**                       which is UA_EventFilterParseTOKENTYPE.  The entry in the union
93
**                       for terminal symbols is called "yy0".
94
**    YYSTACKDEPTH       is the maximum depth of the parser's stack.  If
95
**                       zero the stack is dynamically sized using realloc()
96
**    UA_EventFilterParseARG_SDECL     A static variable declaration for the %extra_argument
97
**    UA_EventFilterParseARG_PDECL     A parameter declaration for the %extra_argument
98
**    UA_EventFilterParseARG_PARAM     Code to pass %extra_argument as a subroutine parameter
99
**    UA_EventFilterParseARG_STORE     Code to store %extra_argument into yypParser
100
**    UA_EventFilterParseARG_FETCH     Code to extract %extra_argument from yypParser
101
**    UA_EventFilterParseCTX_*         As UA_EventFilterParseARG_ except for %extra_context
102
**    YYERRORSYMBOL      is the code number of the error symbol.  If not
103
**                       defined, then do no error processing.
104
**    YYNSTATE           the combined number of states.
105
**    YYNRULE            the number of rules in the grammar
106
**    YYNTOKEN           Number of terminal symbols
107
**    YY_MAX_SHIFT       Maximum value for shift actions
108
**    YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions
109
**    YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions
110
**    YY_ERROR_ACTION    The yy_action[] code for syntax error
111
**    YY_ACCEPT_ACTION   The yy_action[] code for accept
112
**    YY_NO_ACTION       The yy_action[] code for no-op
113
**    YY_MIN_REDUCE      Minimum value for reduce actions
114
**    YY_MAX_REDUCE      Maximum value for reduce actions
115
*/
116
#ifndef INTERFACE
117
# define INTERFACE 1
118
#endif
119
/************* Begin control #defines *****************************************/
120
#define YYCODETYPE unsigned char
121
#define YYNOCODE 29
122
0
#define YYACTIONTYPE unsigned char
123
#define UA_EventFilterParseTOKENTYPE  Operand * 
124
typedef union {
125
  int yyinit;
126
  UA_EventFilterParseTOKENTYPE yy0;
127
} YYMINORTYPE;
128
#ifndef YYSTACKDEPTH
129
0
#define YYSTACKDEPTH 100
130
#endif
131
#define UA_EventFilterParseARG_SDECL  EFParseContext *ctx ;
132
#define UA_EventFilterParseARG_PDECL , EFParseContext *ctx 
133
#define UA_EventFilterParseARG_PARAM ,ctx 
134
0
#define UA_EventFilterParseARG_FETCH  EFParseContext *ctx =yypParser->ctx ;
135
0
#define UA_EventFilterParseARG_STORE yypParser->ctx =ctx ;
136
#define UA_EventFilterParseCTX_SDECL
137
#define UA_EventFilterParseCTX_PDECL
138
#define UA_EventFilterParseCTX_PARAM
139
#define UA_EventFilterParseCTX_FETCH
140
#define UA_EventFilterParseCTX_STORE
141
#define YYNSTATE             34
142
#define YYNRULE              25
143
#define YYNRULE_WITH_ACTION  17
144
#define YYNTOKEN             19
145
0
#define YY_MAX_SHIFT         33
146
0
#define YY_MIN_SHIFTREDUCE   48
147
0
#define YY_MAX_SHIFTREDUCE   72
148
#define YY_ERROR_ACTION      73
149
0
#define YY_ACCEPT_ACTION     74
150
#define YY_NO_ACTION         75
151
0
#define YY_MIN_REDUCE        76
152
#define YY_MAX_REDUCE        100
153
/************* End control #defines *******************************************/
154
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
155
156
/* Define the yytestcase() macro to be a no-op if is not already defined
157
** otherwise.
158
**
159
** Applications can choose to define yytestcase() in the %include section
160
** to a macro that can assist in verifying code coverage.  For production
161
** code the yytestcase() macro should be turned off.  But it is useful
162
** for testing.
163
*/
164
#ifndef yytestcase
165
# define yytestcase(X)
166
#endif
167
168
169
/* Next are the tables used to determine what action to take based on the
170
** current state and lookahead token.  These tables are used to implement
171
** functions that take a state number and lookahead value and return an
172
** action integer.  
173
**
174
** Suppose the action integer is N.  Then the action is determined as
175
** follows
176
**
177
**   0 <= N <= YY_MAX_SHIFT             Shift N.  That is, push the lookahead
178
**                                      token onto the stack and goto state N.
179
**
180
**   N between YY_MIN_SHIFTREDUCE       Shift to an arbitrary state then
181
**     and YY_MAX_SHIFTREDUCE           reduce by rule N-YY_MIN_SHIFTREDUCE.
182
**
183
**   N == YY_ERROR_ACTION               A syntax error has occurred.
184
**
185
**   N == YY_ACCEPT_ACTION              The parser accepts its input.
186
**
187
**   N == YY_NO_ACTION                  No such action.  Denotes unused
188
**                                      slots in the yy_action[] table.
189
**
190
**   N between YY_MIN_REDUCE            Reduce by rule N-YY_MIN_REDUCE
191
**     and YY_MAX_REDUCE
192
**
193
** The action table is constructed as a single large table named yy_action[].
194
** Given state S and lookahead X, the action is computed as either:
195
**
196
**    (A)   N = yy_action[ yy_shift_ofst[S] + X ]
197
**    (B)   N = yy_default[S]
198
**
199
** The (A) formula is preferred.  The B formula is used instead if
200
** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X.
201
**
202
** The formulas above are for computing the action when the lookahead is
203
** a terminal symbol.  If the lookahead is a non-terminal (as occurs after
204
** a reduce action) then the yy_reduce_ofst[] array is used in place of
205
** the yy_shift_ofst[] array.
206
**
207
** The following are the tables generated in this section:
208
**
209
**  yy_action[]        A single table containing all actions.
210
**  yy_lookahead[]     A table containing the lookahead for each entry in
211
**                     yy_action.  Used to detect hash collisions.
212
**  yy_shift_ofst[]    For each state, the offset into yy_action for
213
**                     shifting terminals.
214
**  yy_reduce_ofst[]   For each state, the offset into yy_action for
215
**                     shifting non-terminals after a reduce.
216
**  yy_default[]       Default action for each state.
217
**
218
*********** Begin parsing tables **********************************************/
219
#define YY_ACTTAB_COUNT (76)
220
static const YYACTIONTYPE yy_action[] = {
221
 /*     0 */   100,   11,    9,    8,   30,   29,   11,    9,    8,   30,
222
 /*    10 */    29,   74,   17,    6,   22,   80,   60,    1,   11,    9,
223
 /*    20 */     8,   30,   29,   23,   80,   10,   18,   80,   51,   12,
224
 /*    30 */    31,   53,   54,   55,   11,    9,    8,   30,   29,   19,
225
 /*    40 */    80,   32,   32,   26,   21,   80,   25,   28,   91,   33,
226
 /*    50 */    25,   28,   27,   87,   80,    5,   86,   80,   84,   80,
227
 /*    60 */    85,   80,   20,   80,   24,   80,   14,    4,   16,   61,
228
 /*    70 */     2,    3,    7,   13,   15,   93,
229
};
230
static const YYCODETYPE yy_lookahead[] = {
231
 /*     0 */    28,    1,    2,    3,    4,    5,    1,    2,    3,    4,
232
 /*    10 */     5,   19,   20,    8,   24,   25,   16,    7,    1,    2,
233
 /*    20 */     3,    4,    5,   24,   25,    6,   24,   25,   11,   10,
234
 /*    30 */    14,   12,   13,   14,    1,    2,    3,    4,    5,   24,
235
 /*    40 */    25,   27,   28,   23,   24,   25,   24,   25,   26,   22,
236
 /*    50 */    24,   25,   26,   24,   25,    9,   24,   25,   24,   25,
237
 /*    60 */    24,   25,   24,   25,   24,   25,   17,    8,   21,   16,
238
 /*    70 */     8,   15,   15,   18,    8,    0,   29,   29,   29,   29,
239
 /*    80 */    29,   29,   29,   29,   29,   29,   29,   29,   29,   29,
240
 /*    90 */    29,   29,   29,   29,   29,
241
};
242
#define YY_SHIFT_COUNT    (33)
243
#define YY_SHIFT_MIN      (0)
244
#define YY_SHIFT_MAX      (75)
245
static const unsigned char yy_shift_ofst[] = {
246
 /*     0 */    10,   19,   19,   19,   19,   19,   19,   19,   19,   19,
247
 /*    10 */    19,   19,   19,   19,   16,   16,   49,   46,    0,    5,
248
 /*    20 */    17,   33,   33,   33,   33,   33,   59,   53,   62,   56,
249
 /*    30 */    57,   55,   66,   75,
250
};
251
#define YY_REDUCE_COUNT (17)
252
#define YY_REDUCE_MIN   (-28)
253
#define YY_REDUCE_MAX   (47)
254
static const signed char yy_reduce_ofst[] = {
255
 /*     0 */    -8,   20,   22,   26,  -10,   -1,    2,   15,   29,   32,
256
 /*    10 */    34,   36,   38,   40,   14,  -28,   27,   47,
257
};
258
static const YYACTIONTYPE yy_default[] = {
259
 /*     0 */    94,   73,   73,   73,   73,   73,   73,   73,   73,   73,
260
 /*    10 */    73,   73,   73,   73,   73,   73,   97,   96,   73,   73,
261
 /*    20 */    73,   76,   77,   78,   92,   90,   95,   73,   80,   73,
262
 /*    30 */    73,   73,   98,   73,
263
};
264
/********** End of lemon-generated parsing tables *****************************/
265
266
/* The next table maps tokens (terminal symbols) into fallback tokens.  
267
** If a construct like the following:
268
** 
269
**      %fallback ID X Y Z.
270
**
271
** appears in the grammar, then ID becomes a fallback token for X, Y,
272
** and Z.  Whenever one of the tokens X, Y, or Z is input to the parser
273
** but it does not parse, the type of the token is changed to ID and
274
** the parse is retried before an error is thrown.
275
**
276
** This feature can be used, for example, to cause some keywords in a language
277
** to revert to identifiers if they keyword does not apply in the context where
278
** it appears.
279
*/
280
#ifdef YYFALLBACK
281
static const YYCODETYPE yyFallback[] = {
282
};
283
#endif /* YYFALLBACK */
284
285
/* The following structure represents a single element of the
286
** parser's stack.  Information stored includes:
287
**
288
**   +  The state number for the parser at this level of the stack.
289
**
290
**   +  The value of the token stored at this level of the stack.
291
**      (In other words, the "major" token.)
292
**
293
**   +  The semantic value stored at this level of the stack.  This is
294
**      the information used by the action routines in the grammar.
295
**      It is sometimes called the "minor" token.
296
**
297
** After the "shift" half of a SHIFTREDUCE action, the stateno field
298
** actually contains the reduce action for the second half of the
299
** SHIFTREDUCE.
300
*/
301
struct yyStackEntry {
302
  YYACTIONTYPE stateno;  /* The state-number, or reduce action in SHIFTREDUCE */
303
  YYCODETYPE major;      /* The major token value.  This is the code
304
                         ** number for the token at this stack level */
305
  YYMINORTYPE minor;     /* The user-supplied minor token value.  This
306
                         ** is the value of the token  */
307
};
308
typedef struct yyStackEntry yyStackEntry;
309
310
/* The state of the parser is completely contained in an instance of
311
** the following structure */
312
struct yyParser {
313
  yyStackEntry *yytos;          /* Pointer to top element of the stack */
314
#ifdef YYTRACKMAXSTACKDEPTH
315
  int yyhwm;                    /* High-water mark of the stack */
316
#endif
317
#ifndef YYNOERRORRECOVERY
318
  int yyerrcnt;                 /* Shifts left before out of the error */
319
#endif
320
  UA_EventFilterParseARG_SDECL                /* A place to hold %extra_argument */
321
  UA_EventFilterParseCTX_SDECL                /* A place to hold %extra_context */
322
#if YYSTACKDEPTH<=0
323
  int yystksz;                  /* Current side of the stack */
324
  yyStackEntry *yystack;        /* The parser's stack */
325
  yyStackEntry yystk0;          /* First stack entry */
326
#else
327
  yyStackEntry yystack[YYSTACKDEPTH];  /* The parser's stack */
328
  yyStackEntry *yystackEnd;            /* Last entry in the stack */
329
#endif
330
};
331
typedef struct yyParser yyParser;
332
333
#include <assert.h>
334
#ifndef NDEBUG
335
#include <stdio.h>
336
static FILE *yyTraceFILE = 0;
337
static char *yyTracePrompt = 0;
338
#endif /* NDEBUG */
339
340
#ifndef NDEBUG
341
/* 
342
** Turn parser tracing on by giving a stream to which to write the trace
343
** and a prompt to preface each trace message.  Tracing is turned off
344
** by making either argument NULL 
345
**
346
** Inputs:
347
** <ul>
348
** <li> A FILE* to which trace output should be written.
349
**      If NULL, then tracing is turned off.
350
** <li> A prefix string written at the beginning of every
351
**      line of trace output.  If NULL, then tracing is
352
**      turned off.
353
** </ul>
354
**
355
** Outputs:
356
** None.
357
*/
358
void UA_EventFilterParseTrace(FILE *TraceFILE, char *zTracePrompt){
359
  yyTraceFILE = TraceFILE;
360
  yyTracePrompt = zTracePrompt;
361
  if( yyTraceFILE==0 ) yyTracePrompt = 0;
362
  else if( yyTracePrompt==0 ) yyTraceFILE = 0;
363
}
364
#endif /* NDEBUG */
365
366
#if defined(YYCOVERAGE) || !defined(NDEBUG)
367
/* For tracing shifts, the names of all terminals and nonterminals
368
** are required.  The following table supplies these names */
369
static const char *const yyTokenName[] = { 
370
  /*    0 */ "$",
371
  /*    1 */ "AND",
372
  /*    2 */ "OR",
373
  /*    3 */ "BINARY_OP",
374
  /*    4 */ "BETWEEN",
375
  /*    5 */ "INLIST",
376
  /*    6 */ "UNARY_OP",
377
  /*    7 */ "SELECT",
378
  /*    8 */ "COMMA",
379
  /*    9 */ "WHERE",
380
  /*   10 */ "LPAREN",
381
  /*   11 */ "RPAREN",
382
  /*   12 */ "LITERAL",
383
  /*   13 */ "SAO",
384
  /*   14 */ "NAMEDOPERAND",
385
  /*   15 */ "LBRACKET",
386
  /*   16 */ "RBRACKET",
387
  /*   17 */ "FOR",
388
  /*   18 */ "COLONEQUAL",
389
  /*   19 */ "eventFilter",
390
  /*   20 */ "selectClause",
391
  /*   21 */ "whereClause",
392
  /*   22 */ "forClause",
393
  /*   23 */ "selectClauseList",
394
  /*   24 */ "operand",
395
  /*   25 */ "operator",
396
  /*   26 */ "operandList",
397
  /*   27 */ "namedOperandAssignmentList",
398
  /*   28 */ "namedOperandAssignment",
399
};
400
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
401
402
#ifndef NDEBUG
403
/* For tracing reduce actions, the names of all rules are required.
404
*/
405
static const char *const yyRuleName[] = {
406
 /*   0 */ "selectClauseList ::= operand",
407
 /*   1 */ "selectClauseList ::= selectClauseList COMMA operand",
408
 /*   2 */ "whereClause ::= WHERE operand",
409
 /*   3 */ "operand ::= LPAREN operand RPAREN",
410
 /*   4 */ "operand ::= operator",
411
 /*   5 */ "operand ::= LITERAL",
412
 /*   6 */ "operand ::= SAO",
413
 /*   7 */ "operand ::= NAMEDOPERAND",
414
 /*   8 */ "operator ::= UNARY_OP operand",
415
 /*   9 */ "operator ::= operand AND operand",
416
 /*  10 */ "operator ::= operand OR operand",
417
 /*  11 */ "operator ::= operand BINARY_OP operand",
418
 /*  12 */ "operator ::= operand BETWEEN LBRACKET operand COMMA operand RBRACKET",
419
 /*  13 */ "operator ::= operand INLIST LBRACKET operandList RBRACKET",
420
 /*  14 */ "operandList ::= operand",
421
 /*  15 */ "operandList ::= operator COMMA operandList",
422
 /*  16 */ "namedOperandAssignment ::= NAMEDOPERAND COLONEQUAL operand",
423
 /*  17 */ "eventFilter ::= selectClause whereClause forClause",
424
 /*  18 */ "selectClause ::=",
425
 /*  19 */ "selectClause ::= SELECT selectClauseList",
426
 /*  20 */ "whereClause ::=",
427
 /*  21 */ "forClause ::=",
428
 /*  22 */ "forClause ::= FOR namedOperandAssignmentList",
429
 /*  23 */ "namedOperandAssignmentList ::= namedOperandAssignment",
430
 /*  24 */ "namedOperandAssignmentList ::= namedOperandAssignmentList COMMA namedOperandAssignment",
431
};
432
#endif /* NDEBUG */
433
434
435
#if YYSTACKDEPTH<=0
436
/*
437
** Try to increase the size of the parser stack.  Return the number
438
** of errors.  Return 0 on success.
439
*/
440
static int yyGrowStack(yyParser *p){
441
  int newSize;
442
  int idx;
443
  yyStackEntry *pNew;
444
445
  newSize = p->yystksz*2 + 100;
446
  idx = p->yytos ? (int)(p->yytos - p->yystack) : 0;
447
  if( p->yystack==&p->yystk0 ){
448
    pNew = malloc(newSize*sizeof(pNew[0]));
449
    if( pNew ) pNew[0] = p->yystk0;
450
  }else{
451
    pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
452
  }
453
  if( pNew ){
454
    p->yystack = pNew;
455
    p->yytos = &p->yystack[idx];
456
#ifndef NDEBUG
457
    if( yyTraceFILE ){
458
      fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n",
459
              yyTracePrompt, p->yystksz, newSize);
460
    }
461
#endif
462
    p->yystksz = newSize;
463
  }
464
  return pNew==0; 
465
}
466
#endif
467
468
/* Datatype of the argument to the memory allocated passed as the
469
** second argument to UA_EventFilterParseAlloc() below.  This can be changed by
470
** putting an appropriate #define in the %include section of the input
471
** grammar.
472
*/
473
#ifndef YYMALLOCARGTYPE
474
# define YYMALLOCARGTYPE size_t
475
#endif
476
477
/* Initialize a new parser that has already been allocated.
478
*/
479
0
void UA_EventFilterParseInit(void *yypRawParser UA_EventFilterParseCTX_PDECL){
480
0
  yyParser *yypParser = (yyParser*)yypRawParser;
481
0
  UA_EventFilterParseCTX_STORE
482
#ifdef YYTRACKMAXSTACKDEPTH
483
  yypParser->yyhwm = 0;
484
#endif
485
#if YYSTACKDEPTH<=0
486
  yypParser->yytos = NULL;
487
  yypParser->yystack = NULL;
488
  yypParser->yystksz = 0;
489
  if( yyGrowStack(yypParser) ){
490
    yypParser->yystack = &yypParser->yystk0;
491
    yypParser->yystksz = 1;
492
  }
493
#endif
494
0
#ifndef YYNOERRORRECOVERY
495
0
  yypParser->yyerrcnt = -1;
496
0
#endif
497
0
  yypParser->yytos = yypParser->yystack;
498
0
  yypParser->yystack[0].stateno = 0;
499
0
  yypParser->yystack[0].major = 0;
500
0
#if YYSTACKDEPTH>0
501
0
  yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1];
502
0
#endif
503
0
}
504
505
#ifndef UA_EventFilterParse_ENGINEALWAYSONSTACK
506
/* 
507
** This function allocates a new parser.
508
** The only argument is a pointer to a function which works like
509
** malloc.
510
**
511
** Inputs:
512
** A pointer to the function used to allocate memory.
513
**
514
** Outputs:
515
** A pointer to a parser.  This pointer is used in subsequent calls
516
** to UA_EventFilterParse and UA_EventFilterParseFree.
517
*/
518
void *UA_EventFilterParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) UA_EventFilterParseCTX_PDECL){
519
  yyParser *yypParser;
520
  yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
521
  if( yypParser ){
522
    UA_EventFilterParseCTX_STORE
523
    UA_EventFilterParseInit(yypParser UA_EventFilterParseCTX_PARAM);
524
  }
525
  return (void*)yypParser;
526
}
527
#endif /* UA_EventFilterParse_ENGINEALWAYSONSTACK */
528
529
530
/* The following function deletes the "minor type" or semantic value
531
** associated with a symbol.  The symbol can be either a terminal
532
** or nonterminal. "yymajor" is the symbol code, and "yypminor" is
533
** a pointer to the value to be deleted.  The code used to do the 
534
** deletions is derived from the %destructor and/or %token_destructor
535
** directives of the input grammar.
536
*/
537
static void yy_destructor(
538
  yyParser *yypParser,    /* The parser */
539
  YYCODETYPE yymajor,     /* Type code for object to destroy */
540
  YYMINORTYPE *yypminor   /* The object to be destroyed */
541
0
){
542
0
  UA_EventFilterParseARG_FETCH
543
0
  UA_EventFilterParseCTX_FETCH
544
0
  switch( yymajor ){
545
    /* Here is inserted the actions which take place when a
546
    ** terminal or non-terminal is destroyed.  This can happen
547
    ** when the symbol is popped from the stack during a
548
    ** reduce or during error processing or when a parser is 
549
    ** being destroyed before it is finished parsing.
550
    **
551
    ** Note: during a reduce, the only symbols destroyed are those
552
    ** which appear on the RHS of the rule, but which are *not* used
553
    ** inside the C code.
554
    */
555
/********* Begin destructor definitions ***************************************/
556
      /* TERMINAL Destructor */
557
0
    case 1: /* AND */
558
0
    case 2: /* OR */
559
0
    case 3: /* BINARY_OP */
560
0
    case 4: /* BETWEEN */
561
0
    case 5: /* INLIST */
562
0
    case 6: /* UNARY_OP */
563
0
    case 7: /* SELECT */
564
0
    case 8: /* COMMA */
565
0
    case 9: /* WHERE */
566
0
    case 10: /* LPAREN */
567
0
    case 11: /* RPAREN */
568
0
    case 12: /* LITERAL */
569
0
    case 13: /* SAO */
570
0
    case 14: /* NAMEDOPERAND */
571
0
    case 15: /* LBRACKET */
572
0
    case 16: /* RBRACKET */
573
0
    case 17: /* FOR */
574
0
    case 18: /* COLONEQUAL */
575
0
{
576
0
 (void)ctx; 
577
0
}
578
0
      break;
579
/********* End destructor definitions *****************************************/
580
0
    default:  break;   /* If no destructor action specified: do nothing */
581
0
  }
582
0
}
583
584
/*
585
** Pop the parser's stack once.
586
**
587
** If there is a destructor routine associated with the token which
588
** is popped from the stack, then call it.
589
*/
590
0
static void yy_pop_parser_stack(yyParser *pParser){
591
0
  yyStackEntry *yytos;
592
0
  assert( pParser->yytos!=0 );
593
0
  assert( pParser->yytos > pParser->yystack );
594
0
  yytos = pParser->yytos--;
595
#ifndef NDEBUG
596
  if( yyTraceFILE ){
597
    fprintf(yyTraceFILE,"%sPopping %s\n",
598
      yyTracePrompt,
599
      yyTokenName[yytos->major]);
600
  }
601
#endif
602
0
  yy_destructor(pParser, yytos->major, &yytos->minor);
603
0
}
604
605
/*
606
** Clear all secondary memory allocations from the parser
607
*/
608
0
void UA_EventFilterParseFinalize(void *p){
609
0
  yyParser *pParser = (yyParser*)p;
610
0
  while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser);
611
#if YYSTACKDEPTH<=0
612
  if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack);
613
#endif
614
0
}
615
616
#ifndef UA_EventFilterParse_ENGINEALWAYSONSTACK
617
/* 
618
** Deallocate and destroy a parser.  Destructors are called for
619
** all stack elements before shutting the parser down.
620
**
621
** If the YYPARSEFREENEVERNULL macro exists (for example because it
622
** is defined in a %include section of the input grammar) then it is
623
** assumed that the input pointer is never NULL.
624
*/
625
void UA_EventFilterParseFree(
626
  void *p,                    /* The parser to be deleted */
627
  void (*freeProc)(void*)     /* Function used to reclaim memory */
628
){
629
#ifndef YYPARSEFREENEVERNULL
630
  if( p==0 ) return;
631
#endif
632
  UA_EventFilterParseFinalize(p);
633
  (*freeProc)(p);
634
}
635
#endif /* UA_EventFilterParse_ENGINEALWAYSONSTACK */
636
637
/*
638
** Return the peak depth of the stack for a parser.
639
*/
640
#ifdef YYTRACKMAXSTACKDEPTH
641
int UA_EventFilterParseStackPeak(void *p){
642
  yyParser *pParser = (yyParser*)p;
643
  return pParser->yyhwm;
644
}
645
#endif
646
647
/* This array of booleans keeps track of the parser statement
648
** coverage.  The element yycoverage[X][Y] is set when the parser
649
** is in state X and has a lookahead token Y.  In a well-tested
650
** systems, every element of this matrix should end up being set.
651
*/
652
#if defined(YYCOVERAGE)
653
static unsigned char yycoverage[YYNSTATE][YYNTOKEN];
654
#endif
655
656
/*
657
** Write into out a description of every state/lookahead combination that
658
**
659
**   (1)  has not been used by the parser, and
660
**   (2)  is not a syntax error.
661
**
662
** Return the number of missed state/lookahead combinations.
663
*/
664
#if defined(YYCOVERAGE)
665
int UA_EventFilterParseCoverage(FILE *out){
666
  int stateno, iLookAhead, i;
667
  int nMissed = 0;
668
  for(stateno=0; stateno<YYNSTATE; stateno++){
669
    i = yy_shift_ofst[stateno];
670
    for(iLookAhead=0; iLookAhead<YYNTOKEN; iLookAhead++){
671
      if( yy_lookahead[i+iLookAhead]!=iLookAhead ) continue;
672
      if( yycoverage[stateno][iLookAhead]==0 ) nMissed++;
673
      if( out ){
674
        fprintf(out,"State %d lookahead %s %s\n", stateno,
675
                yyTokenName[iLookAhead],
676
                yycoverage[stateno][iLookAhead] ? "ok" : "missed");
677
      }
678
    }
679
  }
680
  return nMissed;
681
}
682
#endif
683
684
/*
685
** Find the appropriate action for a parser given the terminal
686
** look-ahead token iLookAhead.
687
*/
688
static YYACTIONTYPE yy_find_shift_action(
689
  YYCODETYPE iLookAhead,    /* The look-ahead token */
690
  YYACTIONTYPE stateno      /* Current state number */
691
0
){
692
0
  int i;
693
694
0
  if( stateno>YY_MAX_SHIFT ) return stateno;
695
0
  assert( stateno <= YY_SHIFT_COUNT );
696
#if defined(YYCOVERAGE)
697
  yycoverage[stateno][iLookAhead] = 1;
698
#endif
699
0
  do{
700
0
    i = yy_shift_ofst[stateno];
701
0
    assert( i>=0 );
702
0
    assert( i<=YY_ACTTAB_COUNT );
703
0
    assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD );
704
0
    assert( iLookAhead!=YYNOCODE );
705
0
    assert( iLookAhead < YYNTOKEN );
706
0
    i += iLookAhead;
707
0
    assert( i<(int)YY_NLOOKAHEAD );
708
0
    if( yy_lookahead[i]!=iLookAhead ){
709
#ifdef YYFALLBACK
710
      YYCODETYPE iFallback;            /* Fallback token */
711
      assert( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0]) );
712
      iFallback = yyFallback[iLookAhead];
713
      if( iFallback!=0 ){
714
#ifndef NDEBUG
715
        if( yyTraceFILE ){
716
          fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
717
             yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
718
        }
719
#endif
720
        assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */
721
        iLookAhead = iFallback;
722
        continue;
723
      }
724
#endif
725
#ifdef YYWILDCARD
726
      {
727
        int j = i - iLookAhead + YYWILDCARD;
728
        assert( j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) );
729
        if( yy_lookahead[j]==YYWILDCARD && iLookAhead>0 ){
730
#ifndef NDEBUG
731
          if( yyTraceFILE ){
732
            fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
733
               yyTracePrompt, yyTokenName[iLookAhead],
734
               yyTokenName[YYWILDCARD]);
735
          }
736
#endif /* NDEBUG */
737
          return yy_action[j];
738
        }
739
      }
740
#endif /* YYWILDCARD */
741
0
      return yy_default[stateno];
742
0
    }else{
743
0
      assert( i>=0 && i<(int)(sizeof(yy_action)/sizeof(yy_action[0])) );
744
0
      return yy_action[i];
745
0
    }
746
0
  }while(1);
747
0
}
748
749
/*
750
** Find the appropriate action for a parser given the non-terminal
751
** look-ahead token iLookAhead.
752
*/
753
static YYACTIONTYPE yy_find_reduce_action(
754
  YYACTIONTYPE stateno,     /* Current state number */
755
  YYCODETYPE iLookAhead     /* The look-ahead token */
756
0
){
757
0
  int i;
758
#ifdef YYERRORSYMBOL
759
  if( stateno>YY_REDUCE_COUNT ){
760
    return yy_default[stateno];
761
  }
762
#else
763
0
  assert( stateno<=YY_REDUCE_COUNT );
764
0
#endif
765
0
  i = yy_reduce_ofst[stateno];
766
0
  assert( iLookAhead!=YYNOCODE );
767
0
  i += iLookAhead;
768
#ifdef YYERRORSYMBOL
769
  if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
770
    return yy_default[stateno];
771
  }
772
#else
773
0
  assert( i>=0 && i<YY_ACTTAB_COUNT );
774
0
  assert( yy_lookahead[i]==iLookAhead );
775
0
#endif
776
0
  return yy_action[i];
777
0
}
778
779
/*
780
** The following routine is called if the stack overflows.
781
*/
782
0
static void yyStackOverflow(yyParser *yypParser){
783
0
   UA_EventFilterParseARG_FETCH
784
0
   UA_EventFilterParseCTX_FETCH
785
#ifndef NDEBUG
786
   if( yyTraceFILE ){
787
     fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
788
   }
789
#endif
790
0
   while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
791
   /* Here code is inserted which will execute if the parser
792
   ** stack every overflows */
793
/******** Begin %stack_overflow code ******************************************/
794
/******** End %stack_overflow code ********************************************/
795
   UA_EventFilterParseARG_STORE /* Suppress warning about unused %extra_argument var */
796
0
   UA_EventFilterParseCTX_STORE
797
0
}
798
799
/*
800
** Print tracing information for a SHIFT action
801
*/
802
#ifndef NDEBUG
803
static void yyTraceShift(yyParser *yypParser, int yyNewState, const char *zTag){
804
  if( yyTraceFILE ){
805
    if( yyNewState<YYNSTATE ){
806
      fprintf(yyTraceFILE,"%s%s '%s', go to state %d\n",
807
         yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major],
808
         yyNewState);
809
    }else{
810
      fprintf(yyTraceFILE,"%s%s '%s', pending reduce %d\n",
811
         yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major],
812
         yyNewState - YY_MIN_REDUCE);
813
    }
814
  }
815
}
816
#else
817
# define yyTraceShift(X,Y,Z)
818
#endif
819
820
/*
821
** Perform a shift action.
822
*/
823
static void yy_shift(
824
  yyParser *yypParser,          /* The parser to be shifted */
825
  YYACTIONTYPE yyNewState,      /* The new state to shift in */
826
  YYCODETYPE yyMajor,           /* The major token to shift in */
827
  UA_EventFilterParseTOKENTYPE yyMinor        /* The minor token to shift in */
828
0
){
829
0
  yyStackEntry *yytos;
830
0
  yypParser->yytos++;
831
#ifdef YYTRACKMAXSTACKDEPTH
832
  if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
833
    yypParser->yyhwm++;
834
    assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );
835
  }
836
#endif
837
0
#if YYSTACKDEPTH>0 
838
0
  if( yypParser->yytos>yypParser->yystackEnd ){
839
0
    yypParser->yytos--;
840
0
    yyStackOverflow(yypParser);
841
0
    return;
842
0
  }
843
#else
844
  if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){
845
    if( yyGrowStack(yypParser) ){
846
      yypParser->yytos--;
847
      yyStackOverflow(yypParser);
848
      return;
849
    }
850
  }
851
#endif
852
0
  if( yyNewState > YY_MAX_SHIFT ){
853
0
    yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
854
0
  }
855
0
  yytos = yypParser->yytos;
856
0
  yytos->stateno = yyNewState;
857
0
  yytos->major = yyMajor;
858
0
  yytos->minor.yy0 = yyMinor;
859
0
  yyTraceShift(yypParser, yyNewState, "Shift");
860
0
}
861
862
/* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
863
** of that rule */
864
static const YYCODETYPE yyRuleInfoLhs[] = {
865
    23,  /* (0) selectClauseList ::= operand */
866
    23,  /* (1) selectClauseList ::= selectClauseList COMMA operand */
867
    21,  /* (2) whereClause ::= WHERE operand */
868
    24,  /* (3) operand ::= LPAREN operand RPAREN */
869
    24,  /* (4) operand ::= operator */
870
    24,  /* (5) operand ::= LITERAL */
871
    24,  /* (6) operand ::= SAO */
872
    24,  /* (7) operand ::= NAMEDOPERAND */
873
    25,  /* (8) operator ::= UNARY_OP operand */
874
    25,  /* (9) operator ::= operand AND operand */
875
    25,  /* (10) operator ::= operand OR operand */
876
    25,  /* (11) operator ::= operand BINARY_OP operand */
877
    25,  /* (12) operator ::= operand BETWEEN LBRACKET operand COMMA operand RBRACKET */
878
    25,  /* (13) operator ::= operand INLIST LBRACKET operandList RBRACKET */
879
    26,  /* (14) operandList ::= operand */
880
    26,  /* (15) operandList ::= operator COMMA operandList */
881
    28,  /* (16) namedOperandAssignment ::= NAMEDOPERAND COLONEQUAL operand */
882
    19,  /* (17) eventFilter ::= selectClause whereClause forClause */
883
    20,  /* (18) selectClause ::= */
884
    20,  /* (19) selectClause ::= SELECT selectClauseList */
885
    21,  /* (20) whereClause ::= */
886
    22,  /* (21) forClause ::= */
887
    22,  /* (22) forClause ::= FOR namedOperandAssignmentList */
888
    27,  /* (23) namedOperandAssignmentList ::= namedOperandAssignment */
889
    27,  /* (24) namedOperandAssignmentList ::= namedOperandAssignmentList COMMA namedOperandAssignment */
890
};
891
892
/* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
893
** of symbols on the right-hand side of that rule. */
894
static const signed char yyRuleInfoNRhs[] = {
895
   -1,  /* (0) selectClauseList ::= operand */
896
   -3,  /* (1) selectClauseList ::= selectClauseList COMMA operand */
897
   -2,  /* (2) whereClause ::= WHERE operand */
898
   -3,  /* (3) operand ::= LPAREN operand RPAREN */
899
   -1,  /* (4) operand ::= operator */
900
   -1,  /* (5) operand ::= LITERAL */
901
   -1,  /* (6) operand ::= SAO */
902
   -1,  /* (7) operand ::= NAMEDOPERAND */
903
   -2,  /* (8) operator ::= UNARY_OP operand */
904
   -3,  /* (9) operator ::= operand AND operand */
905
   -3,  /* (10) operator ::= operand OR operand */
906
   -3,  /* (11) operator ::= operand BINARY_OP operand */
907
   -7,  /* (12) operator ::= operand BETWEEN LBRACKET operand COMMA operand RBRACKET */
908
   -5,  /* (13) operator ::= operand INLIST LBRACKET operandList RBRACKET */
909
   -1,  /* (14) operandList ::= operand */
910
   -3,  /* (15) operandList ::= operator COMMA operandList */
911
   -3,  /* (16) namedOperandAssignment ::= NAMEDOPERAND COLONEQUAL operand */
912
   -3,  /* (17) eventFilter ::= selectClause whereClause forClause */
913
    0,  /* (18) selectClause ::= */
914
   -2,  /* (19) selectClause ::= SELECT selectClauseList */
915
    0,  /* (20) whereClause ::= */
916
    0,  /* (21) forClause ::= */
917
   -2,  /* (22) forClause ::= FOR namedOperandAssignmentList */
918
   -1,  /* (23) namedOperandAssignmentList ::= namedOperandAssignment */
919
   -3,  /* (24) namedOperandAssignmentList ::= namedOperandAssignmentList COMMA namedOperandAssignment */
920
};
921
922
static void yy_accept(yyParser*);  /* Forward Declaration */
923
924
/*
925
** Perform a reduce action and the shift that must immediately
926
** follow the reduce.
927
**
928
** The yyLookahead and yyLookaheadToken parameters provide reduce actions
929
** access to the lookahead token (if any).  The yyLookahead will be YYNOCODE
930
** if the lookahead token has already been consumed.  As this procedure is
931
** only called from one place, optimizing compilers will in-line it, which
932
** means that the extra parameters have no performance impact.
933
*/
934
static YYACTIONTYPE yy_reduce(
935
  yyParser *yypParser,         /* The parser */
936
  unsigned int yyruleno,       /* Number of the rule by which to reduce */
937
  int yyLookahead,             /* Lookahead token, or YYNOCODE if none */
938
  UA_EventFilterParseTOKENTYPE yyLookaheadToken  /* Value of the lookahead token */
939
  UA_EventFilterParseCTX_PDECL                   /* %extra_context */
940
0
){
941
0
  int yygoto;                     /* The next state */
942
0
  YYACTIONTYPE yyact;             /* The next action */
943
0
  yyStackEntry *yymsp;            /* The top of the parser's stack */
944
0
  int yysize;                     /* Amount to pop the stack */
945
0
  UA_EventFilterParseARG_FETCH
946
0
  (void)yyLookahead;
947
0
  (void)yyLookaheadToken;
948
0
  yymsp = yypParser->yytos;
949
950
0
  switch( yyruleno ){
951
  /* Beginning here are the reduction cases.  A typical example
952
  ** follows:
953
  **   case 0:
954
  **  #line <lineno> <grammarfile>
955
  **     { ... }           // User supplied code
956
  **  #line <lineno> <thisfile>
957
  **     break;
958
  */
959
/********** Begin reduce actions **********************************************/
960
0
        YYMINORTYPE yylhsminor;
961
0
      case 0: /* selectClauseList ::= operand */
962
0
{ append_select(ctx, yymsp[0].minor.yy0); }
963
0
        break;
964
0
      case 1: /* selectClauseList ::= selectClauseList COMMA operand */
965
0
{ append_select(ctx, yymsp[0].minor.yy0); }
966
0
  yy_destructor(yypParser,8,&yymsp[-1].minor);
967
0
        break;
968
0
      case 2: /* whereClause ::= WHERE operand */
969
0
{  yy_destructor(yypParser,9,&yymsp[-1].minor);
970
0
{ ctx->top = yymsp[0].minor.yy0; }
971
0
}
972
0
        break;
973
0
      case 3: /* operand ::= LPAREN operand RPAREN */
974
0
{  yy_destructor(yypParser,10,&yymsp[-2].minor);
975
0
{ yymsp[-2].minor.yy0 = yymsp[-1].minor.yy0; }
976
0
  yy_destructor(yypParser,11,&yymsp[0].minor);
977
0
}
978
0
        break;
979
0
      case 4: /* operand ::= operator */
980
0
      case 5: /* operand ::= LITERAL */ yytestcase(yyruleno==5);
981
0
      case 6: /* operand ::= SAO */ yytestcase(yyruleno==6);
982
0
      case 7: /* operand ::= NAMEDOPERAND */ yytestcase(yyruleno==7);
983
0
      case 14: /* operandList ::= operand */ yytestcase(yyruleno==14);
984
0
{ yylhsminor.yy0 = yymsp[0].minor.yy0; }
985
0
  yymsp[0].minor.yy0 = yylhsminor.yy0;
986
0
        break;
987
0
      case 8: /* operator ::= UNARY_OP operand */
988
0
{ yylhsminor.yy0 = yymsp[-1].minor.yy0; append_operand(yylhsminor.yy0, yymsp[0].minor.yy0); }
989
0
  yymsp[-1].minor.yy0 = yylhsminor.yy0;
990
0
        break;
991
0
      case 9: /* operator ::= operand AND operand */
992
0
      case 10: /* operator ::= operand OR operand */ yytestcase(yyruleno==10);
993
0
      case 11: /* operator ::= operand BINARY_OP operand */ yytestcase(yyruleno==11);
994
0
{ yylhsminor.yy0 = yymsp[-1].minor.yy0; append_operand(yylhsminor.yy0, yymsp[-2].minor.yy0), append_operand(yylhsminor.yy0, yymsp[0].minor.yy0); }
995
0
  yymsp[-2].minor.yy0 = yylhsminor.yy0;
996
0
        break;
997
0
      case 12: /* operator ::= operand BETWEEN LBRACKET operand COMMA operand RBRACKET */
998
0
{ yylhsminor.yy0 = yymsp[-5].minor.yy0; append_operand(yylhsminor.yy0, yymsp[-6].minor.yy0); append_operand(yylhsminor.yy0, yymsp[-3].minor.yy0); append_operand(yylhsminor.yy0, yymsp[-1].minor.yy0); }
999
0
  yy_destructor(yypParser,15,&yymsp[-4].minor);
1000
0
  yy_destructor(yypParser,8,&yymsp[-2].minor);
1001
0
  yy_destructor(yypParser,16,&yymsp[0].minor);
1002
0
  yymsp[-6].minor.yy0 = yylhsminor.yy0;
1003
0
        break;
1004
0
      case 13: /* operator ::= operand INLIST LBRACKET operandList RBRACKET */
1005
0
{ yylhsminor.yy0 = yymsp[-3].minor.yy0; append_operand(yylhsminor.yy0, yymsp[-4].minor.yy0); while(yymsp[-1].minor.yy0) { append_operand(yylhsminor.yy0, yymsp[-1].minor.yy0); yymsp[-1].minor.yy0 = yymsp[-1].minor.yy0->next; } }
1006
0
  yy_destructor(yypParser,15,&yymsp[-2].minor);
1007
0
  yy_destructor(yypParser,16,&yymsp[0].minor);
1008
0
  yymsp[-4].minor.yy0 = yylhsminor.yy0;
1009
0
        break;
1010
0
      case 15: /* operandList ::= operator COMMA operandList */
1011
0
{ yylhsminor.yy0 = yymsp[-2].minor.yy0; yymsp[-2].minor.yy0->next = yymsp[0].minor.yy0; }
1012
0
  yy_destructor(yypParser,8,&yymsp[-1].minor);
1013
0
  yymsp[-2].minor.yy0 = yylhsminor.yy0;
1014
0
        break;
1015
0
      case 16: /* namedOperandAssignment ::= NAMEDOPERAND COLONEQUAL operand */
1016
0
{ yymsp[0].minor.yy0->ref = save_string(yymsp[-2].minor.yy0->operand.ref); }
1017
0
  yy_destructor(yypParser,18,&yymsp[-1].minor);
1018
0
        break;
1019
0
      case 19: /* selectClause ::= SELECT selectClauseList */
1020
0
{  yy_destructor(yypParser,7,&yymsp[-1].minor);
1021
0
{
1022
0
}
1023
0
}
1024
0
        break;
1025
0
      case 22: /* forClause ::= FOR namedOperandAssignmentList */
1026
0
{  yy_destructor(yypParser,17,&yymsp[-1].minor);
1027
0
{
1028
0
}
1029
0
}
1030
0
        break;
1031
0
      case 24: /* namedOperandAssignmentList ::= namedOperandAssignmentList COMMA namedOperandAssignment */
1032
0
{
1033
0
}
1034
0
  yy_destructor(yypParser,8,&yymsp[-1].minor);
1035
0
        break;
1036
0
      default:
1037
0
      /* (17) eventFilter ::= selectClause whereClause forClause */ yytestcase(yyruleno==17);
1038
0
      /* (18) selectClause ::= */ yytestcase(yyruleno==18);
1039
0
      /* (20) whereClause ::= */ yytestcase(yyruleno==20);
1040
0
      /* (21) forClause ::= */ yytestcase(yyruleno==21);
1041
0
      /* (23) namedOperandAssignmentList ::= namedOperandAssignment (OPTIMIZED OUT) */ assert(yyruleno!=23);
1042
0
        break;
1043
/********** End reduce actions ************************************************/
1044
0
  };
1045
0
  assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) );
1046
0
  yygoto = yyRuleInfoLhs[yyruleno];
1047
0
  yysize = yyRuleInfoNRhs[yyruleno];
1048
0
  yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto);
1049
1050
  /* There are no SHIFTREDUCE actions on nonterminals because the table
1051
  ** generator has simplified them to pure REDUCE actions. */
1052
0
  assert( !(yyact>YY_MAX_SHIFT && yyact<=YY_MAX_SHIFTREDUCE) );
1053
1054
  /* It is not possible for a REDUCE to be followed by an error */
1055
0
  assert( yyact!=YY_ERROR_ACTION );
1056
1057
0
  yymsp += yysize+1;
1058
0
  yypParser->yytos = yymsp;
1059
0
  yymsp->stateno = (YYACTIONTYPE)yyact;
1060
0
  yymsp->major = (YYCODETYPE)yygoto;
1061
0
  yyTraceShift(yypParser, yyact, "... then shift");
1062
0
  return yyact;
1063
0
}
1064
1065
/*
1066
** The following code executes when the parse fails
1067
*/
1068
#ifndef YYNOERRORRECOVERY
1069
static void yy_parse_failed(
1070
  yyParser *yypParser           /* The parser */
1071
0
){
1072
0
  UA_EventFilterParseARG_FETCH
1073
0
  UA_EventFilterParseCTX_FETCH
1074
#ifndef NDEBUG
1075
  if( yyTraceFILE ){
1076
    fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
1077
  }
1078
#endif
1079
0
  while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
1080
  /* Here code is inserted which will be executed whenever the
1081
  ** parser fails */
1082
/************ Begin %parse_failure code ***************************************/
1083
/************ End %parse_failure code *****************************************/
1084
  UA_EventFilterParseARG_STORE /* Suppress warning about unused %extra_argument variable */
1085
0
  UA_EventFilterParseCTX_STORE
1086
0
}
1087
#endif /* YYNOERRORRECOVERY */
1088
1089
/*
1090
** The following code executes when a syntax error first occurs.
1091
*/
1092
static void yy_syntax_error(
1093
  yyParser *yypParser,           /* The parser */
1094
  int yymajor,                   /* The major type of the error token */
1095
  UA_EventFilterParseTOKENTYPE yyminor         /* The minor type of the error token */
1096
0
){
1097
0
  UA_EventFilterParseARG_FETCH
1098
0
  UA_EventFilterParseCTX_FETCH
1099
0
#define TOKEN yyminor
1100
/************ Begin %syntax_error code ****************************************/
1101
0
 ctx->error = UA_STATUSCODE_BADINTERNALERROR; 
1102
/************ End %syntax_error code ******************************************/
1103
  UA_EventFilterParseARG_STORE /* Suppress warning about unused %extra_argument variable */
1104
0
  UA_EventFilterParseCTX_STORE
1105
0
}
1106
1107
/*
1108
** The following is executed when the parser accepts
1109
*/
1110
static void yy_accept(
1111
  yyParser *yypParser           /* The parser */
1112
0
){
1113
0
  UA_EventFilterParseARG_FETCH
1114
0
  UA_EventFilterParseCTX_FETCH
1115
#ifndef NDEBUG
1116
  if( yyTraceFILE ){
1117
    fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
1118
  }
1119
#endif
1120
0
#ifndef YYNOERRORRECOVERY
1121
0
  yypParser->yyerrcnt = -1;
1122
0
#endif
1123
0
  assert( yypParser->yytos==yypParser->yystack );
1124
  /* Here code is inserted which will be executed whenever the
1125
  ** parser accepts */
1126
/*********** Begin %parse_accept code *****************************************/
1127
/*********** End %parse_accept code *******************************************/
1128
  UA_EventFilterParseARG_STORE /* Suppress warning about unused %extra_argument variable */
1129
0
  UA_EventFilterParseCTX_STORE
1130
0
}
1131
1132
/* The main parser program.
1133
** The first argument is a pointer to a structure obtained from
1134
** "UA_EventFilterParseAlloc" which describes the current state of the parser.
1135
** The second argument is the major token number.  The third is
1136
** the minor token.  The fourth optional argument is whatever the
1137
** user wants (and specified in the grammar) and is available for
1138
** use by the action routines.
1139
**
1140
** Inputs:
1141
** <ul>
1142
** <li> A pointer to the parser (an opaque structure.)
1143
** <li> The major token number.
1144
** <li> The minor token number.
1145
** <li> An option argument of a grammar-specified type.
1146
** </ul>
1147
**
1148
** Outputs:
1149
** None.
1150
*/
1151
void UA_EventFilterParse(
1152
  void *yyp,                   /* The parser */
1153
  int yymajor,                 /* The major token code number */
1154
  UA_EventFilterParseTOKENTYPE yyminor       /* The value for the token */
1155
  UA_EventFilterParseARG_PDECL               /* Optional %extra_argument parameter */
1156
0
){
1157
0
  YYMINORTYPE yyminorunion;
1158
0
  YYACTIONTYPE yyact;   /* The parser action. */
1159
0
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
1160
0
  int yyendofinput;     /* True if we are at the end of input */
1161
0
#endif
1162
#ifdef YYERRORSYMBOL
1163
  int yyerrorhit = 0;   /* True if yymajor has invoked an error */
1164
#endif
1165
0
  yyParser *yypParser = (yyParser*)yyp;  /* The parser */
1166
0
  UA_EventFilterParseCTX_FETCH
1167
0
  UA_EventFilterParseARG_STORE
1168
1169
0
  assert( yypParser->yytos!=0 );
1170
0
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
1171
0
  yyendofinput = (yymajor==0);
1172
0
#endif
1173
1174
0
  yyact = yypParser->yytos->stateno;
1175
#ifndef NDEBUG
1176
  if( yyTraceFILE ){
1177
    if( yyact < YY_MIN_REDUCE ){
1178
      fprintf(yyTraceFILE,"%sInput '%s' in state %d\n",
1179
              yyTracePrompt,yyTokenName[yymajor],yyact);
1180
    }else{
1181
      fprintf(yyTraceFILE,"%sInput '%s' with pending reduce %d\n",
1182
              yyTracePrompt,yyTokenName[yymajor],yyact-YY_MIN_REDUCE);
1183
    }
1184
  }
1185
#endif
1186
1187
0
  while(1){ /* Exit by "break" */
1188
0
    assert( yypParser->yytos>=yypParser->yystack );
1189
0
    assert( yyact==yypParser->yytos->stateno );
1190
0
    yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact);
1191
0
    if( yyact >= YY_MIN_REDUCE ){
1192
0
      unsigned int yyruleno = yyact - YY_MIN_REDUCE; /* Reduce by this rule */
1193
#ifndef NDEBUG
1194
      assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) );
1195
      if( yyTraceFILE ){
1196
        int yysize = yyRuleInfoNRhs[yyruleno];
1197
        if( yysize ){
1198
          fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n",
1199
            yyTracePrompt,
1200
            yyruleno, yyRuleName[yyruleno],
1201
            yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action",
1202
            yypParser->yytos[yysize].stateno);
1203
        }else{
1204
          fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n",
1205
            yyTracePrompt, yyruleno, yyRuleName[yyruleno],
1206
            yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action");
1207
        }
1208
      }
1209
#endif /* NDEBUG */
1210
1211
      /* Check that the stack is large enough to grow by a single entry
1212
      ** if the RHS of the rule is empty.  This ensures that there is room
1213
      ** enough on the stack to push the LHS value */
1214
0
      if( yyRuleInfoNRhs[yyruleno]==0 ){
1215
#ifdef YYTRACKMAXSTACKDEPTH
1216
        if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
1217
          yypParser->yyhwm++;
1218
          assert( yypParser->yyhwm ==
1219
                  (int)(yypParser->yytos - yypParser->yystack));
1220
        }
1221
#endif
1222
0
#if YYSTACKDEPTH>0 
1223
0
        if( yypParser->yytos>=yypParser->yystackEnd ){
1224
0
          yyStackOverflow(yypParser);
1225
0
          break;
1226
0
        }
1227
#else
1228
        if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
1229
          if( yyGrowStack(yypParser) ){
1230
            yyStackOverflow(yypParser);
1231
            break;
1232
          }
1233
        }
1234
#endif
1235
0
      }
1236
0
      yyact = yy_reduce(yypParser,yyruleno,yymajor,yyminor UA_EventFilterParseCTX_PARAM);
1237
0
    }else if( yyact <= YY_MAX_SHIFTREDUCE ){
1238
0
      yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor);
1239
0
#ifndef YYNOERRORRECOVERY
1240
0
      yypParser->yyerrcnt--;
1241
0
#endif
1242
0
      break;
1243
0
    }else if( yyact==YY_ACCEPT_ACTION ){
1244
0
      yypParser->yytos--;
1245
0
      yy_accept(yypParser);
1246
0
      return;
1247
0
    }else{
1248
0
      assert( yyact == YY_ERROR_ACTION );
1249
0
      yyminorunion.yy0 = yyminor;
1250
#ifdef YYERRORSYMBOL
1251
      int yymx;
1252
#endif
1253
#ifndef NDEBUG
1254
      if( yyTraceFILE ){
1255
        fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
1256
      }
1257
#endif
1258
#ifdef YYERRORSYMBOL
1259
      /* A syntax error has occurred.
1260
      ** The response to an error depends upon whether or not the
1261
      ** grammar defines an error token "ERROR".  
1262
      **
1263
      ** This is what we do if the grammar does define ERROR:
1264
      **
1265
      **  * Call the %syntax_error function.
1266
      **
1267
      **  * Begin popping the stack until we enter a state where
1268
      **    it is legal to shift the error symbol, then shift
1269
      **    the error symbol.
1270
      **
1271
      **  * Set the error count to three.
1272
      **
1273
      **  * Begin accepting and shifting new tokens.  No new error
1274
      **    processing will occur until three tokens have been
1275
      **    shifted successfully.
1276
      **
1277
      */
1278
      if( yypParser->yyerrcnt<0 ){
1279
        yy_syntax_error(yypParser,yymajor,yyminor);
1280
      }
1281
      yymx = yypParser->yytos->major;
1282
      if( yymx==YYERRORSYMBOL || yyerrorhit ){
1283
#ifndef NDEBUG
1284
        if( yyTraceFILE ){
1285
          fprintf(yyTraceFILE,"%sDiscard input token %s\n",
1286
             yyTracePrompt,yyTokenName[yymajor]);
1287
        }
1288
#endif
1289
        yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
1290
        yymajor = YYNOCODE;
1291
      }else{
1292
        while( yypParser->yytos > yypParser->yystack ){
1293
          yyact = yy_find_reduce_action(yypParser->yytos->stateno,
1294
                                        YYERRORSYMBOL);
1295
          if( yyact<=YY_MAX_SHIFTREDUCE ) break;
1296
          yy_pop_parser_stack(yypParser);
1297
        }
1298
        if( yypParser->yytos <= yypParser->yystack || yymajor==0 ){
1299
          yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
1300
          yy_parse_failed(yypParser);
1301
#ifndef YYNOERRORRECOVERY
1302
          yypParser->yyerrcnt = -1;
1303
#endif
1304
          yymajor = YYNOCODE;
1305
        }else if( yymx!=YYERRORSYMBOL ){
1306
          yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor);
1307
        }
1308
      }
1309
      yypParser->yyerrcnt = 3;
1310
      yyerrorhit = 1;
1311
      if( yymajor==YYNOCODE ) break;
1312
      yyact = yypParser->yytos->stateno;
1313
#elif defined(YYNOERRORRECOVERY)
1314
      /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
1315
      ** do any kind of error recovery.  Instead, simply invoke the syntax
1316
      ** error routine and continue going as if nothing had happened.
1317
      **
1318
      ** Applications can set this macro (for example inside %include) if
1319
      ** they intend to abandon the parse upon the first syntax error seen.
1320
      */
1321
      yy_syntax_error(yypParser,yymajor, yyminor);
1322
      yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
1323
      break;
1324
#else  /* YYERRORSYMBOL is not defined */
1325
      /* This is what we do if the grammar does not define ERROR:
1326
      **
1327
      **  * Report an error message, and throw away the input token.
1328
      **
1329
      **  * If the input token is $, then fail the parse.
1330
      **
1331
      ** As before, subsequent error messages are suppressed until
1332
      ** three input tokens have been successfully shifted.
1333
      */
1334
0
      if( yypParser->yyerrcnt<=0 ){
1335
0
        yy_syntax_error(yypParser,yymajor, yyminor);
1336
0
      }
1337
0
      yypParser->yyerrcnt = 3;
1338
0
      yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
1339
0
      if( yyendofinput ){
1340
0
        yy_parse_failed(yypParser);
1341
0
#ifndef YYNOERRORRECOVERY
1342
0
        yypParser->yyerrcnt = -1;
1343
0
#endif
1344
0
      }
1345
0
      break;
1346
0
#endif
1347
0
    }
1348
0
  }
1349
#ifndef NDEBUG
1350
  if( yyTraceFILE ){
1351
    yyStackEntry *i;
1352
    char cDiv = '[';
1353
    fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt);
1354
    for(i=&yypParser->yystack[1]; i<=yypParser->yytos; i++){
1355
      fprintf(yyTraceFILE,"%c%s", cDiv, yyTokenName[i->major]);
1356
      cDiv = ' ';
1357
    }
1358
    fprintf(yyTraceFILE,"]\n");
1359
  }
1360
#endif
1361
0
  return;
1362
0
}
1363
1364
/*
1365
** Return the fallback token corresponding to canonical token iToken, or
1366
** 0 if iToken has no fallback.
1367
*/
1368
0
int UA_EventFilterParseFallback(int iToken){
1369
#ifdef YYFALLBACK
1370
  assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) );
1371
  return yyFallback[iToken];
1372
#else
1373
0
  (void)iToken;
1374
0
  return 0;
1375
0
#endif
1376
0
}
1377
1378
1379
/* Main method driving the generated parser from the lexer */
1380
UA_StatusCode
1381
UA_EventFilter_parse(UA_EventFilter *filter, UA_ByteString content,
1382
0
                     UA_EventFilterParserOptions *options) {
1383
0
    yyParser parser;
1384
0
    UA_EventFilterParseInit(&parser);
1385
1386
0
    EFParseContext ctx;
1387
0
    memset(&ctx, 0, sizeof(EFParseContext));
1388
0
    TAILQ_INIT(&ctx.select_operands);
1389
0
    ctx.logger = (options) ? options->logger : NULL;
1390
1391
0
    size_t pos = 0;
1392
0
    unsigned line = 0, col = 0;
1393
0
    Operand *token = NULL;
1394
0
    int tokenId = 0;
1395
0
    UA_StatusCode res;
1396
0
    do {
1397
        /* Skip whitespace */
1398
0
        res = UA_EventFilter_skip(content, &pos, &ctx);
1399
0
        if(res != UA_STATUSCODE_GOOD)
1400
0
            goto done;
1401
1402
        /* Get the next token */
1403
0
        size_t begin = pos;
1404
0
        tokenId = UA_EventFilter_lex(content, &pos, &ctx, &token);
1405
0
        UA_EventFilterParse(&parser, tokenId, token, &ctx);
1406
1407
        /* Print an error if the parser could not handle the token */
1408
0
        if(ctx.error != UA_STATUSCODE_GOOD) {
1409
0
            pos2lines(content, begin, &line, &col);
1410
0
            int extractLen = 10;
1411
0
            if(pos - begin < 10)
1412
0
                extractLen = (int)(pos - begin);
1413
0
            UA_LOG_ERROR(ctx.logger, UA_LOGCATEGORY_USERLAND,
1414
0
                         "Could not process token at line %u, column %u: "
1415
0
                         "%.*s...", line, col, extractLen, content.data + begin);
1416
0
            res = UA_STATUSCODE_BADINTERNALERROR;
1417
0
            goto done;
1418
0
        }
1419
0
    } while(tokenId);
1420
1421
    /* Skip trailing whitespace */
1422
0
    res = UA_EventFilter_skip(content, &pos, &ctx);
1423
0
    if(res != UA_STATUSCODE_GOOD)
1424
0
        goto done;
1425
1426
    /* The lexer stopped before the end of the input.
1427
     * The token could not be read. */
1428
0
    if(pos < content.length) {
1429
0
        pos2lines(content, pos, &line, &col);
1430
0
        UA_LOG_ERROR(ctx.logger, UA_LOGCATEGORY_USERLAND,
1431
0
                     "Token after the end of the EventFilter expression "
1432
0
                     "at line %u, column %u", line, col);
1433
0
        res = UA_STATUSCODE_BADINTERNALERROR;
1434
0
        goto done;
1435
0
    }
1436
1437
    /* Create the filter from the parse-tree */
1438
0
    UA_EventFilter_init(filter);
1439
0
    res = create_filter(&ctx, filter);
1440
1441
0
 done:
1442
0
    UA_EventFilterParseFinalize(&parser);
1443
0
    EFParseContext_clear(&ctx);
1444
0
    return res;
1445
0
}