1 /* A Bison parser, made by GNU Bison 3.3.2.  */
2 
3 /* Bison implementation for Yacc-like parsers in C
4 
5    Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
6    Inc.
7 
8    This program is free software: you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation, either version 3 of the License, or
11    (at your option) any later version.
12 
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17 
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
20 
21 /* As a special exception, you may create a larger work that contains
22    part or all of the Bison parser skeleton and distribute that work
23    under terms of your choice, so long as that work isn't itself a
24    parser generator using the skeleton or a modified version thereof
25    as a parser skeleton.  Alternatively, if you modify or redistribute
26    the parser skeleton itself, you may (at your option) remove this
27    special exception, which will cause the skeleton and the resulting
28    Bison output files to be licensed under the GNU General Public
29    License without this special exception.
30 
31    This special exception was added by the Free Software Foundation in
32    version 2.2 of Bison.  */
33 
34 /* C LALR(1) parser skeleton written by Richard Stallman, by
35    simplifying the original so-called "semantic" parser.  */
36 
37 /* All symbols defined below should begin with yy or YY, to avoid
38    infringing on user name space.  This should be done even for local
39    variables, as they might otherwise be expanded by user macros.
40    There are some unavoidable exceptions within include files to
41    define necessary library symbols; they are noted "INFRINGES ON
42    USER NAME SPACE" below.  */
43 
44 /* Undocumented macros, especially those whose name start with YY_,
45    are private implementation details.  Do not rely on them.  */
46 
47 /* Identify Bison output.  */
48 #define YYBISON 1
49 
50 /* Bison version.  */
51 #define YYBISON_VERSION "3.3.2"
52 
53 /* Skeleton name.  */
54 #define YYSKELETON_NAME "yacc.c"
55 
56 /* Pure parsers.  */
57 #define YYPURE 1
58 
59 /* Push parsers.  */
60 #define YYPUSH 0
61 
62 /* Pull parsers.  */
63 #define YYPULL 1
64 
65 
66 /* Substitute the variable and function names.  */
67 #define yyparse         InstrScript_parse
68 #define yylex           InstrScript_lex
69 #define yyerror         InstrScript_error
70 #define yydebug         InstrScript_debug
71 #define yynerrs         InstrScript_nerrs
72 
73 
74 /* First part of user prologue.  */
75 #line 12 "parser.y" /* yacc.c:337  */
76 
77     #define YYERROR_VERBOSE 1
78     #include "parser_shared.h"
79     #include <string>
80     #include <map>
81     using namespace LinuxSampler;
82 
83     void InstrScript_error(YYLTYPE* locp, LinuxSampler::ParserContext* context, const char* err);
84     void InstrScript_warning(YYLTYPE* locp, LinuxSampler::ParserContext* context, const char* txt);
85     int InstrScript_tnamerr(char* yyres, const char* yystr);
86     int InstrScript_lex(YYSTYPE* lvalp, YYLTYPE* llocp, void* scanner);
87     #define scanner context->scanner
88     #define PARSE_ERR(loc,txt)  yyerror(&loc, context, txt)
89     #define PARSE_WRN(loc,txt)  InstrScript_warning(&loc, context, txt)
90     #define PARSE_DROP(loc) \
91         context->addPreprocessorComment( \
92             loc.first_line, loc.last_line, loc.first_column+1, \
93             loc.last_column+1, loc.first_byte, loc.length_bytes \
94         );
95     #define CODE_BLOCK(loc) { \
96         .firstLine = loc.first_line, .lastLine = loc.last_line, \
97         .firstColumn = loc.first_column+1, .lastColumn = loc.last_column+1, \
98         .firstByte = loc.first_byte, .lengthBytes = loc.length_bytes \
99     }
100     #define ASSIGNED_EXPR_BLOCK(loc) { \
101         .firstLine = loc.first_line, .lastLine = loc.last_line, \
102         .firstColumn = loc.first_column+3, .lastColumn = loc.last_column+1, \
103         .firstByte = loc.first_byte+2, .lengthBytes = loc.length_bytes-2 \
104     }
105     #define yytnamerr(res,str)  InstrScript_tnamerr(res, str)
106 
107 #line 108 "y.tab.c" /* yacc.c:337  */
108 # ifndef YY_NULLPTR
109 #  if defined __cplusplus
110 #   if 201103L <= __cplusplus
111 #    define YY_NULLPTR nullptr
112 #   else
113 #    define YY_NULLPTR 0
114 #   endif
115 #  else
116 #   define YY_NULLPTR ((void*)0)
117 #  endif
118 # endif
119 
120 /* Enabling verbose error messages.  */
121 #ifdef YYERROR_VERBOSE
122 # undef YYERROR_VERBOSE
123 # define YYERROR_VERBOSE 1
124 #else
125 # define YYERROR_VERBOSE 1
126 #endif
127 
128 /* In a future release of Bison, this section will be replaced
129    by #include "y.tab.h".  */
130 #ifndef YY_INSTRSCRIPT_Y_TAB_H_INCLUDED
131 # define YY_INSTRSCRIPT_Y_TAB_H_INCLUDED
132 /* Debug traces.  */
133 #ifndef YYDEBUG
134 # define YYDEBUG 0
135 #endif
136 #if YYDEBUG
137 extern int InstrScript_debug;
138 #endif
139 
140 /* Token type.  */
141 #ifndef YYTOKENTYPE
142 # define YYTOKENTYPE
143   enum yytokentype
144   {
145     END_OF_FILE = 0,
146     INTEGER = 258,
147     REAL = 259,
148     INTEGER_UNIT = 260,
149     REAL_UNIT = 261,
150     STRING = 262,
151     IDENTIFIER = 263,
152     VARIABLE = 264,
153     ON = 265,
154     END = 266,
155     INIT = 267,
156     NOTE = 268,
157     RELEASE = 269,
158     CONTROLLER = 270,
159     RPN = 271,
160     NRPN = 272,
161     DECLARE = 273,
162     ASSIGNMENT = 274,
163     CONST_ = 275,
164     POLYPHONIC = 276,
165     PATCH = 277,
166     WHILE = 278,
167     SYNCHRONIZED = 279,
168     IF = 280,
169     ELSE = 281,
170     SELECT = 282,
171     CASE = 283,
172     TO = 284,
173     OR = 285,
174     AND = 286,
175     NOT = 287,
176     BITWISE_OR = 288,
177     BITWISE_AND = 289,
178     BITWISE_NOT = 290,
179     FUNCTION = 291,
180     CALL = 292,
181     MOD = 293,
182     LE = 294,
183     GE = 295,
184     UNKNOWN_CHAR = 296
185   };
186 #endif
187 /* Tokens.  */
188 #define END_OF_FILE 0
189 #define INTEGER 258
190 #define REAL 259
191 #define INTEGER_UNIT 260
192 #define REAL_UNIT 261
193 #define STRING 262
194 #define IDENTIFIER 263
195 #define VARIABLE 264
196 #define ON 265
197 #define END 266
198 #define INIT 267
199 #define NOTE 268
200 #define RELEASE 269
201 #define CONTROLLER 270
202 #define RPN 271
203 #define NRPN 272
204 #define DECLARE 273
205 #define ASSIGNMENT 274
206 #define CONST_ 275
207 #define POLYPHONIC 276
208 #define PATCH 277
209 #define WHILE 278
210 #define SYNCHRONIZED 279
211 #define IF 280
212 #define ELSE 281
213 #define SELECT 282
214 #define CASE 283
215 #define TO 284
216 #define OR 285
217 #define AND 286
218 #define NOT 287
219 #define BITWISE_OR 288
220 #define BITWISE_AND 289
221 #define BITWISE_NOT 290
222 #define FUNCTION 291
223 #define CALL 292
224 #define MOD 293
225 #define LE 294
226 #define GE 295
227 #define UNKNOWN_CHAR 296
228 
229 /* Value type.  */
230 
231 /* Location type.  */
232 #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
233 typedef struct YYLTYPE YYLTYPE;
234 struct YYLTYPE
235 {
236   int first_line;
237   int first_column;
238   int last_line;
239   int last_column;
240 };
241 # define YYLTYPE_IS_DECLARED 1
242 # define YYLTYPE_IS_TRIVIAL 1
243 #endif
244 
245 
246 
247 int InstrScript_parse (LinuxSampler::ParserContext* context);
248 
249 #endif /* !YY_INSTRSCRIPT_Y_TAB_H_INCLUDED  */
250 
251 
252 
253 #ifdef short
254 # undef short
255 #endif
256 
257 #ifdef YYTYPE_UINT8
258 typedef YYTYPE_UINT8 yytype_uint8;
259 #else
260 typedef unsigned char yytype_uint8;
261 #endif
262 
263 #ifdef YYTYPE_INT8
264 typedef YYTYPE_INT8 yytype_int8;
265 #else
266 typedef signed char yytype_int8;
267 #endif
268 
269 #ifdef YYTYPE_UINT16
270 typedef YYTYPE_UINT16 yytype_uint16;
271 #else
272 typedef unsigned short yytype_uint16;
273 #endif
274 
275 #ifdef YYTYPE_INT16
276 typedef YYTYPE_INT16 yytype_int16;
277 #else
278 typedef short yytype_int16;
279 #endif
280 
281 #ifndef YYSIZE_T
282 # ifdef __SIZE_TYPE__
283 #  define YYSIZE_T __SIZE_TYPE__
284 # elif defined size_t
285 #  define YYSIZE_T size_t
286 # elif ! defined YYSIZE_T
287 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
288 #  define YYSIZE_T size_t
289 # else
290 #  define YYSIZE_T unsigned
291 # endif
292 #endif
293 
294 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
295 
296 #ifndef YY_
297 # if defined YYENABLE_NLS && YYENABLE_NLS
298 #  if ENABLE_NLS
299 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
300 #   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
301 #  endif
302 # endif
303 # ifndef YY_
304 #  define YY_(Msgid) Msgid
305 # endif
306 #endif
307 
308 #ifndef YY_ATTRIBUTE
309 # if (defined __GNUC__                                               \
310       && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__)))  \
311      || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
312 #  define YY_ATTRIBUTE(Spec) __attribute__(Spec)
313 # else
314 #  define YY_ATTRIBUTE(Spec) /* empty */
315 # endif
316 #endif
317 
318 #ifndef YY_ATTRIBUTE_PURE
319 # define YY_ATTRIBUTE_PURE   YY_ATTRIBUTE ((__pure__))
320 #endif
321 
322 #ifndef YY_ATTRIBUTE_UNUSED
323 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
324 #endif
325 
326 /* Suppress unused-variable warnings by "using" E.  */
327 #if ! defined lint || defined __GNUC__
328 # define YYUSE(E) ((void) (E))
329 #else
330 # define YYUSE(E) /* empty */
331 #endif
332 
333 #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
334 /* Suppress an incorrect diagnostic about yylval being uninitialized.  */
335 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
336     _Pragma ("GCC diagnostic push") \
337     _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
338     _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
339 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
340     _Pragma ("GCC diagnostic pop")
341 #else
342 # define YY_INITIAL_VALUE(Value) Value
343 #endif
344 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
345 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
346 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
347 #endif
348 #ifndef YY_INITIAL_VALUE
349 # define YY_INITIAL_VALUE(Value) /* Nothing. */
350 #endif
351 
352 
353 #if ! defined yyoverflow || YYERROR_VERBOSE
354 
355 /* The parser invokes alloca or malloc; define the necessary symbols.  */
356 
357 # ifdef YYSTACK_USE_ALLOCA
358 #  if YYSTACK_USE_ALLOCA
359 #   ifdef __GNUC__
360 #    define YYSTACK_ALLOC __builtin_alloca
361 #   elif defined __BUILTIN_VA_ARG_INCR
362 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
363 #   elif defined _AIX
364 #    define YYSTACK_ALLOC __alloca
365 #   elif defined _MSC_VER
366 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
367 #    define alloca _alloca
368 #   else
369 #    define YYSTACK_ALLOC alloca
370 #    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
371 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
372       /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
373 #     ifndef EXIT_SUCCESS
374 #      define EXIT_SUCCESS 0
375 #     endif
376 #    endif
377 #   endif
378 #  endif
379 # endif
380 
381 # ifdef YYSTACK_ALLOC
382    /* Pacify GCC's 'empty if-body' warning.  */
383 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
384 #  ifndef YYSTACK_ALLOC_MAXIMUM
385     /* The OS might guarantee only one guard page at the bottom of the stack,
386        and a page size can be as small as 4096 bytes.  So we cannot safely
387        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
388        to allow for a few compiler-allocated temporary stack slots.  */
389 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
390 #  endif
391 # else
392 #  define YYSTACK_ALLOC YYMALLOC
393 #  define YYSTACK_FREE YYFREE
394 #  ifndef YYSTACK_ALLOC_MAXIMUM
395 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
396 #  endif
397 #  if (defined __cplusplus && ! defined EXIT_SUCCESS \
398        && ! ((defined YYMALLOC || defined malloc) \
399              && (defined YYFREE || defined free)))
400 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
401 #   ifndef EXIT_SUCCESS
402 #    define EXIT_SUCCESS 0
403 #   endif
404 #  endif
405 #  ifndef YYMALLOC
406 #   define YYMALLOC malloc
407 #   if ! defined malloc && ! defined EXIT_SUCCESS
408 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
409 #   endif
410 #  endif
411 #  ifndef YYFREE
412 #   define YYFREE free
413 #   if ! defined free && ! defined EXIT_SUCCESS
414 void free (void *); /* INFRINGES ON USER NAME SPACE */
415 #   endif
416 #  endif
417 # endif
418 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
419 
420 
421 #if (! defined yyoverflow \
422      && (! defined __cplusplus \
423          || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
424              && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
425 
426 /* A type that is properly aligned for any stack member.  */
427 union yyalloc
428 {
429   yytype_int16 yyss_alloc;
430   YYSTYPE yyvs_alloc;
431   YYLTYPE yyls_alloc;
432 };
433 
434 /* The size of the maximum gap between one aligned stack and the next.  */
435 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
436 
437 /* The size of an array large to enough to hold all stacks, each with
438    N elements.  */
439 # define YYSTACK_BYTES(N) \
440      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
441       + 2 * YYSTACK_GAP_MAXIMUM)
442 
443 # define YYCOPY_NEEDED 1
444 
445 /* Relocate STACK from its old location to the new one.  The
446    local variables YYSIZE and YYSTACKSIZE give the old and new number of
447    elements in the stack, and YYPTR gives the new location of the
448    stack.  Advance YYPTR to a properly aligned location for the next
449    stack.  */
450 # define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
451     do                                                                  \
452       {                                                                 \
453         YYSIZE_T yynewbytes;                                            \
454         YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
455         Stack = &yyptr->Stack_alloc;                                    \
456         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
457         yyptr += yynewbytes / sizeof (*yyptr);                          \
458       }                                                                 \
459     while (0)
460 
461 #endif
462 
463 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
464 /* Copy COUNT objects from SRC to DST.  The source and destination do
465    not overlap.  */
466 # ifndef YYCOPY
467 #  if defined __GNUC__ && 1 < __GNUC__
468 #   define YYCOPY(Dst, Src, Count) \
469       __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
470 #  else
471 #   define YYCOPY(Dst, Src, Count)              \
472       do                                        \
473         {                                       \
474           YYSIZE_T yyi;                         \
475           for (yyi = 0; yyi < (Count); yyi++)   \
476             (Dst)[yyi] = (Src)[yyi];            \
477         }                                       \
478       while (0)
479 #  endif
480 # endif
481 #endif /* !YYCOPY_NEEDED */
482 
483 /* YYFINAL -- State number of the termination state.  */
484 #define YYFINAL  15
485 /* YYLAST -- Last index in YYTABLE.  */
486 #define YYLAST   191
487 
488 /* YYNTOKENS -- Number of terminals.  */
489 #define YYNTOKENS  57
490 /* YYNNTS -- Number of nonterminals.  */
491 #define YYNNTS  32
492 /* YYNRULES -- Number of rules.  */
493 #define YYNRULES  92
494 /* YYNSTATES -- Number of states.  */
495 #define YYNSTATES  183
496 
497 #define YYUNDEFTOK  2
498 #define YYMAXUTOK   296
499 
500 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
501    as returned by yylex, with out-of-bounds checking.  */
502 #define YYTRANSLATE(YYX)                                                \
503   ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
504 
505 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
506    as returned by yylex.  */
507 static const yytype_uint8 yytranslate[] =
508 {
509        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
510        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
511        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
512        2,     2,     2,    49,     2,    54,     2,     2,    50,     2,
513       44,    45,    55,    47,    46,    48,     2,    56,     2,     2,
514        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
515       51,    53,    52,     2,     2,     2,     2,     2,     2,     2,
516        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
517        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
518        2,    42,     2,    43,     2,     2,     2,     2,     2,     2,
519        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
520        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
521        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
522        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
523        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
524        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
525        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
526        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
527        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
528        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
529        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
530        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
531        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
532        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
533        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
534        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
535        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
536       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
537       25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
538       35,    36,    37,    38,    39,    40,    41
539 };
540 
541 #if YYDEBUG
542   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
543 static const yytype_uint16 yyrline[] =
544 {
545        0,   112,   112,   117,   121,   127,   130,   135,   141,   147,
546      153,   159,   165,   173,   185,   188,   193,   200,   209,   212,
547      215,   378,   503,   506,   520,   523,   537,   551,   569,   573,
548      579,   584,   592,   607,   670,   691,   714,   718,   724,   727,
549      730,   735,   738,   745,   748,   751,   756,   759,   764,   767,
550      772,   798,   839,   842,   845,   853,   861,   864,   874,   904,
551      907,   910,   918,   926,   937,   948,   958,   961,   966,   969,
552      970,   983,   984,  1009,  1012,  1037,  1038,  1063,  1066,  1091,
553     1092,  1114,  1136,  1158,  1180,  1202,  1226,  1227,  1253,  1281,
554     1282,  1308,  1340
555 };
556 #endif
557 
558 #if YYDEBUG || YYERROR_VERBOSE || 1
559 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
560    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
561 static const char *const yytname[] =
562 {
563   "\"end of file\"", "error", "$undefined", "\"integer literal\"",
564   "\"real number literal\"", "\"integer literal with unit\"",
565   "\"real number literal with unit\"", "\"string literal\"",
566   "\"function name\"", "\"variable name\"", "\"keyword 'on'\"",
567   "\"keyword 'end'\"", "\"keyword 'init'\"", "\"keyword 'note'\"",
568   "\"keyword 'release'\"", "\"keyword 'controller'\"", "\"keyword 'rpn'\"",
569   "\"keyword 'nrpn'\"", "\"keyword 'declare'\"", "\"operator ':='\"",
570   "\"keyword 'const'\"", "\"keyword 'polyphonic'\"", "\"keyword 'patch'\"",
571   "\"keyword 'while'\"", "\"keyword 'synchronized'\"", "\"keyword 'if'\"",
572   "\"keyword 'else'\"", "\"keyword 'select'\"", "\"keyword 'case'\"",
573   "\"keyword 'to'\"", "\"operator 'or'\"", "\"operator 'and'\"",
574   "\"operator 'not'\"", "\"bitwise operator '.or.'\"",
575   "\"bitwise operator '.and.'\"", "\"bitwise operator '.not.'\"",
576   "\"keyword 'function'\"", "\"keyword 'call'\"", "\"operator 'mod'\"",
577   "\"operator '<='\"", "\"operator '>='\"", "\"unknown character\"", "'['",
578   "']'", "'('", "')'", "','", "'+'", "'-'", "'!'", "'&'", "'<'", "'>'",
579   "'='", "'#'", "'*'", "'/'", "$accept", "script", "sections", "section",
580   "eventhandler", "function_declaration", "opt_statements", "statements",
581   "statement", "caseclauses", "caseclause", "userfunctioncall",
582   "functioncall", "args", "arg", "opt_qualifiers", "qualifiers",
583   "qualifier", "opt_assignment", "opt_arr_assignment", "assignment",
584   "unary_expr", "opt_expr", "expr", "concat_expr", "logical_or_expr",
585   "logical_and_expr", "bitwise_or_expr", "bitwise_and_expr", "rel_expr",
586   "add_expr", "mul_expr", YY_NULLPTR
587 };
588 #endif
589 
590 # ifdef YYPRINT
591 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
592    (internal) symbol number NUM (which must be that of a token).  */
593 static const yytype_uint16 yytoknum[] =
594 {
595        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
596      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
597      275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
598      285,   286,   287,   288,   289,   290,   291,   292,   293,   294,
599      295,   296,    91,    93,    40,    41,    44,    43,    45,    33,
600       38,    60,    62,    61,    35,    42,    47
601 };
602 # endif
603 
604 #define YYPACT_NINF -36
605 
606 #define yypact_value_is_default(Yystate) \
607   (!!((Yystate) == (-36)))
608 
609 #define YYTABLE_NINF -1
610 
611 #define yytable_value_is_error(Yytable_value) \
612   0
613 
614   /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
615      STATE-NUM.  */
616 static const yytype_int16 yypact[] =
617 {
618        5,    60,    14,    36,     5,   -36,   -36,   -36,     8,     8,
619        8,     8,     8,     8,     8,   -36,   -36,    -6,     9,    68,
620       -4,     8,     3,    59,    42,    41,     8,   -36,   -36,   -36,
621      -36,    43,    84,    91,    93,    94,   104,    52,    59,    59,
622      -36,   -36,   -36,    89,    68,   -36,    59,   105,    59,   -36,
623      -36,   -36,   -36,   -36,    75,    59,    59,    59,    59,    59,
624       59,   -36,   -36,    90,    71,    92,    99,   100,    98,    87,
625       -5,    15,   -36,   114,   -36,   132,   133,   134,   136,   138,
626      101,   -36,    33,   -36,   -36,   -36,   106,    27,   -36,   108,
627      131,   112,    59,   -36,   -36,   113,   -36,   -36,   -36,   156,
628       16,   -36,    59,    59,    59,    59,    59,    59,    59,    59,
629       59,    59,    59,    59,    59,    59,    59,    59,   -36,   -36,
630      -36,   -36,   -36,   -36,   -36,   -36,    59,   141,    59,    59,
631      -36,     8,   -36,     8,   118,   -36,   127,   139,   -36,    92,
632       99,   100,    98,    87,    -5,    -5,    -5,    -5,    -5,    -5,
633       15,    15,   -36,   -36,   -36,   -36,    59,   -36,   122,   -36,
634      159,    23,   -36,   164,   -36,   -36,   -36,   152,   149,   148,
635        8,     8,   130,   -36,   -36,   -36,   165,   -36,    59,   150,
636       40,   -36,   -36
637 };
638 
639   /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
640      Performed when YYTABLE does not specify something else to do.  Zero
641      means the default is an error.  */
642 static const yytype_uint8 yydefact[] =
643 {
644        0,     0,     0,     0,     2,     3,     6,     5,    14,    14,
645       14,    14,    14,    14,    14,     1,     4,    35,     0,    39,
646        0,    14,     0,     0,     0,     0,    15,    16,    19,    18,
647       22,     0,     0,     0,     0,     0,     0,     0,     0,     0,
648       43,    44,    45,     0,    40,    41,     0,     0,     0,    52,
649       53,    54,    55,    56,    57,     0,     0,     0,     0,     0,
650        0,    60,    89,     0,    68,    69,    71,    73,    75,    77,
651       79,    86,    32,     0,    17,     0,     0,     0,     0,     0,
652        0,    34,     0,    36,    38,    50,     0,    46,    42,     0,
653        0,     0,     0,    64,    63,     0,    61,    62,    65,     0,
654        0,    28,     0,     0,     0,     0,     0,     0,     0,     0,
655        0,     0,     0,     0,     0,     0,     0,     0,     8,     7,
656        9,    10,    11,    12,    13,    33,     0,     0,     0,    66,
657       20,    14,    24,    14,     0,    59,    14,     0,    29,    70,
658       72,    74,    76,    78,    82,    83,    80,    81,    84,    85,
659       87,    88,    92,    90,    91,    37,     0,    47,     0,    67,
660        0,     0,    58,     0,    30,    27,    51,    48,     0,     0,
661       14,    14,     0,    21,    23,    26,     0,    31,     0,     0,
662        0,    25,    49
663 };
664 
665   /* YYPGOTO[NTERM-NUM].  */
666 static const yytype_int16 yypgoto[] =
667 {
668      -36,   -36,   -36,   173,   -36,   -36,    -2,   -36,   153,   -36,
669       78,   -36,    -8,     4,    54,   -36,   -36,   137,   -36,   -36,
670      -36,   -35,   -36,    -9,   -36,    81,    82,    80,    83,    85,
671        2,   -21
672 };
673 
674   /* YYDEFGOTO[NTERM-NUM].  */
675 static const yytype_int16 yydefgoto[] =
676 {
677       -1,     3,     4,     5,     6,     7,    25,    26,    27,   100,
678      101,    28,    61,    82,    83,    43,    44,    45,   130,   173,
679       30,    62,   158,    84,    64,    65,    66,    67,    68,    69,
680       70,    71
681 };
682 
683   /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
684      positive, shift that token.  If negative, reduce the rule whose
685      number is the opposite.  If YYTABLE_NINF, syntax error.  */
686 static const yytype_uint8 yytable[] =
687 {
688       29,    29,    29,    29,    29,    29,    29,    31,    32,    33,
689       34,    35,    36,    29,    63,     1,    17,    18,    29,    47,
690       93,    94,    14,    96,    97,    98,    19,   137,    38,    85,
691       86,    20,    21,    22,   169,    23,    15,    89,    37,    91,
692       46,     2,   113,   114,    99,    24,   128,    48,    95,   170,
693       72,    39,    73,   115,    75,    49,    50,    51,    52,    53,
694       17,    54,    49,    50,    51,    52,    53,    17,    54,   129,
695      116,   117,     8,     9,    10,    11,    12,    13,   125,   126,
696      152,   153,   154,   134,    55,   182,   126,    56,    40,    41,
697       42,    55,   150,   151,    56,    76,    57,    81,    87,    58,
698       59,    60,    77,    57,    78,    79,    58,    59,    60,   144,
699      145,   146,   147,   148,   149,    80,    90,    92,    99,   157,
700      159,   102,   103,    29,   118,    29,   107,   108,    29,   160,
701      104,   161,   106,   105,   164,    17,    18,   124,   109,   110,
702      111,   112,   119,   120,   121,    19,   122,   166,   123,   127,
703       20,    21,    22,   131,    23,   132,   163,   133,   135,   136,
704      156,   162,    29,    29,    24,   167,   165,   171,   176,   177,
705      168,   172,   174,   175,   178,   181,   179,    16,   138,    74,
706      155,    88,   180,   139,   141,   140,     0,     0,   142,     0,
707        0,   143
708 };
709 
710 static const yytype_int16 yycheck[] =
711 {
712        8,     9,    10,    11,    12,    13,    14,     9,    10,    11,
713       12,    13,    14,    21,    23,    10,     8,     9,    26,    21,
714       55,    56,     8,    58,    59,    60,    18,    11,    19,    38,
715       39,    23,    24,    25,    11,    27,     0,    46,    44,    48,
716       44,    36,    47,    48,    28,    37,    19,    44,    57,    26,
717        8,    42,    11,    38,    11,     3,     4,     5,     6,     7,
718        8,     9,     3,     4,     5,     6,     7,     8,     9,    42,
719       55,    56,    12,    13,    14,    15,    16,    17,    45,    46,
720      115,   116,   117,    92,    32,    45,    46,    35,    20,    21,
721       22,    32,   113,   114,    35,    11,    44,    45,     9,    47,
722       48,    49,    11,    44,    11,    11,    47,    48,    49,   107,
723      108,   109,   110,   111,   112,    11,    11,    42,    28,   128,
724      129,    50,    30,   131,    10,   133,    39,    40,   136,   131,
725       31,   133,    34,    33,   136,     8,     9,    36,    51,    52,
726       53,    54,    10,    10,    10,    18,    10,   156,    10,    43,
727       23,    24,    25,    45,    27,    24,    29,    45,    45,     3,
728       19,    43,   170,   171,    37,    43,    27,     3,   170,   171,
729       11,    19,    23,    25,    44,    25,    11,     4,   100,    26,
730      126,    44,   178,   102,   104,   103,    -1,    -1,   105,    -1,
731       -1,   106
732 };
733 
734   /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
735      symbol of state STATE-NUM.  */
736 static const yytype_uint8 yystos[] =
737 {
738        0,    10,    36,    58,    59,    60,    61,    62,    12,    13,
739       14,    15,    16,    17,     8,     0,    60,     8,     9,    18,
740       23,    24,    25,    27,    37,    63,    64,    65,    68,    69,
741       77,    63,    63,    63,    63,    63,    63,    44,    19,    42,
742       20,    21,    22,    72,    73,    74,    44,    63,    44,     3,
743        4,     5,     6,     7,     9,    32,    35,    44,    47,    48,
744       49,    69,    78,    80,    81,    82,    83,    84,    85,    86,
745       87,    88,     8,    11,    65,    11,    11,    11,    11,    11,
746       11,    45,    70,    71,    80,    80,    80,     9,    74,    80,
747       11,    80,    42,    78,    78,    80,    78,    78,    78,    28,
748       66,    67,    50,    30,    31,    33,    34,    39,    40,    51,
749       52,    53,    54,    47,    48,    38,    55,    56,    10,    10,
750       10,    10,    10,    10,    36,    45,    46,    43,    19,    42,
751       75,    45,    24,    45,    80,    45,     3,    11,    67,    82,
752       83,    84,    85,    86,    87,    87,    87,    87,    87,    87,
753       88,    88,    78,    78,    78,    71,    19,    80,    79,    80,
754       63,    63,    43,    29,    63,    27,    80,    43,    11,    11,
755       26,     3,    19,    76,    23,    25,    63,    63,    44,    11,
756       70,    25,    45
757 };
758 
759   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
760 static const yytype_uint8 yyr1[] =
761 {
762        0,    57,    58,    59,    59,    60,    60,    61,    61,    61,
763       61,    61,    61,    62,    63,    63,    64,    64,    65,    65,
764       65,    65,    65,    65,    65,    65,    65,    65,    66,    66,
765       67,    67,    68,    69,    69,    69,    70,    70,    71,    72,
766       72,    73,    73,    74,    74,    74,    75,    75,    76,    76,
767       77,    77,    78,    78,    78,    78,    78,    78,    78,    78,
768       78,    78,    78,    78,    78,    78,    79,    79,    80,    81,
769       81,    82,    82,    83,    83,    84,    84,    85,    85,    86,
770       86,    86,    86,    86,    86,    86,    87,    87,    87,    88,
771       88,    88,    88
772 };
773 
774   /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
775 static const yytype_uint8 yyr2[] =
776 {
777        0,     2,     1,     1,     2,     1,     1,     5,     5,     5,
778        5,     5,     5,     5,     0,     1,     1,     2,     1,     1,
779        4,     7,     1,     7,     4,     9,     7,     5,     1,     2,
780        3,     5,     2,     4,     3,     1,     1,     3,     1,     0,
781        1,     1,     2,     1,     1,     1,     0,     2,     0,     4,
782        3,     6,     1,     1,     1,     1,     1,     1,     4,     3,
783        1,     2,     2,     2,     2,     2,     0,     1,     1,     1,
784        3,     1,     3,     1,     3,     1,     3,     1,     3,     1,
785        3,     3,     3,     3,     3,     3,     1,     3,     3,     1,
786        3,     3,     3
787 };
788 
789 
790 #define yyerrok         (yyerrstatus = 0)
791 #define yyclearin       (yychar = YYEMPTY)
792 #define YYEMPTY         (-2)
793 #define YYEOF           0
794 
795 #define YYACCEPT        goto yyacceptlab
796 #define YYABORT         goto yyabortlab
797 #define YYERROR         goto yyerrorlab
798 
799 
800 #define YYRECOVERING()  (!!yyerrstatus)
801 
802 #define YYBACKUP(Token, Value)                                    \
803   do                                                              \
804     if (yychar == YYEMPTY)                                        \
805       {                                                           \
806         yychar = (Token);                                         \
807         yylval = (Value);                                         \
808         YYPOPSTACK (yylen);                                       \
809         yystate = *yyssp;                                         \
810         goto yybackup;                                            \
811       }                                                           \
812     else                                                          \
813       {                                                           \
814         yyerror (&yylloc, context, YY_("syntax error: cannot back up")); \
815         YYERROR;                                                  \
816       }                                                           \
817   while (0)
818 
819 /* Error token number */
820 #define YYTERROR        1
821 #define YYERRCODE       256
822 
823 
824 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
825    If N is 0, then set CURRENT to the empty location which ends
826    the previous symbol: RHS[0] (always defined).  */
827 
828 #ifndef YYLLOC_DEFAULT
829 # define YYLLOC_DEFAULT(Current, Rhs, N)                                \
830     do                                                                  \
831       if (N)                                                            \
832         {                                                               \
833           (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
834           (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
835           (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
836           (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
837         }                                                               \
838       else                                                              \
839         {                                                               \
840           (Current).first_line   = (Current).last_line   =              \
841             YYRHSLOC (Rhs, 0).last_line;                                \
842           (Current).first_column = (Current).last_column =              \
843             YYRHSLOC (Rhs, 0).last_column;                              \
844         }                                                               \
845     while (0)
846 #endif
847 
848 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
849 
850 
851 /* Enable debugging if requested.  */
852 #if YYDEBUG
853 
854 # ifndef YYFPRINTF
855 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
856 #  define YYFPRINTF fprintf
857 # endif
858 
859 # define YYDPRINTF(Args)                        \
860 do {                                            \
861   if (yydebug)                                  \
862     YYFPRINTF Args;                             \
863 } while (0)
864 
865 
866 /* YY_LOCATION_PRINT -- Print the location on the stream.
867    This macro was not mandated originally: define only if we know
868    we won't break user code: when these are the locations we know.  */
869 
870 #ifndef YY_LOCATION_PRINT
871 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
872 
873 /* Print *YYLOCP on YYO.  Private, do not rely on its existence. */
874 
875 YY_ATTRIBUTE_UNUSED
876 static int
yy_location_print_(FILE * yyo,YYLTYPE const * const yylocp)877 yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
878 {
879   int res = 0;
880   int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
881   if (0 <= yylocp->first_line)
882     {
883       res += YYFPRINTF (yyo, "%d", yylocp->first_line);
884       if (0 <= yylocp->first_column)
885         res += YYFPRINTF (yyo, ".%d", yylocp->first_column);
886     }
887   if (0 <= yylocp->last_line)
888     {
889       if (yylocp->first_line < yylocp->last_line)
890         {
891           res += YYFPRINTF (yyo, "-%d", yylocp->last_line);
892           if (0 <= end_col)
893             res += YYFPRINTF (yyo, ".%d", end_col);
894         }
895       else if (0 <= end_col && yylocp->first_column < end_col)
896         res += YYFPRINTF (yyo, "-%d", end_col);
897     }
898   return res;
899  }
900 
901 #  define YY_LOCATION_PRINT(File, Loc)          \
902   yy_location_print_ (File, &(Loc))
903 
904 # else
905 #  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
906 # endif
907 #endif
908 
909 
910 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
911 do {                                                                      \
912   if (yydebug)                                                            \
913     {                                                                     \
914       YYFPRINTF (stderr, "%s ", Title);                                   \
915       yy_symbol_print (stderr,                                            \
916                   Type, Value, Location, context); \
917       YYFPRINTF (stderr, "\n");                                           \
918     }                                                                     \
919 } while (0)
920 
921 
922 /*-----------------------------------.
923 | Print this symbol's value on YYO.  |
924 `-----------------------------------*/
925 
926 static void
yy_symbol_value_print(FILE * yyo,int yytype,YYSTYPE const * const yyvaluep,YYLTYPE const * const yylocationp,LinuxSampler::ParserContext * context)927 yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, LinuxSampler::ParserContext* context)
928 {
929   FILE *yyoutput = yyo;
930   YYUSE (yyoutput);
931   YYUSE (yylocationp);
932   YYUSE (context);
933   if (!yyvaluep)
934     return;
935 # ifdef YYPRINT
936   if (yytype < YYNTOKENS)
937     YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
938 # endif
939   YYUSE (yytype);
940 }
941 
942 
943 /*---------------------------.
944 | Print this symbol on YYO.  |
945 `---------------------------*/
946 
947 static void
yy_symbol_print(FILE * yyo,int yytype,YYSTYPE const * const yyvaluep,YYLTYPE const * const yylocationp,LinuxSampler::ParserContext * context)948 yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, LinuxSampler::ParserContext* context)
949 {
950   YYFPRINTF (yyo, "%s %s (",
951              yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
952 
953   YY_LOCATION_PRINT (yyo, *yylocationp);
954   YYFPRINTF (yyo, ": ");
955   yy_symbol_value_print (yyo, yytype, yyvaluep, yylocationp, context);
956   YYFPRINTF (yyo, ")");
957 }
958 
959 /*------------------------------------------------------------------.
960 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
961 | TOP (included).                                                   |
962 `------------------------------------------------------------------*/
963 
964 static void
yy_stack_print(yytype_int16 * yybottom,yytype_int16 * yytop)965 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
966 {
967   YYFPRINTF (stderr, "Stack now");
968   for (; yybottom <= yytop; yybottom++)
969     {
970       int yybot = *yybottom;
971       YYFPRINTF (stderr, " %d", yybot);
972     }
973   YYFPRINTF (stderr, "\n");
974 }
975 
976 # define YY_STACK_PRINT(Bottom, Top)                            \
977 do {                                                            \
978   if (yydebug)                                                  \
979     yy_stack_print ((Bottom), (Top));                           \
980 } while (0)
981 
982 
983 /*------------------------------------------------.
984 | Report that the YYRULE is going to be reduced.  |
985 `------------------------------------------------*/
986 
987 static void
yy_reduce_print(yytype_int16 * yyssp,YYSTYPE * yyvsp,YYLTYPE * yylsp,int yyrule,LinuxSampler::ParserContext * context)988 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, LinuxSampler::ParserContext* context)
989 {
990   unsigned long yylno = yyrline[yyrule];
991   int yynrhs = yyr2[yyrule];
992   int yyi;
993   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
994              yyrule - 1, yylno);
995   /* The symbols being reduced.  */
996   for (yyi = 0; yyi < yynrhs; yyi++)
997     {
998       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
999       yy_symbol_print (stderr,
1000                        yystos[yyssp[yyi + 1 - yynrhs]],
1001                        &yyvsp[(yyi + 1) - (yynrhs)]
1002                        , &(yylsp[(yyi + 1) - (yynrhs)])                       , context);
1003       YYFPRINTF (stderr, "\n");
1004     }
1005 }
1006 
1007 # define YY_REDUCE_PRINT(Rule)          \
1008 do {                                    \
1009   if (yydebug)                          \
1010     yy_reduce_print (yyssp, yyvsp, yylsp, Rule, context); \
1011 } while (0)
1012 
1013 /* Nonzero means print parse trace.  It is left uninitialized so that
1014    multiple parsers can coexist.  */
1015 int yydebug;
1016 #else /* !YYDEBUG */
1017 # define YYDPRINTF(Args)
1018 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1019 # define YY_STACK_PRINT(Bottom, Top)
1020 # define YY_REDUCE_PRINT(Rule)
1021 #endif /* !YYDEBUG */
1022 
1023 
1024 /* YYINITDEPTH -- initial size of the parser's stacks.  */
1025 #ifndef YYINITDEPTH
1026 # define YYINITDEPTH 200
1027 #endif
1028 
1029 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1030    if the built-in stack extension method is used).
1031 
1032    Do not make this value too large; the results are undefined if
1033    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1034    evaluated with infinite-precision integer arithmetic.  */
1035 
1036 #ifndef YYMAXDEPTH
1037 # define YYMAXDEPTH 10000
1038 #endif
1039 
1040 
1041 #if YYERROR_VERBOSE
1042 
1043 # ifndef yystrlen
1044 #  if defined __GLIBC__ && defined _STRING_H
1045 #   define yystrlen strlen
1046 #  else
1047 /* Return the length of YYSTR.  */
1048 static YYSIZE_T
yystrlen(const char * yystr)1049 yystrlen (const char *yystr)
1050 {
1051   YYSIZE_T yylen;
1052   for (yylen = 0; yystr[yylen]; yylen++)
1053     continue;
1054   return yylen;
1055 }
1056 #  endif
1057 # endif
1058 
1059 # ifndef yystpcpy
1060 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1061 #   define yystpcpy stpcpy
1062 #  else
1063 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1064    YYDEST.  */
1065 static char *
yystpcpy(char * yydest,const char * yysrc)1066 yystpcpy (char *yydest, const char *yysrc)
1067 {
1068   char *yyd = yydest;
1069   const char *yys = yysrc;
1070 
1071   while ((*yyd++ = *yys++) != '\0')
1072     continue;
1073 
1074   return yyd - 1;
1075 }
1076 #  endif
1077 # endif
1078 
1079 # ifndef yytnamerr
1080 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1081    quotes and backslashes, so that it's suitable for yyerror.  The
1082    heuristic is that double-quoting is unnecessary unless the string
1083    contains an apostrophe, a comma, or backslash (other than
1084    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
1085    null, do not copy; instead, return the length of what the result
1086    would have been.  */
1087 static YYSIZE_T
yytnamerr(char * yyres,const char * yystr)1088 yytnamerr (char *yyres, const char *yystr)
1089 {
1090   if (*yystr == '"')
1091     {
1092       YYSIZE_T yyn = 0;
1093       char const *yyp = yystr;
1094 
1095       for (;;)
1096         switch (*++yyp)
1097           {
1098           case '\'':
1099           case ',':
1100             goto do_not_strip_quotes;
1101 
1102           case '\\':
1103             if (*++yyp != '\\')
1104               goto do_not_strip_quotes;
1105             else
1106               goto append;
1107 
1108           append:
1109           default:
1110             if (yyres)
1111               yyres[yyn] = *yyp;
1112             yyn++;
1113             break;
1114 
1115           case '"':
1116             if (yyres)
1117               yyres[yyn] = '\0';
1118             return yyn;
1119           }
1120     do_not_strip_quotes: ;
1121     }
1122 
1123   if (! yyres)
1124     return yystrlen (yystr);
1125 
1126   return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres);
1127 }
1128 # endif
1129 
1130 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1131    about the unexpected token YYTOKEN for the state stack whose top is
1132    YYSSP.
1133 
1134    Return 0 if *YYMSG was successfully written.  Return 1 if *YYMSG is
1135    not large enough to hold the message.  In that case, also set
1136    *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
1137    required number of bytes is too large to store.  */
1138 static int
yysyntax_error(YYSIZE_T * yymsg_alloc,char ** yymsg,yytype_int16 * yyssp,int yytoken)1139 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1140                 yytype_int16 *yyssp, int yytoken)
1141 {
1142   YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
1143   YYSIZE_T yysize = yysize0;
1144   enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1145   /* Internationalized format string. */
1146   const char *yyformat = YY_NULLPTR;
1147   /* Arguments of yyformat. */
1148   char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1149   /* Number of reported tokens (one for the "unexpected", one per
1150      "expected"). */
1151   int yycount = 0;
1152 
1153   /* There are many possibilities here to consider:
1154      - If this state is a consistent state with a default action, then
1155        the only way this function was invoked is if the default action
1156        is an error action.  In that case, don't check for expected
1157        tokens because there are none.
1158      - The only way there can be no lookahead present (in yychar) is if
1159        this state is a consistent state with a default action.  Thus,
1160        detecting the absence of a lookahead is sufficient to determine
1161        that there is no unexpected or expected token to report.  In that
1162        case, just report a simple "syntax error".
1163      - Don't assume there isn't a lookahead just because this state is a
1164        consistent state with a default action.  There might have been a
1165        previous inconsistent state, consistent state with a non-default
1166        action, or user semantic action that manipulated yychar.
1167      - Of course, the expected token list depends on states to have
1168        correct lookahead information, and it depends on the parser not
1169        to perform extra reductions after fetching a lookahead from the
1170        scanner and before detecting a syntax error.  Thus, state merging
1171        (from LALR or IELR) and default reductions corrupt the expected
1172        token list.  However, the list is correct for canonical LR with
1173        one exception: it will still contain any token that will not be
1174        accepted due to an error action in a later state.
1175   */
1176   if (yytoken != YYEMPTY)
1177     {
1178       int yyn = yypact[*yyssp];
1179       yyarg[yycount++] = yytname[yytoken];
1180       if (!yypact_value_is_default (yyn))
1181         {
1182           /* Start YYX at -YYN if negative to avoid negative indexes in
1183              YYCHECK.  In other words, skip the first -YYN actions for
1184              this state because they are default actions.  */
1185           int yyxbegin = yyn < 0 ? -yyn : 0;
1186           /* Stay within bounds of both yycheck and yytname.  */
1187           int yychecklim = YYLAST - yyn + 1;
1188           int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1189           int yyx;
1190 
1191           for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1192             if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1193                 && !yytable_value_is_error (yytable[yyx + yyn]))
1194               {
1195                 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1196                   {
1197                     yycount = 1;
1198                     yysize = yysize0;
1199                     break;
1200                   }
1201                 yyarg[yycount++] = yytname[yyx];
1202                 {
1203                   YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
1204                   if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1205                     yysize = yysize1;
1206                   else
1207                     return 2;
1208                 }
1209               }
1210         }
1211     }
1212 
1213   switch (yycount)
1214     {
1215 # define YYCASE_(N, S)                      \
1216       case N:                               \
1217         yyformat = S;                       \
1218       break
1219     default: /* Avoid compiler warnings. */
1220       YYCASE_(0, YY_("syntax error"));
1221       YYCASE_(1, YY_("syntax error, unexpected %s"));
1222       YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1223       YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1224       YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1225       YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1226 # undef YYCASE_
1227     }
1228 
1229   {
1230     YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1231     if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1232       yysize = yysize1;
1233     else
1234       return 2;
1235   }
1236 
1237   if (*yymsg_alloc < yysize)
1238     {
1239       *yymsg_alloc = 2 * yysize;
1240       if (! (yysize <= *yymsg_alloc
1241              && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1242         *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1243       return 1;
1244     }
1245 
1246   /* Avoid sprintf, as that infringes on the user's name space.
1247      Don't have undefined behavior even if the translation
1248      produced a string with the wrong number of "%s"s.  */
1249   {
1250     char *yyp = *yymsg;
1251     int yyi = 0;
1252     while ((*yyp = *yyformat) != '\0')
1253       if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1254         {
1255           yyp += yytnamerr (yyp, yyarg[yyi++]);
1256           yyformat += 2;
1257         }
1258       else
1259         {
1260           yyp++;
1261           yyformat++;
1262         }
1263   }
1264   return 0;
1265 }
1266 #endif /* YYERROR_VERBOSE */
1267 
1268 /*-----------------------------------------------.
1269 | Release the memory associated to this symbol.  |
1270 `-----------------------------------------------*/
1271 
1272 static void
yydestruct(const char * yymsg,int yytype,YYSTYPE * yyvaluep,YYLTYPE * yylocationp,LinuxSampler::ParserContext * context)1273 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, LinuxSampler::ParserContext* context)
1274 {
1275   YYUSE (yyvaluep);
1276   YYUSE (yylocationp);
1277   YYUSE (context);
1278   if (!yymsg)
1279     yymsg = "Deleting";
1280   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1281 
1282   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1283   YYUSE (yytype);
1284   YY_IGNORE_MAYBE_UNINITIALIZED_END
1285 }
1286 
1287 
1288 
1289 
1290 /*----------.
1291 | yyparse.  |
1292 `----------*/
1293 
1294 int
yyparse(LinuxSampler::ParserContext * context)1295 yyparse (LinuxSampler::ParserContext* context)
1296 {
1297 /* The lookahead symbol.  */
1298 int yychar;
1299 
1300 
1301 /* The semantic value of the lookahead symbol.  */
1302 /* Default value used for initialization, for pacifying older GCCs
1303    or non-GCC compilers.  */
1304 YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1305 YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1306 
1307 /* Location data for the lookahead symbol.  */
1308 static YYLTYPE yyloc_default
1309 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1310   = { 1, 1, 1, 1 }
1311 # endif
1312 ;
1313 YYLTYPE yylloc = yyloc_default;
1314 
1315     /* Number of syntax errors so far.  */
1316     int yynerrs;
1317 
1318     int yystate;
1319     /* Number of tokens to shift before error messages enabled.  */
1320     int yyerrstatus;
1321 
1322     /* The stacks and their tools:
1323        'yyss': related to states.
1324        'yyvs': related to semantic values.
1325        'yyls': related to locations.
1326 
1327        Refer to the stacks through separate pointers, to allow yyoverflow
1328        to reallocate them elsewhere.  */
1329 
1330     /* The state stack.  */
1331     yytype_int16 yyssa[YYINITDEPTH];
1332     yytype_int16 *yyss;
1333     yytype_int16 *yyssp;
1334 
1335     /* The semantic value stack.  */
1336     YYSTYPE yyvsa[YYINITDEPTH];
1337     YYSTYPE *yyvs;
1338     YYSTYPE *yyvsp;
1339 
1340     /* The location stack.  */
1341     YYLTYPE yylsa[YYINITDEPTH];
1342     YYLTYPE *yyls;
1343     YYLTYPE *yylsp;
1344 
1345     /* The locations where the error started and ended.  */
1346     YYLTYPE yyerror_range[3];
1347 
1348     YYSIZE_T yystacksize;
1349 
1350   int yyn;
1351   int yyresult;
1352   /* Lookahead token as an internal (translated) token number.  */
1353   int yytoken = 0;
1354   /* The variables used to return semantic value and location from the
1355      action routines.  */
1356   YYSTYPE yyval;
1357   YYLTYPE yyloc;
1358 
1359 #if YYERROR_VERBOSE
1360   /* Buffer for error messages, and its allocated size.  */
1361   char yymsgbuf[128];
1362   char *yymsg = yymsgbuf;
1363   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1364 #endif
1365 
1366 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
1367 
1368   /* The number of symbols on the RHS of the reduced rule.
1369      Keep to zero when no symbol should be popped.  */
1370   int yylen = 0;
1371 
1372   yyssp = yyss = yyssa;
1373   yyvsp = yyvs = yyvsa;
1374   yylsp = yyls = yylsa;
1375   yystacksize = YYINITDEPTH;
1376 
1377   YYDPRINTF ((stderr, "Starting parse\n"));
1378 
1379   yystate = 0;
1380   yyerrstatus = 0;
1381   yynerrs = 0;
1382   yychar = YYEMPTY; /* Cause a token to be read.  */
1383   yylsp[0] = yylloc;
1384   goto yysetstate;
1385 
1386 
1387 /*------------------------------------------------------------.
1388 | yynewstate -- push a new state, which is found in yystate.  |
1389 `------------------------------------------------------------*/
1390 yynewstate:
1391   /* In all cases, when you get here, the value and location stacks
1392      have just been pushed.  So pushing a state here evens the stacks.  */
1393   yyssp++;
1394 
1395 
1396 /*--------------------------------------------------------------------.
1397 | yynewstate -- set current state (the top of the stack) to yystate.  |
1398 `--------------------------------------------------------------------*/
1399 yysetstate:
1400   *yyssp = (yytype_int16) yystate;
1401 
1402   if (yyss + yystacksize - 1 <= yyssp)
1403 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1404     goto yyexhaustedlab;
1405 #else
1406     {
1407       /* Get the current used size of the three stacks, in elements.  */
1408       YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1);
1409 
1410 # if defined yyoverflow
1411       {
1412         /* Give user a chance to reallocate the stack.  Use copies of
1413            these so that the &'s don't force the real ones into
1414            memory.  */
1415         YYSTYPE *yyvs1 = yyvs;
1416         yytype_int16 *yyss1 = yyss;
1417         YYLTYPE *yyls1 = yyls;
1418 
1419         /* Each stack pointer address is followed by the size of the
1420            data in use in that stack, in bytes.  This used to be a
1421            conditional around just the two extra args, but that might
1422            be undefined if yyoverflow is a macro.  */
1423         yyoverflow (YY_("memory exhausted"),
1424                     &yyss1, yysize * sizeof (*yyssp),
1425                     &yyvs1, yysize * sizeof (*yyvsp),
1426                     &yyls1, yysize * sizeof (*yylsp),
1427                     &yystacksize);
1428         yyss = yyss1;
1429         yyvs = yyvs1;
1430         yyls = yyls1;
1431       }
1432 # else /* defined YYSTACK_RELOCATE */
1433       /* Extend the stack our own way.  */
1434       if (YYMAXDEPTH <= yystacksize)
1435         goto yyexhaustedlab;
1436       yystacksize *= 2;
1437       if (YYMAXDEPTH < yystacksize)
1438         yystacksize = YYMAXDEPTH;
1439 
1440       {
1441         yytype_int16 *yyss1 = yyss;
1442         union yyalloc *yyptr =
1443           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1444         if (! yyptr)
1445           goto yyexhaustedlab;
1446         YYSTACK_RELOCATE (yyss_alloc, yyss);
1447         YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1448         YYSTACK_RELOCATE (yyls_alloc, yyls);
1449 # undef YYSTACK_RELOCATE
1450         if (yyss1 != yyssa)
1451           YYSTACK_FREE (yyss1);
1452       }
1453 # endif
1454 
1455       yyssp = yyss + yysize - 1;
1456       yyvsp = yyvs + yysize - 1;
1457       yylsp = yyls + yysize - 1;
1458 
1459       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1460                   (unsigned long) yystacksize));
1461 
1462       if (yyss + yystacksize - 1 <= yyssp)
1463         YYABORT;
1464     }
1465 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1466 
1467   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1468 
1469   if (yystate == YYFINAL)
1470     YYACCEPT;
1471 
1472   goto yybackup;
1473 
1474 
1475 /*-----------.
1476 | yybackup.  |
1477 `-----------*/
1478 yybackup:
1479   /* Do appropriate processing given the current state.  Read a
1480      lookahead token if we need one and don't already have one.  */
1481 
1482   /* First try to decide what to do without reference to lookahead token.  */
1483   yyn = yypact[yystate];
1484   if (yypact_value_is_default (yyn))
1485     goto yydefault;
1486 
1487   /* Not known => get a lookahead token if don't already have one.  */
1488 
1489   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1490   if (yychar == YYEMPTY)
1491     {
1492       YYDPRINTF ((stderr, "Reading a token: "));
1493       yychar = yylex (&yylval, &yylloc, scanner);
1494     }
1495 
1496   if (yychar <= YYEOF)
1497     {
1498       yychar = yytoken = YYEOF;
1499       YYDPRINTF ((stderr, "Now at end of input.\n"));
1500     }
1501   else
1502     {
1503       yytoken = YYTRANSLATE (yychar);
1504       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1505     }
1506 
1507   /* If the proper action on seeing token YYTOKEN is to reduce or to
1508      detect an error, take that action.  */
1509   yyn += yytoken;
1510   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1511     goto yydefault;
1512   yyn = yytable[yyn];
1513   if (yyn <= 0)
1514     {
1515       if (yytable_value_is_error (yyn))
1516         goto yyerrlab;
1517       yyn = -yyn;
1518       goto yyreduce;
1519     }
1520 
1521   /* Count tokens shifted since error; after three, turn off error
1522      status.  */
1523   if (yyerrstatus)
1524     yyerrstatus--;
1525 
1526   /* Shift the lookahead token.  */
1527   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1528 
1529   /* Discard the shifted token.  */
1530   yychar = YYEMPTY;
1531 
1532   yystate = yyn;
1533   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1534   *++yyvsp = yylval;
1535   YY_IGNORE_MAYBE_UNINITIALIZED_END
1536   *++yylsp = yylloc;
1537   goto yynewstate;
1538 
1539 
1540 /*-----------------------------------------------------------.
1541 | yydefault -- do the default action for the current state.  |
1542 `-----------------------------------------------------------*/
1543 yydefault:
1544   yyn = yydefact[yystate];
1545   if (yyn == 0)
1546     goto yyerrlab;
1547   goto yyreduce;
1548 
1549 
1550 /*-----------------------------.
1551 | yyreduce -- do a reduction.  |
1552 `-----------------------------*/
1553 yyreduce:
1554   /* yyn is the number of a rule to reduce with.  */
1555   yylen = yyr2[yyn];
1556 
1557   /* If YYLEN is nonzero, implement the default value of the action:
1558      '$$ = $1'.
1559 
1560      Otherwise, the following line sets YYVAL to garbage.
1561      This behavior is undocumented and Bison
1562      users should not rely upon it.  Assigning to YYVAL
1563      unconditionally makes the parser a bit smaller, and it avoids a
1564      GCC warning that YYVAL may be used uninitialized.  */
1565   yyval = yyvsp[1-yylen];
1566 
1567   /* Default location. */
1568   YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1569   yyerror_range[1] = yyloc;
1570   YY_REDUCE_PRINT (yyn);
1571   switch (yyn)
1572     {
1573         case 2:
1574 #line 112 "parser.y" /* yacc.c:1652  */
1575     {
1576         (yyval.nEventHandlers) = context->handlers = (yyvsp[0].nEventHandlers);
1577     }
1578 #line 1579 "y.tab.c" /* yacc.c:1652  */
1579     break;
1580 
1581   case 3:
1582 #line 117 "parser.y" /* yacc.c:1652  */
1583     {
1584         (yyval.nEventHandlers) = new EventHandlers();
1585         if ((yyvsp[0].nEventHandler)) (yyval.nEventHandlers)->add((yyvsp[0].nEventHandler));
1586     }
1587 #line 1588 "y.tab.c" /* yacc.c:1652  */
1588     break;
1589 
1590   case 4:
1591 #line 121 "parser.y" /* yacc.c:1652  */
1592     {
1593         (yyval.nEventHandlers) = (yyvsp[-1].nEventHandlers);
1594         if ((yyvsp[0].nEventHandler)) (yyval.nEventHandlers)->add((yyvsp[0].nEventHandler));
1595     }
1596 #line 1597 "y.tab.c" /* yacc.c:1652  */
1597     break;
1598 
1599   case 5:
1600 #line 127 "parser.y" /* yacc.c:1652  */
1601     {
1602         (yyval.nEventHandler) = EventHandlerRef();
1603     }
1604 #line 1605 "y.tab.c" /* yacc.c:1652  */
1605     break;
1606 
1607   case 6:
1608 #line 130 "parser.y" /* yacc.c:1652  */
1609     {
1610         (yyval.nEventHandler) = (yyvsp[0].nEventHandler);
1611     }
1612 #line 1613 "y.tab.c" /* yacc.c:1652  */
1613     break;
1614 
1615   case 7:
1616 #line 135 "parser.y" /* yacc.c:1652  */
1617     {
1618         if (context->onNote)
1619             PARSE_ERR((yylsp[-3]), "Redeclaration of 'note' event handler.");
1620         context->onNote = new OnNote((yyvsp[-2].nStatements));
1621         (yyval.nEventHandler) = context->onNote;
1622     }
1623 #line 1624 "y.tab.c" /* yacc.c:1652  */
1624     break;
1625 
1626   case 8:
1627 #line 141 "parser.y" /* yacc.c:1652  */
1628     {
1629         if (context->onInit)
1630             PARSE_ERR((yylsp[-3]), "Redeclaration of 'init' event handler.");
1631         context->onInit = new OnInit((yyvsp[-2].nStatements));
1632         (yyval.nEventHandler) = context->onInit;
1633     }
1634 #line 1635 "y.tab.c" /* yacc.c:1652  */
1635     break;
1636 
1637   case 9:
1638 #line 147 "parser.y" /* yacc.c:1652  */
1639     {
1640         if (context->onRelease)
1641             PARSE_ERR((yylsp[-3]), "Redeclaration of 'release' event handler.");
1642         context->onRelease = new OnRelease((yyvsp[-2].nStatements));
1643         (yyval.nEventHandler) = context->onRelease;
1644     }
1645 #line 1646 "y.tab.c" /* yacc.c:1652  */
1646     break;
1647 
1648   case 10:
1649 #line 153 "parser.y" /* yacc.c:1652  */
1650     {
1651         if (context->onController)
1652             PARSE_ERR((yylsp[-3]), "Redeclaration of 'controller' event handler.");
1653         context->onController = new OnController((yyvsp[-2].nStatements));
1654         (yyval.nEventHandler) = context->onController;
1655     }
1656 #line 1657 "y.tab.c" /* yacc.c:1652  */
1657     break;
1658 
1659   case 11:
1660 #line 159 "parser.y" /* yacc.c:1652  */
1661     {
1662         if (context->onRpn)
1663             PARSE_ERR((yylsp[-3]), "Redeclaration of 'rpn' event handler.");
1664         context->onRpn = new OnRpn((yyvsp[-2].nStatements));
1665         (yyval.nEventHandler) = context->onRpn;
1666     }
1667 #line 1668 "y.tab.c" /* yacc.c:1652  */
1668     break;
1669 
1670   case 12:
1671 #line 165 "parser.y" /* yacc.c:1652  */
1672     {
1673         if (context->onNrpn)
1674             PARSE_ERR((yylsp[-3]), "Redeclaration of 'nrpn' event handler.");
1675         context->onNrpn = new OnNrpn((yyvsp[-2].nStatements));
1676         (yyval.nEventHandler) = context->onNrpn;
1677     }
1678 #line 1679 "y.tab.c" /* yacc.c:1652  */
1679     break;
1680 
1681   case 13:
1682 #line 173 "parser.y" /* yacc.c:1652  */
1683     {
1684         const char* name = (yyvsp[-3].sValue);
1685         if (context->functionProvider->functionByName(name)) {
1686             PARSE_ERR((yylsp[-3]), (String("There is already a built-in function with name '") + name + "'.").c_str());
1687         } else if (context->userFunctionByName(name)) {
1688             PARSE_ERR((yylsp[-3]), (String("There is already a user defined function with name '") + name + "'.").c_str());
1689         } else {
1690             context->userFnTable[name] = new UserFunction((yyvsp[-2].nStatements));
1691         }
1692     }
1693 #line 1694 "y.tab.c" /* yacc.c:1652  */
1694     break;
1695 
1696   case 14:
1697 #line 185 "parser.y" /* yacc.c:1652  */
1698     {
1699         (yyval.nStatements) = new Statements();
1700     }
1701 #line 1702 "y.tab.c" /* yacc.c:1652  */
1702     break;
1703 
1704   case 15:
1705 #line 188 "parser.y" /* yacc.c:1652  */
1706     {
1707         (yyval.nStatements) = (yyvsp[0].nStatements);
1708     }
1709 #line 1710 "y.tab.c" /* yacc.c:1652  */
1710     break;
1711 
1712   case 16:
1713 #line 193 "parser.y" /* yacc.c:1652  */
1714     {
1715         (yyval.nStatements) = new Statements();
1716         if ((yyvsp[0].nStatement)) {
1717             if (!isNoOperation((yyvsp[0].nStatement))) (yyval.nStatements)->add((yyvsp[0].nStatement)); // filter out NoOperation statements
1718         } else
1719             PARSE_WRN((yylsp[0]), "Not a statement.");
1720     }
1721 #line 1722 "y.tab.c" /* yacc.c:1652  */
1722     break;
1723 
1724   case 17:
1725 #line 200 "parser.y" /* yacc.c:1652  */
1726     {
1727         (yyval.nStatements) = (yyvsp[-1].nStatements);
1728         if ((yyvsp[0].nStatement)) {
1729             if (!isNoOperation((yyvsp[0].nStatement))) (yyval.nStatements)->add((yyvsp[0].nStatement)); // filter out NoOperation statements
1730         } else
1731             PARSE_WRN((yylsp[0]), "Not a statement.");
1732     }
1733 #line 1734 "y.tab.c" /* yacc.c:1652  */
1734     break;
1735 
1736   case 18:
1737 #line 209 "parser.y" /* yacc.c:1652  */
1738     {
1739         (yyval.nStatement) = (yyvsp[0].nFunctionCall);
1740     }
1741 #line 1742 "y.tab.c" /* yacc.c:1652  */
1742     break;
1743 
1744   case 19:
1745 #line 212 "parser.y" /* yacc.c:1652  */
1746     {
1747         (yyval.nStatement) = (yyvsp[0].nStatements);
1748     }
1749 #line 1750 "y.tab.c" /* yacc.c:1652  */
1750     break;
1751 
1752   case 20:
1753 #line 215 "parser.y" /* yacc.c:1652  */
1754     {
1755         (yyval.nStatement) = new NoOperation; // just as default result value
1756         const bool qConst      = (yyvsp[-2].varQualifier) & QUALIFIER_CONST;
1757         const bool qPolyphonic = (yyvsp[-2].varQualifier) & QUALIFIER_POLYPHONIC;
1758         const bool qPatch      = (yyvsp[-2].varQualifier) & QUALIFIER_PATCH;
1759         const char* name = (yyvsp[-1].sValue);
1760         ExpressionRef expr = (yyvsp[0].nExpression);
1761         //printf("declared var '%s'\n", name);
1762         const ExprType_t declType = exprTypeOfVarName(name);
1763         if (qPatch)
1764             context->patchVars[name].nameBlock = CODE_BLOCK((yylsp[-1]));
1765         if (context->variableByName(name)) {
1766             PARSE_ERR((yylsp[-1]), (String("Redeclaration of variable '") + name + "'.").c_str());
1767         } else if (qConst && !expr) {
1768             PARSE_ERR((yylsp[-2]), (String("Variable '") + name + "' declared const without value assignment.").c_str());
1769         } else if (qConst && qPolyphonic) {
1770             PARSE_ERR((yylsp[-2]), (String("Variable '") + name + "' must not be declared both const and polyphonic.").c_str());
1771         } else {
1772             if (!expr) {
1773                 if (qPolyphonic) {
1774                     if (name[0] != '$' && name[0] != '~') {
1775                         PARSE_ERR((yylsp[-1]), "Polyphonic variables must only be declared either as integer or real number type.");
1776                     } else if (name[0] == '~') {
1777                         context->vartable[name] = new PolyphonicRealVariable({
1778                             .ctx = context
1779                         });
1780                     } else {
1781                         context->vartable[name] = new PolyphonicIntVariable({
1782                             .ctx = context
1783                         });
1784                     }
1785                 } else {
1786                     if (name[0] == '@') {
1787                         context->vartable[name] = new StringVariable(context);
1788                     } else if (name[0] == '~') {
1789                         context->vartable[name] = new RealVariable({
1790                             .ctx = context
1791                         });
1792                     } else if (name[0] == '$') {
1793                         context->vartable[name] = new IntVariable({
1794                             .ctx = context
1795                         });
1796                     } else if (name[0] == '?') {
1797                         PARSE_ERR((yylsp[-1]), (String("Real number array variable '") + name + "' declaration requires array size.").c_str());
1798                     } else if (name[0] == '%') {
1799                         PARSE_ERR((yylsp[-1]), (String("Integer array variable '") + name + "' declaration requires array size.").c_str());
1800                     } else {
1801                         PARSE_ERR((yylsp[-1]), (String("Variable '") + name + "' declared with unknown type.").c_str());
1802                     }
1803                 }
1804             } else {
1805                 if (qPatch)
1806                     context->patchVars[name].exprBlock = ASSIGNED_EXPR_BLOCK((yylsp[0]));
1807                 if (qPolyphonic && !isNumber(expr->exprType())) {
1808                     PARSE_ERR((yylsp[-1]), "Polyphonic variables must only be declared either as integer or real number type.");
1809                 } else if (expr->exprType() == STRING_EXPR) {
1810                     if (name[0] != '@')
1811                         PARSE_WRN((yylsp[-1]), (String("Variable '") + name + "' declared as " + typeStr(declType) + ", string expression assigned though.").c_str());
1812                     StringExprRef strExpr = expr;
1813                     String s;
1814                     if (qConst) {
1815                         if (strExpr->isConstExpr())
1816                             s = strExpr->evalStr();
1817                         else
1818                             PARSE_ERR((yylsp[0]), (String("Assignment to const string variable '") + name + "' requires const expression.").c_str());
1819                         ConstStringVariableRef var = new ConstStringVariable(context, s);
1820                         context->vartable[name] = var;
1821                     } else {
1822                         if (strExpr->isConstExpr()) {
1823                             s = strExpr->evalStr();
1824                             StringVariableRef var = new StringVariable(context);
1825                             context->vartable[name] = var;
1826                             (yyval.nStatement) = new Assignment(var, new StringLiteral(s));
1827                         } else {
1828                             StringVariableRef var = new StringVariable(context);
1829                             context->vartable[name] = var;
1830                             (yyval.nStatement) = new Assignment(var, strExpr);
1831                         }
1832                     }
1833                 } else if (expr->exprType() == REAL_EXPR) {
1834                     if (name[0] != '~')
1835                         PARSE_WRN((yylsp[-1]), (String("Variable '") + name + "' declared as " + typeStr(declType) + ", real number expression assigned though.").c_str());
1836                     RealExprRef realExpr = expr;
1837                     if (qConst) {
1838                         if (!realExpr->isConstExpr()) {
1839                             PARSE_ERR((yylsp[0]), (String("Assignment to const real number variable '") + name + "' requires const expression.").c_str());
1840                         }
1841                         ConstRealVariableRef var = new ConstRealVariable(
1842                             #if defined(__GNUC__) && !defined(__clang__)
1843                             (const RealVarDef&) // GCC 8.x requires this cast here (looks like a GCC bug to me); cast would cause an error with clang though
1844                             #endif
1845                         {
1846                             .value = (realExpr->isConstExpr()) ? realExpr->evalReal() : vmfloat(0),
1847                             .unitFactor = (realExpr->isConstExpr()) ? realExpr->unitFactor() : VM_NO_FACTOR,
1848                             .unitType = realExpr->unitType(),
1849                             .isFinal = realExpr->isFinal()
1850                         });
1851                         context->vartable[name] = var;
1852                     } else {
1853                         RealVariableRef var = new RealVariable({
1854                             .ctx = context,
1855                             .unitType = realExpr->unitType(),
1856                             .isFinal = realExpr->isFinal()
1857                         });
1858                         if (realExpr->isConstExpr()) {
1859                             (yyval.nStatement) = new Assignment(var, new RealLiteral({
1860                                 .value = realExpr->evalReal(),
1861                                 .unitFactor = realExpr->unitFactor(),
1862                                 .unitType = realExpr->unitType(),
1863                                 .isFinal = realExpr->isFinal()
1864                             }));
1865                         } else {
1866                             (yyval.nStatement) = new Assignment(var, realExpr);
1867                         }
1868                         context->vartable[name] = var;
1869                     }
1870                 } else if (expr->exprType() == INT_EXPR) {
1871                     if (name[0] != '$')
1872                         PARSE_WRN((yylsp[-1]), (String("Variable '") + name + "' declared as " + typeStr(declType) + ", integer expression assigned though.").c_str());
1873                     IntExprRef intExpr = expr;
1874                     if (qConst) {
1875                         if (!intExpr->isConstExpr()) {
1876                             PARSE_ERR((yylsp[0]), (String("Assignment to const integer variable '") + name + "' requires const expression.").c_str());
1877                         }
1878                         ConstIntVariableRef var = new ConstIntVariable(
1879                             #if defined(__GNUC__) && !defined(__clang__)
1880                             (const IntVarDef&) // GCC 8.x requires this cast here (looks like a GCC bug to me); cast would cause an error with clang though
1881                             #endif
1882                         {
1883                             .value = (intExpr->isConstExpr()) ? intExpr->evalInt() : 0,
1884                             .unitFactor = (intExpr->isConstExpr()) ? intExpr->unitFactor() : VM_NO_FACTOR,
1885                             .unitType = intExpr->unitType(),
1886                             .isFinal = intExpr->isFinal()
1887                         });
1888                         context->vartable[name] = var;
1889                     } else {
1890                         IntVariableRef var = new IntVariable({
1891                             .ctx = context,
1892                             .unitType = intExpr->unitType(),
1893                             .isFinal = intExpr->isFinal()
1894                         });
1895                         if (intExpr->isConstExpr()) {
1896                             (yyval.nStatement) = new Assignment(var, new IntLiteral({
1897                                 .value = intExpr->evalInt(),
1898                                 .unitFactor = intExpr->unitFactor(),
1899                                 .unitType = intExpr->unitType(),
1900                                 .isFinal = intExpr->isFinal()
1901                             }));
1902                         } else {
1903                             (yyval.nStatement) = new Assignment(var, intExpr);
1904                         }
1905                         context->vartable[name] = var;
1906                     }
1907                 } else if (expr->exprType() == EMPTY_EXPR) {
1908                     PARSE_ERR((yylsp[0]), "Expression does not result in a value.");
1909                     (yyval.nStatement) = new NoOperation;
1910                 } else if (isArray(expr->exprType())) {
1911                     PARSE_ERR((yylsp[-1]), (String("Variable '") + name + "' declared as scalar type, array expression assigned though.").c_str());
1912                     (yyval.nStatement) = new NoOperation;
1913                 }
1914             }
1915         }
1916     }
1917 #line 1918 "y.tab.c" /* yacc.c:1652  */
1918     break;
1919 
1920   case 21:
1921 #line 378 "parser.y" /* yacc.c:1652  */
1922     {
1923         (yyval.nStatement) = new NoOperation; // just as default result value
1924         const bool qConst      = (yyvsp[-5].varQualifier) & QUALIFIER_CONST;
1925         const bool qPolyphonic = (yyvsp[-5].varQualifier) & QUALIFIER_POLYPHONIC;
1926         const bool qPatch      = (yyvsp[-5].varQualifier) & QUALIFIER_PATCH;
1927         const char* name = (yyvsp[-4].sValue);
1928         if (qPatch)
1929             context->patchVars[name].nameBlock = CODE_BLOCK((yylsp[-4]));
1930         if ((yyvsp[-2].nExpression) && !(yyvsp[-2].nExpression)->isConstExpr()) {
1931             PARSE_ERR((yylsp[-2]), (String("Array variable '") + name + "' must be declared with constant array size.").c_str());
1932         } else if ((yyvsp[-2].nExpression) && (yyvsp[-2].nExpression)->exprType() != INT_EXPR) {
1933             PARSE_ERR((yylsp[-2]), (String("Size of array variable '") + name + "' declared with non integer expression.").c_str());
1934         } else if (context->variableByName(name)) {
1935             PARSE_ERR((yylsp[-4]), (String("Redeclaration of variable '") + name + "'.").c_str());
1936         } else if (qConst && !(yyvsp[0].nArgs)) {
1937             PARSE_ERR((yylsp[-5]), (String("Array variable '") + name + "' declared const without value assignment.").c_str());
1938         } else if (qPolyphonic) {
1939             PARSE_ERR((yylsp[-5]), (String("Array variable '") + name + "' must not be declared polyphonic.").c_str());
1940         } else {
1941             IntExprRef sizeExpr = (yyvsp[-2].nExpression);
1942             ArgsRef args = (yyvsp[0].nArgs);
1943             vmint size = (sizeExpr) ? sizeExpr->evalInt() : (args) ? args->argsCount() : 0;
1944             if (size == 0)
1945                 PARSE_WRN((yylsp[-2]), (String("Array variable '") + name + "' declared with zero array size.").c_str());
1946             if (size < 0) {
1947                 PARSE_ERR((yylsp[-2]), (String("Array variable '") + name + "' must not be declared with negative array size.").c_str());
1948             } else if (sizeExpr && (sizeExpr->unitType() || sizeExpr->hasUnitFactorNow())) {
1949                 PARSE_ERR((yylsp[-2]), "Units are not allowed as array size.");
1950             } else {
1951                 if (sizeExpr && sizeExpr->isFinal())
1952                     PARSE_WRN((yylsp[-2]), "Final operator '!' is meaningless here.");
1953                 if (!args) {
1954                     if (name[0] == '?') {
1955                         context->vartable[name] = new RealArrayVariable(context, size);
1956                     } else if (name[0] == '%') {
1957                         context->vartable[name] = new IntArrayVariable(context, size);
1958                     } else {
1959                         PARSE_ERR((yylsp[-4]), (String("Variable '") + name + "' declared as unknown array type: use either '%' or '?' instead of '" + String(name).substr(0,1) + "'.").c_str());
1960                     }
1961                 } else {
1962                     if (qPatch)
1963                         context->patchVars[name].exprBlock = ASSIGNED_EXPR_BLOCK((yylsp[0]));
1964                     if (size == 0)
1965                         PARSE_WRN((yylsp[-2]), (String("Array variable '") + name + "' declared with zero array size.").c_str());
1966                     if (size < 0) {
1967                         PARSE_ERR((yylsp[-2]), (String("Array variable '") + name + "' must not be declared with negative array size.").c_str());
1968                     } else if (args->argsCount() > size) {
1969                         PARSE_ERR((yylsp[0]), (String("Array variable '") + name +
1970                                   "' was declared with size " + ToString(size) +
1971                                   " but " + ToString(args->argsCount()) +
1972                                   " values were assigned." ).c_str());
1973                     } else {
1974                         if (args->argsCount() < size) {
1975                             PARSE_WRN((yylsp[-2]), (String("Array variable '") + name +
1976                                       "' was declared with size " + ToString(size) +
1977                                       " but only " + ToString(args->argsCount()) +
1978                                       " values were assigned." ).c_str());
1979                         }
1980                         ExprType_t declType = EMPTY_EXPR;
1981                         if (name[0] == '%') {
1982                             declType = INT_EXPR;
1983                         } else if (name[0] == '?') {
1984                             declType = REAL_EXPR;
1985                         } else if (name[0] == '$') {
1986                             PARSE_ERR((yylsp[-4]), (String("Variable '") + name + "' declaration ambiguous: Use '%' as name prefix for integer arrays instead of '$'.").c_str());
1987                         } else if (name[0] == '~') {
1988                             PARSE_ERR((yylsp[-4]), (String("Variable '") + name + "' declaration ambiguous: Use '?' as name prefix for real number arrays instead of '~'.").c_str());
1989                         } else {
1990                             PARSE_ERR((yylsp[-4]), (String("Variable '") + name + "' declared as unknown array type: use either '%' or '?' instead of '" + String(name).substr(0,1) + "'.").c_str());
1991                         }
1992                         bool argsOK = true;
1993                         if (declType == EMPTY_EXPR) {
1994                             argsOK = false;
1995                         } else {
1996                             for (vmint i = 0; i < args->argsCount(); ++i) {
1997                                 if (args->arg(i)->exprType() != declType) {
1998                                     PARSE_ERR(
1999                                         (yylsp[0]),
2000                                         (String("Array variable '") + name +
2001                                         "' declared with invalid assignment values. Assigned element " +
2002                                         ToString(i+1) + " is not an " + typeStr(declType) + " expression.").c_str()
2003                                     );
2004                                     argsOK = false;
2005                                     break;
2006                                 } else if (qConst && !args->arg(i)->isConstExpr()) {
2007                                     PARSE_ERR(
2008                                         (yylsp[0]),
2009                                         (String("const array variable '") + name +
2010                                         "' must be defined with const values. Assigned element " +
2011                                         ToString(i+1) + " is not a const expression though.").c_str()
2012                                     );
2013                                     argsOK = false;
2014                                     break;
2015                                 } else if (args->arg(i)->asNumber()->unitType()) {
2016                                     PARSE_ERR(
2017                                         (yylsp[0]),
2018                                         (String("Array variable '") + name +
2019                                         "' declared with invalid assignment values. Assigned element " +
2020                                         ToString(i+1) + " contains a unit type, only metric prefixes are allowed for arrays.").c_str()
2021                                     );
2022                                     argsOK = false;
2023                                     break;
2024                                 } else if (args->arg(i)->asNumber()->isFinal()) {
2025                                     PARSE_ERR(
2026                                         (yylsp[0]),
2027                                         (String("Array variable '") + name +
2028                                         "' declared with invalid assignment values. Assigned element " +
2029                                         ToString(i+1) + " declared as 'final' value.").c_str()
2030                                     );
2031                                     argsOK = false;
2032                                     break;
2033                                 }
2034                             }
2035                         }
2036                         if (argsOK) {
2037                             if (declType == REAL_EXPR)
2038                                 context->vartable[name] = new RealArrayVariable(context, size, args, qConst);
2039                             else
2040                                 context->vartable[name] = new IntArrayVariable(context, size, args, qConst);
2041                         }
2042                     }
2043                 }
2044             }
2045         }
2046     }
2047 #line 2048 "y.tab.c" /* yacc.c:1652  */
2048     break;
2049 
2050   case 22:
2051 #line 503 "parser.y" /* yacc.c:1652  */
2052     {
2053         (yyval.nStatement) = (yyvsp[0].nStatement);
2054     }
2055 #line 2056 "y.tab.c" /* yacc.c:1652  */
2056     break;
2057 
2058   case 23:
2059 #line 506 "parser.y" /* yacc.c:1652  */
2060     {
2061         if ((yyvsp[-4].nExpression)->exprType() == INT_EXPR) {
2062             IntExprRef expr = (yyvsp[-4].nExpression);
2063             if (expr->asNumber()->unitType() ||
2064                 expr->asNumber()->hasUnitFactorEver())
2065                 PARSE_WRN((yylsp[-4]), "Condition for 'while' loops contains a unit.");
2066             else if (expr->isFinal() && expr->isConstExpr())
2067                 PARSE_WRN((yylsp[-4]), "Final operator '!' is meaningless here.");
2068             (yyval.nStatement) = new While(expr, (yyvsp[-2].nStatements));
2069         } else {
2070             PARSE_ERR((yylsp[-4]), "Condition for 'while' loops must be integer expression.");
2071             (yyval.nStatement) = new While(new IntLiteral({ .value = 0 }), (yyvsp[-2].nStatements));
2072         }
2073     }
2074 #line 2075 "y.tab.c" /* yacc.c:1652  */
2075     break;
2076 
2077   case 24:
2078 #line 520 "parser.y" /* yacc.c:1652  */
2079     {
2080         (yyval.nStatement) = new SyncBlock((yyvsp[-2].nStatements));
2081     }
2082 #line 2083 "y.tab.c" /* yacc.c:1652  */
2083     break;
2084 
2085   case 25:
2086 #line 523 "parser.y" /* yacc.c:1652  */
2087     {
2088         if ((yyvsp[-6].nExpression)->exprType() == INT_EXPR) {
2089             IntExprRef expr = (yyvsp[-6].nExpression);
2090             if (expr->asNumber()->unitType() ||
2091                 expr->asNumber()->hasUnitFactorEver())
2092                 PARSE_WRN((yylsp[-6]), "Condition for 'if' contains a unit.");
2093             else if (expr->isFinal() && expr->isConstExpr())
2094                 PARSE_WRN((yylsp[-6]), "Final operator '!' is meaningless here.");
2095             (yyval.nStatement) = new If((yyvsp[-6].nExpression), (yyvsp[-4].nStatements), (yyvsp[-2].nStatements));
2096         } else {
2097             PARSE_ERR((yylsp[-6]), "Condition for 'if' must be integer expression.");
2098             (yyval.nStatement) = new If(new IntLiteral({ .value = 0 }), (yyvsp[-4].nStatements), (yyvsp[-2].nStatements));
2099         }
2100     }
2101 #line 2102 "y.tab.c" /* yacc.c:1652  */
2102     break;
2103 
2104   case 26:
2105 #line 537 "parser.y" /* yacc.c:1652  */
2106     {
2107         if ((yyvsp[-4].nExpression)->exprType() == INT_EXPR) {
2108             IntExprRef expr = (yyvsp[-4].nExpression);
2109             if (expr->asNumber()->unitType() ||
2110                 expr->asNumber()->hasUnitFactorEver())
2111                 PARSE_WRN((yylsp[-4]), "Condition for 'if' contains a unit.");
2112             else if (expr->isFinal() && expr->isConstExpr())
2113                 PARSE_WRN((yylsp[-4]), "Final operator '!' is meaningless here.");
2114             (yyval.nStatement) = new If((yyvsp[-4].nExpression), (yyvsp[-2].nStatements));
2115         } else {
2116             PARSE_ERR((yylsp[-4]), "Condition for 'if' must be integer expression.");
2117             (yyval.nStatement) = new If(new IntLiteral({ .value = 0 }), (yyvsp[-2].nStatements));
2118         }
2119     }
2120 #line 2121 "y.tab.c" /* yacc.c:1652  */
2121     break;
2122 
2123   case 27:
2124 #line 551 "parser.y" /* yacc.c:1652  */
2125     {
2126         if ((yyvsp[-3].nExpression)->exprType() == INT_EXPR) {
2127             IntExprRef expr = (yyvsp[-3].nExpression);
2128             if (expr->unitType() || expr->hasUnitFactorEver()) {
2129                 PARSE_ERR((yylsp[-3]), "Units are not allowed here.");
2130                 (yyval.nStatement) = new SelectCase(new IntLiteral({ .value = 0 }), (yyvsp[-2].nCaseBranches));
2131             } else {
2132                 if (expr->isFinal() && expr->isConstExpr())
2133                     PARSE_WRN((yylsp[-3]), "Final operator '!' is meaningless here.");
2134                 (yyval.nStatement) = new SelectCase(expr, (yyvsp[-2].nCaseBranches));
2135             }
2136         } else {
2137             PARSE_ERR((yylsp[-3]), "Statement 'select' can only by applied to integer expressions.");
2138             (yyval.nStatement) = new SelectCase(new IntLiteral({ .value = 0 }), (yyvsp[-2].nCaseBranches));
2139         }
2140     }
2141 #line 2142 "y.tab.c" /* yacc.c:1652  */
2142     break;
2143 
2144   case 28:
2145 #line 569 "parser.y" /* yacc.c:1652  */
2146     {
2147         (yyval.nCaseBranches) = CaseBranches();
2148         (yyval.nCaseBranches).push_back((yyvsp[0].nCaseBranch));
2149     }
2150 #line 2151 "y.tab.c" /* yacc.c:1652  */
2151     break;
2152 
2153   case 29:
2154 #line 573 "parser.y" /* yacc.c:1652  */
2155     {
2156         (yyval.nCaseBranches) = (yyvsp[-1].nCaseBranches);
2157         (yyval.nCaseBranches).push_back((yyvsp[0].nCaseBranch));
2158     }
2159 #line 2160 "y.tab.c" /* yacc.c:1652  */
2160     break;
2161 
2162   case 30:
2163 #line 579 "parser.y" /* yacc.c:1652  */
2164     {
2165         (yyval.nCaseBranch) = CaseBranch();
2166         (yyval.nCaseBranch).from = new IntLiteral({ .value = (yyvsp[-1].iValue) });
2167         (yyval.nCaseBranch).statements = (yyvsp[0].nStatements);
2168     }
2169 #line 2170 "y.tab.c" /* yacc.c:1652  */
2170     break;
2171 
2172   case 31:
2173 #line 584 "parser.y" /* yacc.c:1652  */
2174     {
2175         (yyval.nCaseBranch) = CaseBranch();
2176         (yyval.nCaseBranch).from = new IntLiteral({ .value = (yyvsp[-3].iValue) });
2177         (yyval.nCaseBranch).to   = new IntLiteral({ .value = (yyvsp[-1].iValue) });
2178         (yyval.nCaseBranch).statements = (yyvsp[0].nStatements);
2179     }
2180 #line 2181 "y.tab.c" /* yacc.c:1652  */
2181     break;
2182 
2183   case 32:
2184 #line 592 "parser.y" /* yacc.c:1652  */
2185     {
2186         const char* name = (yyvsp[0].sValue);
2187         UserFunctionRef fn = context->userFunctionByName(name);
2188         if (context->functionProvider->functionByName(name)) {
2189             PARSE_ERR((yylsp[-1]), (String("Keyword 'call' must only be used for user defined functions, not for any built-in function like '") + name + "'.").c_str());
2190             (yyval.nStatements) = StatementsRef();
2191         } else if (!fn) {
2192             PARSE_ERR((yylsp[0]), (String("No user defined function with name '") + name + "'.").c_str());
2193             (yyval.nStatements) = StatementsRef();
2194         } else {
2195             (yyval.nStatements) = fn;
2196         }
2197     }
2198 #line 2199 "y.tab.c" /* yacc.c:1652  */
2199     break;
2200 
2201   case 33:
2202 #line 607 "parser.y" /* yacc.c:1652  */
2203     {
2204         const char* name = (yyvsp[-3].sValue);
2205         //printf("function call of '%s' with args\n", name);
2206         ArgsRef args = (yyvsp[-1].nArgs);
2207         VMFunction* fn = context->functionProvider->functionByName(name);
2208         if (context->userFunctionByName(name)) {
2209             PARSE_ERR((yylsp[-3]), (String("Missing 'call' keyword before user defined function name '") + name + "'.").c_str());
2210             (yyval.nFunctionCall) = new FunctionCall(name, args, NULL);
2211         } else if (!fn) {
2212             PARSE_ERR((yylsp[-3]), (String("No built-in function with name '") + name + "'.").c_str());
2213             (yyval.nFunctionCall) = new FunctionCall(name, args, NULL);
2214         } else if (context->functionProvider->isFunctionDisabled(fn,context)) {
2215             PARSE_DROP((yyloc));
2216             (yyval.nFunctionCall) = new NoFunctionCall;
2217         } else if (args->argsCount() < fn->minRequiredArgs()) {
2218             PARSE_ERR((yylsp[-1]), (String("Built-in function '") + name + "' requires at least " + ToString(fn->minRequiredArgs()) + " arguments.").c_str());
2219             (yyval.nFunctionCall) = new FunctionCall(name, args, NULL);
2220         } else if (args->argsCount() > fn->maxAllowedArgs()) {
2221             PARSE_ERR((yylsp[-1]), (String("Built-in function '") + name + "' accepts max. " + ToString(fn->maxAllowedArgs()) + " arguments.").c_str());
2222             (yyval.nFunctionCall) = new FunctionCall(name, args, NULL);
2223         } else {
2224             bool argsOK = true;
2225             for (vmint i = 0; i < args->argsCount(); ++i) {
2226                 if (!fn->acceptsArgType(i, args->arg(i)->exprType())) {
2227                     PARSE_ERR((yylsp[-1]), (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' expects " + acceptedArgTypesStr(fn, i) + " type, but type " + typeStr(args->arg(i)->exprType()) + " was given instead.").c_str());
2228                     argsOK = false;
2229                     break;
2230                 } else if (fn->modifiesArg(i) && !args->arg(i)->isModifyable()) {
2231                     PARSE_ERR((yylsp[-1]), (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' expects an assignable variable.").c_str());
2232                     argsOK = false;
2233                     break;
2234                 } else if (isNumber(args->arg(i)->exprType()) && !fn->acceptsArgUnitType(i, args->arg(i)->asNumber()->unitType())) {
2235                     if (args->arg(i)->asNumber()->unitType())
2236                         PARSE_ERR((yylsp[-1]), (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' does not expect unit " + unitTypeStr(args->arg(i)->asNumber()->unitType()) +  ".").c_str());
2237                     else
2238                         PARSE_ERR((yylsp[-1]), (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' expects a unit.").c_str());
2239                     argsOK = false;
2240                     break;
2241                 } else if (isNumber(args->arg(i)->exprType()) && args->arg(i)->asNumber()->hasUnitFactorEver() && !fn->acceptsArgUnitPrefix(i, args->arg(i)->asNumber()->unitType())) {
2242                     if (args->arg(i)->asNumber()->unitType())
2243                         PARSE_ERR((yylsp[-1]), (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' does not expect a unit prefix for unit" + unitTypeStr(args->arg(i)->asNumber()->unitType()) + ".").c_str());
2244                     else
2245                         PARSE_ERR((yylsp[-1]), (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' does not expect a unit prefix.").c_str());
2246                     argsOK = false;
2247                     break;
2248                 } else if (!fn->acceptsArgFinal(i) && isNumber(args->arg(i)->exprType()) && args->arg(i)->asNumber()->isFinal()) {
2249                     PARSE_ERR((yylsp[-1]), (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' does not expect a \"final\" value.").c_str());
2250                     argsOK = false;
2251                     break;
2252                 }
2253             }
2254             if (argsOK) {
2255                 // perform built-in function's own, custom arguments checks (if any)
2256                 fn->checkArgs(&*args, [&](String err) {
2257                     PARSE_ERR((yylsp[-1]), (String("Built-in function '") + name + "()': " + err).c_str());
2258                     argsOK = false;
2259                 }, [&](String wrn) {
2260                     PARSE_WRN((yylsp[-1]), (String("Built-in function '") + name + "()': " + wrn).c_str());
2261                 });
2262             }
2263             (yyval.nFunctionCall) = new FunctionCall(name, args, argsOK ? fn : NULL);
2264         }
2265     }
2266 #line 2267 "y.tab.c" /* yacc.c:1652  */
2267     break;
2268 
2269   case 34:
2270 #line 670 "parser.y" /* yacc.c:1652  */
2271     {
2272         const char* name = (yyvsp[-2].sValue);
2273         //printf("function call of '%s' (with empty args)\n", name);
2274         ArgsRef args = new Args;
2275         VMFunction* fn = context->functionProvider->functionByName(name);
2276         if (context->userFunctionByName(name)) {
2277             PARSE_ERR((yylsp[-2]), (String("Missing 'call' keyword before user defined function name '") + name + "'.").c_str());
2278             (yyval.nFunctionCall) = new FunctionCall(name, args, NULL);
2279         } else if (!fn) {
2280             PARSE_ERR((yylsp[-2]), (String("No built-in function with name '") + name + "'.").c_str());
2281             (yyval.nFunctionCall) = new FunctionCall(name, args, NULL);
2282         } else if (context->functionProvider->isFunctionDisabled(fn,context)) {
2283             PARSE_DROP((yyloc));
2284             (yyval.nFunctionCall) = new NoFunctionCall;
2285         } else if (fn->minRequiredArgs() > 0) {
2286             PARSE_ERR((yylsp[0]), (String("Built-in function '") + name + "' requires at least " + ToString(fn->minRequiredArgs()) + " arguments.").c_str());
2287             (yyval.nFunctionCall) = new FunctionCall(name, args, NULL);
2288         } else {
2289             (yyval.nFunctionCall) = new FunctionCall(name, args, fn);
2290         }
2291     }
2292 #line 2293 "y.tab.c" /* yacc.c:1652  */
2293     break;
2294 
2295   case 35:
2296 #line 691 "parser.y" /* yacc.c:1652  */
2297     {
2298         const char* name = (yyvsp[0].sValue);
2299         //printf("function call of '%s' (without args)\n", name);
2300         ArgsRef args = new Args;
2301         VMFunction* fn = context->functionProvider->functionByName(name);
2302         if (context->userFunctionByName(name)) {
2303             PARSE_ERR((yylsp[0]), (String("Missing 'call' keyword before user defined function name '") + name + "'.").c_str());
2304             (yyval.nFunctionCall) = new FunctionCall(name, args, NULL);
2305         } else if (!fn) {
2306             PARSE_ERR((yylsp[0]), (String("No built-in function with name '") + name + "'.").c_str());
2307             (yyval.nFunctionCall) = new FunctionCall(name, args, NULL);
2308         } else if (context->functionProvider->isFunctionDisabled(fn,context)) {
2309             PARSE_DROP((yyloc));
2310             (yyval.nFunctionCall) = new NoFunctionCall;
2311         } else if (fn->minRequiredArgs() > 0) {
2312             PARSE_ERR((yylsp[0]), (String("Built-in function '") + name + "' requires at least " + ToString(fn->minRequiredArgs()) + " arguments.").c_str());
2313             (yyval.nFunctionCall) = new FunctionCall(name, args, NULL);
2314         } else {
2315             (yyval.nFunctionCall) = new FunctionCall(name, args, fn);
2316         }
2317     }
2318 #line 2319 "y.tab.c" /* yacc.c:1652  */
2319     break;
2320 
2321   case 36:
2322 #line 714 "parser.y" /* yacc.c:1652  */
2323     {
2324         (yyval.nArgs) = new Args();
2325         (yyval.nArgs)->add((yyvsp[0].nExpression));
2326     }
2327 #line 2328 "y.tab.c" /* yacc.c:1652  */
2328     break;
2329 
2330   case 37:
2331 #line 718 "parser.y" /* yacc.c:1652  */
2332     {
2333         (yyval.nArgs) = (yyvsp[-2].nArgs);
2334         (yyval.nArgs)->add((yyvsp[0].nExpression));
2335     }
2336 #line 2337 "y.tab.c" /* yacc.c:1652  */
2337     break;
2338 
2339   case 39:
2340 #line 727 "parser.y" /* yacc.c:1652  */
2341     {
2342         (yyval.varQualifier) = QUALIFIER_NONE;
2343     }
2344 #line 2345 "y.tab.c" /* yacc.c:1652  */
2345     break;
2346 
2347   case 40:
2348 #line 730 "parser.y" /* yacc.c:1652  */
2349     {
2350         (yyval.varQualifier) = (yyvsp[0].varQualifier);
2351     }
2352 #line 2353 "y.tab.c" /* yacc.c:1652  */
2353     break;
2354 
2355   case 41:
2356 #line 735 "parser.y" /* yacc.c:1652  */
2357     {
2358         (yyval.varQualifier) = (yyvsp[0].varQualifier);
2359     }
2360 #line 2361 "y.tab.c" /* yacc.c:1652  */
2361     break;
2362 
2363   case 42:
2364 #line 738 "parser.y" /* yacc.c:1652  */
2365     {
2366         if ((yyvsp[-1].varQualifier) & (yyvsp[0].varQualifier))
2367             PARSE_ERR((yylsp[0]), ("Qualifier '" + qualifierStr((yyvsp[0].varQualifier)) + "' must only be listed once.").c_str());
2368         (yyval.varQualifier) = (Qualifier_t) ((yyvsp[-1].varQualifier) | (yyvsp[0].varQualifier));
2369     }
2370 #line 2371 "y.tab.c" /* yacc.c:1652  */
2371     break;
2372 
2373   case 43:
2374 #line 745 "parser.y" /* yacc.c:1652  */
2375     {
2376         (yyval.varQualifier) = QUALIFIER_CONST;
2377     }
2378 #line 2379 "y.tab.c" /* yacc.c:1652  */
2379     break;
2380 
2381   case 44:
2382 #line 748 "parser.y" /* yacc.c:1652  */
2383     {
2384         (yyval.varQualifier) = QUALIFIER_POLYPHONIC;
2385     }
2386 #line 2387 "y.tab.c" /* yacc.c:1652  */
2387     break;
2388 
2389   case 45:
2390 #line 751 "parser.y" /* yacc.c:1652  */
2391     {
2392         (yyval.varQualifier) = QUALIFIER_PATCH;
2393     }
2394 #line 2395 "y.tab.c" /* yacc.c:1652  */
2395     break;
2396 
2397   case 46:
2398 #line 756 "parser.y" /* yacc.c:1652  */
2399     {
2400         (yyval.nExpression) = ExpressionRef();
2401     }
2402 #line 2403 "y.tab.c" /* yacc.c:1652  */
2403     break;
2404 
2405   case 47:
2406 #line 759 "parser.y" /* yacc.c:1652  */
2407     {
2408         (yyval.nExpression) = (yyvsp[0].nExpression);
2409     }
2410 #line 2411 "y.tab.c" /* yacc.c:1652  */
2411     break;
2412 
2413   case 48:
2414 #line 764 "parser.y" /* yacc.c:1652  */
2415     {
2416         (yyval.nArgs) = ArgsRef();
2417     }
2418 #line 2419 "y.tab.c" /* yacc.c:1652  */
2419     break;
2420 
2421   case 49:
2422 #line 767 "parser.y" /* yacc.c:1652  */
2423     {
2424         (yyval.nArgs) = (yyvsp[-1].nArgs);
2425     }
2426 #line 2427 "y.tab.c" /* yacc.c:1652  */
2427     break;
2428 
2429   case 50:
2430 #line 772 "parser.y" /* yacc.c:1652  */
2431     {
2432         //printf("variable lookup with name '%s' as assignment expr\n", $1);
2433         const char* name = (yyvsp[-2].sValue);
2434         VariableRef var = context->variableByName(name);
2435         if (!var)
2436             PARSE_ERR((yylsp[-2]), (String("Variable assignment: No variable declared with name '") + name + "'.").c_str());
2437         else if (var->isConstExpr())
2438             PARSE_ERR((yylsp[-1]), (String("Variable assignment: Cannot modify const variable '") + name + "'.").c_str());
2439         else if (!var->isAssignable())
2440             PARSE_ERR((yylsp[-1]), (String("Variable assignment: Variable '") + name + "' is not assignable.").c_str());
2441         else if (var->exprType() != (yyvsp[0].nExpression)->exprType())
2442             PARSE_ERR((yylsp[0]), (String("Variable assignment: Variable '") + name + "' is of type " + typeStr(var->exprType()) + ", assignment is of type " + typeStr((yyvsp[0].nExpression)->exprType()) + " though.").c_str());
2443         else if (isNumber(var->exprType())) {
2444             NumberVariableRef numberVar = var;
2445             NumberExprRef expr = (yyvsp[0].nExpression);
2446             if (numberVar->unitType() != expr->unitType())
2447                 PARSE_ERR((yylsp[0]), (String("Variable assignment: Variable '") + name + "' has unit type " + unitTypeStr(numberVar->unitType()) + ", assignment has unit type " + unitTypeStr(expr->unitType()) + " though.").c_str());
2448             else if (numberVar->isFinal() != expr->isFinal())
2449                 PARSE_ERR((yylsp[0]), (String("Variable assignment: Variable '") + name + "' was declared as " + String(numberVar->isFinal() ? "final" : "not final") + ", assignment is " + String(expr->isFinal() ? "final" : "not final") + " though.").c_str());
2450         }
2451 
2452         if (var)
2453             (yyval.nStatement) = new Assignment(var, (yyvsp[0].nExpression));
2454         else
2455             (yyval.nStatement) = new NoOperation;
2456     }
2457 #line 2458 "y.tab.c" /* yacc.c:1652  */
2458     break;
2459 
2460   case 51:
2461 #line 798 "parser.y" /* yacc.c:1652  */
2462     {
2463         const char* name = (yyvsp[-5].sValue);
2464         VariableRef var = context->variableByName(name);
2465         if (!var)
2466             PARSE_ERR((yylsp[-5]), (String("No variable declared with name '") + name + "'.").c_str());
2467         else if (!isArray(var->exprType()))
2468             PARSE_ERR((yylsp[-4]), (String("Variable '") + name + "' is not an array variable.").c_str());
2469         else if (var->isConstExpr())
2470             PARSE_ERR((yylsp[-1]), (String("Variable assignment: Cannot modify const array variable '") + name + "'.").c_str());
2471         else if (!var->isAssignable())
2472             PARSE_ERR((yylsp[-1]), (String("Variable assignment: Array variable '") + name + "' is not assignable.").c_str());
2473         else if ((yyvsp[-3].nExpression)->exprType() != INT_EXPR)
2474             PARSE_ERR((yylsp[-3]), (String("Array variable '") + name + "' accessed with non integer expression.").c_str());
2475         else if ((yyvsp[-3].nExpression)->asInt()->unitType())
2476             PARSE_ERR((yylsp[-3]), "Unit types are not allowed as array index.");
2477         else if ((yyvsp[0].nExpression)->exprType() != scalarTypeOfArray(var->exprType()))
2478             PARSE_ERR((yylsp[-1]), (String("Variable '") + name + "' was declared as " + typeStr(var->exprType()) + ", assigned expression is " + typeStr((yyvsp[0].nExpression)->exprType()) + " though.").c_str());
2479         else if ((yyvsp[0].nExpression)->asNumber()->unitType())
2480             PARSE_ERR((yylsp[0]), "Unit types are not allowed for array variables.");
2481         else if ((yyvsp[0].nExpression)->asNumber()->isFinal())
2482             PARSE_ERR((yylsp[0]), "Final operator '!' not allowed for array variables.");
2483         else if ((yyvsp[-3].nExpression)->isConstExpr() && (yyvsp[-3].nExpression)->asInt()->evalInt() >= ((ArrayExprRef)var)->arraySize())
2484             PARSE_WRN((yylsp[-3]), (String("Index ") + ToString((yyvsp[-3].nExpression)->asInt()->evalInt()) +
2485                           " exceeds size of array variable '" + name +
2486                           "' which was declared with size " +
2487                           ToString(((ArrayExprRef)var)->arraySize()) + ".").c_str());
2488         else if ((yyvsp[-3].nExpression)->asInt()->isFinal())
2489             PARSE_WRN((yylsp[-3]), "Final operator '!' is meaningless here.");
2490 
2491         if (!var) {
2492             (yyval.nStatement) = new NoOperation;
2493         } else if (var->exprType() == INT_ARR_EXPR) {
2494             IntArrayElementRef element = new IntArrayElement(var, (yyvsp[-3].nExpression));
2495             (yyval.nStatement) = new Assignment(element, (yyvsp[0].nExpression));
2496         } else if (var->exprType() == REAL_ARR_EXPR) {
2497             RealArrayElementRef element = new RealArrayElement(var, (yyvsp[-3].nExpression));
2498             (yyval.nStatement) = new Assignment(element, (yyvsp[0].nExpression));
2499         }
2500     }
2501 #line 2502 "y.tab.c" /* yacc.c:1652  */
2502     break;
2503 
2504   case 52:
2505 #line 839 "parser.y" /* yacc.c:1652  */
2506     {
2507         (yyval.nExpression) = new IntLiteral({ .value = (yyvsp[0].iValue) });
2508     }
2509 #line 2510 "y.tab.c" /* yacc.c:1652  */
2510     break;
2511 
2512   case 53:
2513 #line 842 "parser.y" /* yacc.c:1652  */
2514     {
2515         (yyval.nExpression) = new RealLiteral({ .value = (yyvsp[0].fValue) });
2516     }
2517 #line 2518 "y.tab.c" /* yacc.c:1652  */
2518     break;
2519 
2520   case 54:
2521 #line 845 "parser.y" /* yacc.c:1652  */
2522     {
2523         IntLiteralRef literal = new IntLiteral({
2524             .value = (yyvsp[0].iUnitValue).iValue,
2525             .unitFactor = VMUnit::unitFactor((yyvsp[0].iUnitValue).prefix),
2526             .unitType = (yyvsp[0].iUnitValue).unit
2527         });
2528         (yyval.nExpression) = literal;
2529     }
2530 #line 2531 "y.tab.c" /* yacc.c:1652  */
2531     break;
2532 
2533   case 55:
2534 #line 853 "parser.y" /* yacc.c:1652  */
2535     {
2536         RealLiteralRef literal = new RealLiteral({
2537             .value = (yyvsp[0].fUnitValue).fValue,
2538             .unitFactor = VMUnit::unitFactor((yyvsp[0].fUnitValue).prefix),
2539             .unitType = (yyvsp[0].fUnitValue).unit
2540         });
2541         (yyval.nExpression) = literal;
2542     }
2543 #line 2544 "y.tab.c" /* yacc.c:1652  */
2544     break;
2545 
2546   case 56:
2547 #line 861 "parser.y" /* yacc.c:1652  */
2548     {
2549         (yyval.nExpression) = new StringLiteral((yyvsp[0].sValue));
2550     }
2551 #line 2552 "y.tab.c" /* yacc.c:1652  */
2552     break;
2553 
2554   case 57:
2555 #line 864 "parser.y" /* yacc.c:1652  */
2556     {
2557         //printf("variable lookup with name '%s' as unary expr\n", $1);
2558         VariableRef var = context->variableByName((yyvsp[0].sValue));
2559         if (var)
2560             (yyval.nExpression) = var;
2561         else {
2562             PARSE_ERR((yylsp[0]), (String("No variable declared with name '") + (yyvsp[0].sValue) + "'.").c_str());
2563             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2564         }
2565     }
2566 #line 2567 "y.tab.c" /* yacc.c:1652  */
2567     break;
2568 
2569   case 58:
2570 #line 874 "parser.y" /* yacc.c:1652  */
2571     {
2572         const char* name = (yyvsp[-3].sValue);
2573         VariableRef var = context->variableByName(name);
2574         if (!var) {
2575             PARSE_ERR((yylsp[-3]), (String("No variable declared with name '") + name + "'.").c_str());
2576             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2577         } else if (!isArray(var->exprType())) {
2578             PARSE_ERR((yylsp[-2]), (String("Variable '") + name + "' is not an array variable.").c_str());
2579             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2580         } else if ((yyvsp[-1].nExpression)->exprType() != INT_EXPR) {
2581             PARSE_ERR((yylsp[-1]), (String("Array variable '") + name + "' accessed with non integer expression.").c_str());
2582             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2583         } else if ((yyvsp[-1].nExpression)->asInt()->unitType() || (yyvsp[-1].nExpression)->asInt()->hasUnitFactorEver()) {
2584             PARSE_ERR((yylsp[-1]), "Units are not allowed as array index.");
2585             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2586         } else {
2587             if ((yyvsp[-1].nExpression)->isConstExpr() && (yyvsp[-1].nExpression)->asInt()->evalInt() >= ((ArrayExprRef)var)->arraySize())
2588                 PARSE_WRN((yylsp[-1]), (String("Index ") + ToString((yyvsp[-1].nExpression)->asInt()->evalInt()) +
2589                                " exceeds size of array variable '" + name +
2590                                "' which was declared with size " +
2591                                ToString(((ArrayExprRef)var)->arraySize()) + ".").c_str());
2592             else if ((yyvsp[-1].nExpression)->asInt()->isFinal())
2593                 PARSE_WRN((yylsp[-1]), "Final operator '!' is meaningless here.");
2594             if (var->exprType() == REAL_ARR_EXPR) {
2595                 (yyval.nExpression) = new RealArrayElement(var, (yyvsp[-1].nExpression));
2596             } else {
2597                 (yyval.nExpression) = new IntArrayElement(var, (yyvsp[-1].nExpression));
2598             }
2599         }
2600     }
2601 #line 2602 "y.tab.c" /* yacc.c:1652  */
2602     break;
2603 
2604   case 59:
2605 #line 904 "parser.y" /* yacc.c:1652  */
2606     {
2607         (yyval.nExpression) = (yyvsp[-1].nExpression);
2608     }
2609 #line 2610 "y.tab.c" /* yacc.c:1652  */
2610     break;
2611 
2612   case 60:
2613 #line 907 "parser.y" /* yacc.c:1652  */
2614     {
2615         (yyval.nExpression) = (yyvsp[0].nFunctionCall);
2616     }
2617 #line 2618 "y.tab.c" /* yacc.c:1652  */
2618     break;
2619 
2620   case 61:
2621 #line 910 "parser.y" /* yacc.c:1652  */
2622     {
2623         if (isNumber((yyvsp[0].nExpression)->exprType())) {
2624             (yyval.nExpression) = (yyvsp[0].nExpression);
2625         } else {
2626             PARSE_ERR((yylsp[0]), (String("Unary '+' operator requires number, is ") + typeStr((yyvsp[0].nExpression)->exprType()) + " though.").c_str());
2627             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2628         }
2629     }
2630 #line 2631 "y.tab.c" /* yacc.c:1652  */
2631     break;
2632 
2633   case 62:
2634 #line 918 "parser.y" /* yacc.c:1652  */
2635     {
2636         if (isNumber((yyvsp[0].nExpression)->exprType())) {
2637             (yyval.nExpression) = new Neg((yyvsp[0].nExpression));
2638         } else {
2639             PARSE_ERR((yylsp[0]), (String("Unary '-' operator requires number, is ") + typeStr((yyvsp[0].nExpression)->exprType()) + " though.").c_str());
2640             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2641         }
2642     }
2643 #line 2644 "y.tab.c" /* yacc.c:1652  */
2644     break;
2645 
2646   case 63:
2647 #line 926 "parser.y" /* yacc.c:1652  */
2648     {
2649         if ((yyvsp[0].nExpression)->exprType() != INT_EXPR) {
2650             PARSE_ERR((yylsp[0]), (String("Right operand of bitwise operator '.not.' must be an integer expression, is ") + typeStr((yyvsp[0].nExpression)->exprType()) + " though.").c_str());
2651             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2652         } else if ((yyvsp[0].nExpression)->asInt()->unitType() || (yyvsp[0].nExpression)->asInt()->hasUnitFactorEver()) {
2653             PARSE_ERR((yylsp[0]), "Units are not allowed for operands of bitwise operations.");
2654             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2655         } else {
2656             (yyval.nExpression) = new BitwiseNot((yyvsp[0].nExpression));
2657         }
2658     }
2659 #line 2660 "y.tab.c" /* yacc.c:1652  */
2660     break;
2661 
2662   case 64:
2663 #line 937 "parser.y" /* yacc.c:1652  */
2664     {
2665         if ((yyvsp[0].nExpression)->exprType() != INT_EXPR) {
2666             PARSE_ERR((yylsp[0]), (String("Right operand of operator 'not' must be an integer expression, is ") + typeStr((yyvsp[0].nExpression)->exprType()) + " though.").c_str());
2667             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2668         } else if ((yyvsp[0].nExpression)->asInt()->unitType() || (yyvsp[0].nExpression)->asInt()->hasUnitFactorEver()) {
2669             PARSE_ERR((yylsp[0]), "Units are not allowed for operands of logical operations.");
2670             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2671         } else {
2672             (yyval.nExpression) = new Not((yyvsp[0].nExpression));
2673         }
2674     }
2675 #line 2676 "y.tab.c" /* yacc.c:1652  */
2676     break;
2677 
2678   case 65:
2679 #line 948 "parser.y" /* yacc.c:1652  */
2680     {
2681         if (!isNumber((yyvsp[0].nExpression)->exprType())) {
2682             PARSE_ERR((yylsp[0]), (String("Right operand of \"final\" operator '!' must be a scalar number expression, is ") + typeStr((yyvsp[0].nExpression)->exprType()) + " though.").c_str());
2683             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2684         } else {
2685             (yyval.nExpression) = new Final((yyvsp[0].nExpression));
2686         }
2687     }
2688 #line 2689 "y.tab.c" /* yacc.c:1652  */
2689     break;
2690 
2691   case 66:
2692 #line 958 "parser.y" /* yacc.c:1652  */
2693     {
2694         (yyval.nExpression) = NULL;
2695     }
2696 #line 2697 "y.tab.c" /* yacc.c:1652  */
2697     break;
2698 
2699   case 67:
2700 #line 961 "parser.y" /* yacc.c:1652  */
2701     {
2702         (yyval.nExpression) = (yyvsp[0].nExpression);
2703     }
2704 #line 2705 "y.tab.c" /* yacc.c:1652  */
2705     break;
2706 
2707   case 70:
2708 #line 970 "parser.y" /* yacc.c:1652  */
2709     {
2710         ExpressionRef lhs = (yyvsp[-2].nExpression);
2711         ExpressionRef rhs = (yyvsp[0].nExpression);
2712         if (lhs->isConstExpr() && rhs->isConstExpr()) {
2713             (yyval.nExpression) = new StringLiteral(
2714                 lhs->evalCastToStr() + rhs->evalCastToStr()
2715             );
2716         } else {
2717             (yyval.nExpression) = new ConcatString(lhs, rhs);
2718         }
2719     }
2720 #line 2721 "y.tab.c" /* yacc.c:1652  */
2721     break;
2722 
2723   case 72:
2724 #line 984 "parser.y" /* yacc.c:1652  */
2725     {
2726         ExpressionRef lhs = (yyvsp[-2].nExpression);
2727         ExpressionRef rhs = (yyvsp[0].nExpression);
2728         if (lhs->exprType() != INT_EXPR) {
2729             PARSE_ERR((yylsp[-2]), (String("Left operand of operator 'or' must be an integer expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
2730             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2731         } else if (rhs->exprType() != INT_EXPR) {
2732             PARSE_ERR((yylsp[0]), (String("Right operand of operator 'or' must be an integer expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
2733             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2734         } else if (lhs->asInt()->unitType() || lhs->asInt()->hasUnitFactorEver()) {
2735             PARSE_ERR((yylsp[-2]), "Units are not allowed for operands of logical operations.");
2736             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2737         } else if (rhs->asInt()->unitType() || rhs->asInt()->hasUnitFactorEver()) {
2738             PARSE_ERR((yylsp[0]), "Units are not allowed for operands of logical operations.");
2739             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2740         } else {
2741             if (lhs->asInt()->isFinal() && !rhs->asInt()->isFinal())
2742                 PARSE_WRN((yylsp[0]), "Right operand of 'or' operation is not 'final', result will be 'final' though since left operand is 'final'.");
2743             else if (!lhs->asInt()->isFinal() && rhs->asInt()->isFinal())
2744                 PARSE_WRN((yylsp[-2]), "Left operand of 'or' operation is not 'final', result will be 'final' though since right operand is 'final'.");
2745             (yyval.nExpression) = new Or(lhs, rhs);
2746         }
2747     }
2748 #line 2749 "y.tab.c" /* yacc.c:1652  */
2749     break;
2750 
2751   case 73:
2752 #line 1009 "parser.y" /* yacc.c:1652  */
2753     {
2754         (yyval.nExpression) = (yyvsp[0].nExpression);
2755     }
2756 #line 2757 "y.tab.c" /* yacc.c:1652  */
2757     break;
2758 
2759   case 74:
2760 #line 1012 "parser.y" /* yacc.c:1652  */
2761     {
2762         ExpressionRef lhs = (yyvsp[-2].nExpression);
2763         ExpressionRef rhs = (yyvsp[0].nExpression);
2764         if (lhs->exprType() != INT_EXPR) {
2765             PARSE_ERR((yylsp[-2]), (String("Left operand of operator 'and' must be an integer expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
2766             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2767         } else if (rhs->exprType() != INT_EXPR) {
2768             PARSE_ERR((yylsp[0]), (String("Right operand of operator 'and' must be an integer expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
2769             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2770         } else if (lhs->asInt()->unitType() || lhs->asInt()->hasUnitFactorEver()) {
2771             PARSE_ERR((yylsp[-2]), "Units are not allowed for operands of logical operations.");
2772             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2773         } else if (rhs->asInt()->unitType() || rhs->asInt()->hasUnitFactorEver()) {
2774             PARSE_ERR((yylsp[0]), "Units are not allowed for operands of logical operations.");
2775             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2776         } else {
2777             if (lhs->asInt()->isFinal() && !rhs->asInt()->isFinal())
2778                 PARSE_WRN((yylsp[0]), "Right operand of 'and' operation is not 'final', result will be 'final' though since left operand is 'final'.");
2779             else if (!lhs->asInt()->isFinal() && rhs->asInt()->isFinal())
2780                 PARSE_WRN((yylsp[-2]), "Left operand of 'and' operation is not 'final', result will be 'final' though since right operand is 'final'.");
2781             (yyval.nExpression) = new And(lhs, rhs);
2782         }
2783     }
2784 #line 2785 "y.tab.c" /* yacc.c:1652  */
2785     break;
2786 
2787   case 76:
2788 #line 1038 "parser.y" /* yacc.c:1652  */
2789     {
2790         ExpressionRef lhs = (yyvsp[-2].nExpression);
2791         ExpressionRef rhs = (yyvsp[0].nExpression);
2792         if (lhs->exprType() != INT_EXPR) {
2793             PARSE_ERR((yylsp[-2]), (String("Left operand of bitwise operator '.or.' must be an integer expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
2794             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2795         } else if (rhs->exprType() != INT_EXPR) {
2796             PARSE_ERR((yylsp[0]), (String("Right operand of bitwise operator '.or.' must be an integer expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
2797             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2798         } else if (lhs->asInt()->unitType() || lhs->asInt()->hasUnitFactorEver()) {
2799             PARSE_ERR((yylsp[-2]), "Units are not allowed for operands of bitwise operations.");
2800             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2801         } else if (rhs->asInt()->unitType() || rhs->asInt()->hasUnitFactorEver()) {
2802             PARSE_ERR((yylsp[0]), "Units are not allowed for operands of bitwise operations.");
2803             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2804         } else {
2805             if (lhs->asInt()->isFinal() && !rhs->asInt()->isFinal())
2806                 PARSE_WRN((yylsp[0]), "Right operand of '.or.' operation is not 'final', result will be 'final' though since left operand is 'final'.");
2807             else if (!lhs->asInt()->isFinal() && rhs->asInt()->isFinal())
2808                 PARSE_WRN((yylsp[-2]), "Left operand of '.or.' operation is not 'final', result will be 'final' though since right operand is 'final'.");
2809             (yyval.nExpression) = new BitwiseOr(lhs, rhs);
2810         }
2811     }
2812 #line 2813 "y.tab.c" /* yacc.c:1652  */
2813     break;
2814 
2815   case 77:
2816 #line 1063 "parser.y" /* yacc.c:1652  */
2817     {
2818         (yyval.nExpression) = (yyvsp[0].nExpression);
2819     }
2820 #line 2821 "y.tab.c" /* yacc.c:1652  */
2821     break;
2822 
2823   case 78:
2824 #line 1066 "parser.y" /* yacc.c:1652  */
2825     {
2826         ExpressionRef lhs = (yyvsp[-2].nExpression);
2827         ExpressionRef rhs = (yyvsp[0].nExpression);
2828         if (lhs->exprType() != INT_EXPR) {
2829             PARSE_ERR((yylsp[-2]), (String("Left operand of bitwise operator '.and.' must be an integer expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
2830             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2831         } else if (rhs->exprType() != INT_EXPR) {
2832             PARSE_ERR((yylsp[0]), (String("Right operand of bitwise operator '.and.' must be an integer expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
2833             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2834         } else if (lhs->asInt()->unitType() || lhs->asInt()->hasUnitFactorEver()) {
2835             PARSE_ERR((yylsp[-2]), "Units are not allowed for operands of bitwise operations.");
2836             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2837         } else if (rhs->asInt()->unitType() || rhs->asInt()->hasUnitFactorEver()) {
2838             PARSE_ERR((yylsp[0]), "Units are not allowed for operands of bitwise operations.");
2839             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2840         } else {
2841             if (lhs->asInt()->isFinal() && !rhs->asInt()->isFinal())
2842                 PARSE_WRN((yylsp[0]), "Right operand of '.and.' operation is not 'final', result will be 'final' though since left operand is 'final'.");
2843             else if (!lhs->asInt()->isFinal() && rhs->asInt()->isFinal())
2844                 PARSE_WRN((yylsp[-2]), "Left operand of '.and.' operation is not 'final', result will be 'final' though since right operand is 'final'.");
2845             (yyval.nExpression) = new BitwiseAnd(lhs, rhs);
2846         }
2847     }
2848 #line 2849 "y.tab.c" /* yacc.c:1652  */
2849     break;
2850 
2851   case 80:
2852 #line 1092 "parser.y" /* yacc.c:1652  */
2853     {
2854         ExpressionRef lhs = (yyvsp[-2].nExpression);
2855         ExpressionRef rhs = (yyvsp[0].nExpression);
2856         if (!isNumber(lhs->exprType())) {
2857             PARSE_ERR((yylsp[-2]), (String("Left operand of operator '<' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
2858             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2859         } else if (!isNumber(rhs->exprType())) {
2860             PARSE_ERR((yylsp[0]), (String("Right operand of operator '<' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
2861             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2862         } else if (lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) {
2863             PARSE_ERR((yylsp[-1]), (String("Operands of relative operations must have same unit, left operand is ") +
2864                 unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " +
2865                 unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str());
2866             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2867         } else {
2868             if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal())
2869                 PARSE_WRN((yylsp[0]), "Right operand of '<' comparison is not 'final', left operand is 'final' though.");
2870             else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal())
2871                 PARSE_WRN((yylsp[-2]), "Left operand of '<' comparison is not 'final', right operand is 'final' though.");
2872             (yyval.nExpression) = new Relation(lhs, Relation::LESS_THAN, rhs);
2873         }
2874     }
2875 #line 2876 "y.tab.c" /* yacc.c:1652  */
2876     break;
2877 
2878   case 81:
2879 #line 1114 "parser.y" /* yacc.c:1652  */
2880     {
2881         ExpressionRef lhs = (yyvsp[-2].nExpression);
2882         ExpressionRef rhs = (yyvsp[0].nExpression);
2883         if (!isNumber(lhs->exprType())) {
2884             PARSE_ERR((yylsp[-2]), (String("Left operand of operator '>' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
2885             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2886         } else if (!isNumber(rhs->exprType())) {
2887             PARSE_ERR((yylsp[0]), (String("Right operand of operator '>' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
2888             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2889         } else if (lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) {
2890             PARSE_ERR((yylsp[-1]), (String("Operands of relative operations must have same unit, left operand is ") +
2891                 unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " +
2892                 unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str());
2893             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2894         } else {
2895             if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal())
2896                 PARSE_WRN((yylsp[0]), "Right operand of '>' comparison is not 'final', left operand is 'final' though.");
2897             else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal())
2898                 PARSE_WRN((yylsp[-2]), "Left operand of '>' comparison is not 'final', right operand is 'final' though.");
2899             (yyval.nExpression) = new Relation(lhs, Relation::GREATER_THAN, rhs);
2900         }
2901     }
2902 #line 2903 "y.tab.c" /* yacc.c:1652  */
2903     break;
2904 
2905   case 82:
2906 #line 1136 "parser.y" /* yacc.c:1652  */
2907     {
2908         ExpressionRef lhs = (yyvsp[-2].nExpression);
2909         ExpressionRef rhs = (yyvsp[0].nExpression);
2910         if (!isNumber(lhs->exprType())) {
2911             PARSE_ERR((yylsp[-2]), (String("Left operand of operator '<=' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
2912             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2913         } else if (!isNumber(rhs->exprType())) {
2914             PARSE_ERR((yylsp[0]), (String("Right operand of operator '<=' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
2915             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2916         } else if (lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) {
2917             PARSE_ERR((yylsp[-1]), (String("Operands of relative operations must have same unit, left operand is ") +
2918                 unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " +
2919                 unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str());
2920             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2921         } else {
2922             if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal())
2923                 PARSE_WRN((yylsp[0]), "Right operand of '<=' comparison is not 'final', left operand is 'final' though.");
2924             else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal())
2925                 PARSE_WRN((yylsp[-2]), "Left operand of '<=' comparison is not 'final', right operand is 'final' though.");
2926             (yyval.nExpression) = new Relation(lhs, Relation::LESS_OR_EQUAL, rhs);
2927         }
2928     }
2929 #line 2930 "y.tab.c" /* yacc.c:1652  */
2930     break;
2931 
2932   case 83:
2933 #line 1158 "parser.y" /* yacc.c:1652  */
2934     {
2935         ExpressionRef lhs = (yyvsp[-2].nExpression);
2936         ExpressionRef rhs = (yyvsp[0].nExpression);
2937         if (!isNumber(lhs->exprType())) {
2938             PARSE_ERR((yylsp[-2]), (String("Left operand of operator '>=' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
2939             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2940         } else if (!isNumber(rhs->exprType())) {
2941             PARSE_ERR((yylsp[0]), (String("Right operand of operator '>=' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
2942             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2943         } else if (lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) {
2944             PARSE_ERR((yylsp[-1]), (String("Operands of relative operations must have same unit, left operand is ") +
2945                 unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " +
2946                 unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str());
2947             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2948         } else {
2949             if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal())
2950                 PARSE_WRN((yylsp[0]), "Right operand of '>=' comparison is not 'final', left operand is 'final' though.");
2951             else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal())
2952                 PARSE_WRN((yylsp[-2]), "Left operand of '>=' comparison is not 'final', right operand is 'final' though.");
2953             (yyval.nExpression) = new Relation(lhs, Relation::GREATER_OR_EQUAL, rhs);
2954         }
2955     }
2956 #line 2957 "y.tab.c" /* yacc.c:1652  */
2957     break;
2958 
2959   case 84:
2960 #line 1180 "parser.y" /* yacc.c:1652  */
2961     {
2962         ExpressionRef lhs = (yyvsp[-2].nExpression);
2963         ExpressionRef rhs = (yyvsp[0].nExpression);
2964         if (!isNumber(lhs->exprType())) {
2965             PARSE_ERR((yylsp[-2]), (String("Left operand of operator '=' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
2966             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2967         } else if (!isNumber(rhs->exprType())) {
2968             PARSE_ERR((yylsp[0]), (String("Right operand of operator '=' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
2969             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2970         } else if (lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) {
2971             PARSE_ERR((yylsp[-1]), (String("Operands of relative operations must have same unit, left operand is ") +
2972                 unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " +
2973                 unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str());
2974             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2975         } else {
2976             if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal())
2977                 PARSE_WRN((yylsp[0]), "Right operand of '=' comparison is not 'final', left operand is 'final' though.");
2978             else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal())
2979                 PARSE_WRN((yylsp[-2]), "Left operand of '=' comparison is not 'final', right operand is 'final' though.");
2980             (yyval.nExpression) = new Relation(lhs, Relation::EQUAL, rhs);
2981         }
2982     }
2983 #line 2984 "y.tab.c" /* yacc.c:1652  */
2984     break;
2985 
2986   case 85:
2987 #line 1202 "parser.y" /* yacc.c:1652  */
2988     {
2989         ExpressionRef lhs = (yyvsp[-2].nExpression);
2990         ExpressionRef rhs = (yyvsp[0].nExpression);
2991         if (!isNumber(lhs->exprType())) {
2992             PARSE_ERR((yylsp[-2]), (String("Left operand of operator '#' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
2993             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2994         } else if (!isNumber(rhs->exprType())) {
2995             PARSE_ERR((yylsp[0]), (String("Right operand of operator '#' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
2996             (yyval.nExpression) = new IntLiteral({ .value = 0 });
2997         } else if (lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) {
2998             PARSE_ERR((yylsp[-1]), (String("Operands of relative operations must have same unit, left operand is ") +
2999                 unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " +
3000                 unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str());
3001             (yyval.nExpression) = new IntLiteral({ .value = 0 });
3002         } else {
3003             if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal())
3004                 PARSE_WRN((yylsp[0]), "Right operand of '#' comparison is not 'final', left operand is 'final' though.");
3005             else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal())
3006                 PARSE_WRN((yylsp[-2]), "Left operand of '#' comparison is not 'final', right operand is 'final' though.");
3007             (yyval.nExpression) = new Relation(lhs, Relation::NOT_EQUAL, rhs);
3008         }
3009     }
3010 #line 3011 "y.tab.c" /* yacc.c:1652  */
3011     break;
3012 
3013   case 87:
3014 #line 1227 "parser.y" /* yacc.c:1652  */
3015     {
3016         ExpressionRef lhs = (yyvsp[-2].nExpression);
3017         ExpressionRef rhs = (yyvsp[0].nExpression);
3018         if (!isNumber(lhs->exprType())) {
3019             PARSE_ERR((yylsp[-2]), (String("Left operand of operator '+' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
3020             (yyval.nExpression) = new IntLiteral({ .value = 0 });
3021         } else if (!isNumber(rhs->exprType())) {
3022             PARSE_ERR((yylsp[-2]), (String("Right operand of operator '+' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
3023             (yyval.nExpression) = new IntLiteral({ .value = 0 });
3024         } else if (lhs->exprType() != rhs->exprType()) {
3025             PARSE_ERR((yylsp[-1]), (String("Operands of operator '+' must have same type; left operand is ") +
3026                       typeStr(lhs->exprType()) + " and right operand is " + typeStr(rhs->exprType()) + " though.").c_str());
3027             (yyval.nExpression) = new IntLiteral({ .value = 0 });
3028         } else if (lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) {
3029             PARSE_ERR((yylsp[-1]), (String("Operands of '+' operations must have same unit, left operand is ") +
3030                 unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " +
3031                 unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str());
3032             (yyval.nExpression) = new IntLiteral({ .value = 0 });
3033         } else {
3034             if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal())
3035                 PARSE_WRN((yylsp[0]), "Right operand of '+' operation is not 'final', result will be 'final' though since left operand is 'final'.");
3036             else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal())
3037                 PARSE_WRN((yylsp[-2]), "Left operand of '+' operation is not 'final', result will be 'final' though since right operand is 'final'.");
3038             (yyval.nExpression) = new Add(lhs,rhs);
3039         }
3040     }
3041 #line 3042 "y.tab.c" /* yacc.c:1652  */
3042     break;
3043 
3044   case 88:
3045 #line 1253 "parser.y" /* yacc.c:1652  */
3046     {
3047         ExpressionRef lhs = (yyvsp[-2].nExpression);
3048         ExpressionRef rhs = (yyvsp[0].nExpression);
3049         if (!isNumber(lhs->exprType())) {
3050             PARSE_ERR((yylsp[-2]), (String("Left operand of operator '-' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
3051             (yyval.nExpression) = new IntLiteral({ .value = 0 });
3052         } else if (!isNumber(rhs->exprType())) {
3053             PARSE_ERR((yylsp[-2]), (String("Right operand of operator '-' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
3054             (yyval.nExpression) = new IntLiteral({ .value = 0 });
3055         } else if (lhs->exprType() != rhs->exprType()) {
3056             PARSE_ERR((yylsp[-1]), (String("Operands of operator '-' must have same type; left operand is ") +
3057                       typeStr(lhs->exprType()) + " and right operand is " + typeStr(rhs->exprType()) + " though.").c_str());
3058             (yyval.nExpression) = new IntLiteral({ .value = 0 });
3059         } else if (lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) {
3060             PARSE_ERR((yylsp[-1]), (String("Operands of '-' operations must have same unit, left operand is ") +
3061                 unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " +
3062                 unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str());
3063             (yyval.nExpression) = new IntLiteral({ .value = 0 });
3064         } else {
3065             if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal())
3066                 PARSE_WRN((yylsp[0]), "Right operand of '-' operation is not 'final', result will be 'final' though since left operand is 'final'.");
3067             else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal())
3068                 PARSE_WRN((yylsp[-2]), "Left operand of '-' operation is not 'final', result will be 'final' though since right operand is 'final'.");
3069             (yyval.nExpression) = new Sub(lhs,rhs);
3070         }
3071     }
3072 #line 3073 "y.tab.c" /* yacc.c:1652  */
3073     break;
3074 
3075   case 90:
3076 #line 1282 "parser.y" /* yacc.c:1652  */
3077     {
3078         ExpressionRef lhs = (yyvsp[-2].nExpression);
3079         ExpressionRef rhs = (yyvsp[0].nExpression);
3080         if (!isNumber(lhs->exprType())) {
3081             PARSE_ERR((yylsp[-2]), (String("Left operand of operator '*' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
3082             (yyval.nExpression) = new IntLiteral({ .value = 0 });
3083         } else if (!isNumber(rhs->exprType())) {
3084             PARSE_ERR((yylsp[-2]), (String("Right operand of operator '*' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
3085             (yyval.nExpression) = new IntLiteral({ .value = 0 });
3086         } else if (lhs->asNumber()->unitType() && rhs->asNumber()->unitType()) {
3087             PARSE_ERR((yylsp[-1]), (String("Only one operand of operator '*' may have a unit type, left operand is ") +
3088                 unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " +
3089                 unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str());
3090             (yyval.nExpression) = new IntLiteral({ .value = 0 });
3091         } else if (lhs->exprType() != rhs->exprType()) {
3092             PARSE_ERR((yylsp[-1]), (String("Operands of operator '*' must have same type; left operand is ") +
3093                       typeStr(lhs->exprType()) + " and right operand is " + typeStr(rhs->exprType()) + " though.").c_str());
3094             (yyval.nExpression) = new IntLiteral({ .value = 0 });
3095         } else {
3096             if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal())
3097                 PARSE_WRN((yylsp[0]), "Right operand of '*' operation is not 'final', result will be 'final' though since left operand is 'final'.");
3098             else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal())
3099                 PARSE_WRN((yylsp[-2]), "Left operand of '*' operation is not 'final', result will be 'final' though since right operand is 'final'.");
3100             (yyval.nExpression) = new Mul(lhs,rhs);
3101         }
3102     }
3103 #line 3104 "y.tab.c" /* yacc.c:1652  */
3104     break;
3105 
3106   case 91:
3107 #line 1308 "parser.y" /* yacc.c:1652  */
3108     {
3109         ExpressionRef lhs = (yyvsp[-2].nExpression);
3110         ExpressionRef rhs = (yyvsp[0].nExpression);
3111         if (!isNumber(lhs->exprType())) {
3112             PARSE_ERR((yylsp[-2]), (String("Left operand of operator '/' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
3113             (yyval.nExpression) = new IntLiteral({ .value = 0 });
3114         } else if (!isNumber(rhs->exprType())) {
3115             PARSE_ERR((yylsp[-2]), (String("Right operand of operator '/' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
3116             (yyval.nExpression) = new IntLiteral({ .value = 0 });
3117         } else if (lhs->asNumber()->unitType() && rhs->asNumber()->unitType() &&
3118                    lhs->asNumber()->unitType() != rhs->asNumber()->unitType())
3119         {
3120             PARSE_ERR((yylsp[-1]), (String("Operands of operator '/' with two different unit types, left operand is ") +
3121                 unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " +
3122                 unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str());
3123             (yyval.nExpression) = new IntLiteral({ .value = 0 });
3124         } else if (!lhs->asNumber()->unitType() && rhs->asNumber()->unitType()) {
3125             PARSE_ERR((yylsp[0]), ("Dividing left operand without any unit type by right operand with unit type (" +
3126                 unitTypeStr(rhs->asNumber()->unitType()) + ") is not possible.").c_str());
3127             (yyval.nExpression) = new IntLiteral({ .value = 0 });
3128         } else if (lhs->exprType() != rhs->exprType()) {
3129             PARSE_ERR((yylsp[-1]), (String("Operands of operator '/' must have same type; left operand is ") +
3130                       typeStr(lhs->exprType()) + " and right operand is " + typeStr(rhs->exprType()) + " though.").c_str());
3131             (yyval.nExpression) = new IntLiteral({ .value = 0 });
3132         } else {
3133             if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal())
3134                 PARSE_WRN((yylsp[0]), "Right operand of '/' operation is not 'final', result will be 'final' though since left operand is 'final'.");
3135             else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal())
3136                 PARSE_WRN((yylsp[-2]), "Left operand of '/' operation is not 'final', result will be 'final' though since right operand is 'final'.");
3137             (yyval.nExpression) = new Div(lhs,rhs);
3138         }
3139     }
3140 #line 3141 "y.tab.c" /* yacc.c:1652  */
3141     break;
3142 
3143   case 92:
3144 #line 1340 "parser.y" /* yacc.c:1652  */
3145     {
3146         ExpressionRef lhs = (yyvsp[-2].nExpression);
3147         ExpressionRef rhs = (yyvsp[0].nExpression);
3148         if (lhs->exprType() != INT_EXPR) {
3149             PARSE_ERR((yylsp[-2]), (String("Left operand of modulo operator must be an integer expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
3150             (yyval.nExpression) = new IntLiteral({ .value = 0 });
3151         } else if (rhs->exprType() != INT_EXPR) {
3152             PARSE_ERR((yylsp[0]), (String("Right operand of modulo operator must be an integer expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
3153             (yyval.nExpression) = new IntLiteral({ .value = 0 });
3154         } else {
3155             if (lhs->asInt()->unitType() || lhs->asInt()->hasUnitFactorEver())
3156                 PARSE_ERR((yylsp[-2]), "Operands of modulo operator must not use any unit.");
3157             if (rhs->asInt()->unitType() || rhs->asInt()->hasUnitFactorEver())
3158                 PARSE_ERR((yylsp[0]), "Operands of modulo operator must not use any unit.");
3159             if (lhs->asInt()->isFinal() && !rhs->asInt()->isFinal())
3160                 PARSE_WRN((yylsp[0]), "Right operand of 'mod' operation is not 'final', result will be 'final' though since left operand is 'final'.");
3161             else if (!lhs->asInt()->isFinal() && rhs->asInt()->isFinal())
3162                 PARSE_WRN((yylsp[-2]), "Left operand of 'mod' operation is not 'final', result will be 'final' though since right operand is 'final'.");
3163             (yyval.nExpression) = new Mod(lhs,rhs);
3164         }
3165     }
3166 #line 3167 "y.tab.c" /* yacc.c:1652  */
3167     break;
3168 
3169 
3170 #line 3171 "y.tab.c" /* yacc.c:1652  */
3171       default: break;
3172     }
3173   /* User semantic actions sometimes alter yychar, and that requires
3174      that yytoken be updated with the new translation.  We take the
3175      approach of translating immediately before every use of yytoken.
3176      One alternative is translating here after every semantic action,
3177      but that translation would be missed if the semantic action invokes
3178      YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
3179      if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
3180      incorrect destructor might then be invoked immediately.  In the
3181      case of YYERROR or YYBACKUP, subsequent parser actions might lead
3182      to an incorrect destructor call or verbose syntax error message
3183      before the lookahead is translated.  */
3184   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
3185 
3186   YYPOPSTACK (yylen);
3187   yylen = 0;
3188   YY_STACK_PRINT (yyss, yyssp);
3189 
3190   *++yyvsp = yyval;
3191   *++yylsp = yyloc;
3192 
3193   /* Now 'shift' the result of the reduction.  Determine what state
3194      that goes to, based on the state we popped back to and the rule
3195      number reduced by.  */
3196   {
3197     const int yylhs = yyr1[yyn] - YYNTOKENS;
3198     const int yyi = yypgoto[yylhs] + *yyssp;
3199     yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
3200                ? yytable[yyi]
3201                : yydefgoto[yylhs]);
3202   }
3203 
3204   goto yynewstate;
3205 
3206 
3207 /*--------------------------------------.
3208 | yyerrlab -- here on detecting error.  |
3209 `--------------------------------------*/
3210 yyerrlab:
3211   /* Make sure we have latest lookahead translation.  See comments at
3212      user semantic actions for why this is necessary.  */
3213   yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
3214 
3215   /* If not already recovering from an error, report this error.  */
3216   if (!yyerrstatus)
3217     {
3218       ++yynerrs;
3219 #if ! YYERROR_VERBOSE
3220       yyerror (&yylloc, context, YY_("syntax error"));
3221 #else
3222 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
3223                                         yyssp, yytoken)
3224       {
3225         char const *yymsgp = YY_("syntax error");
3226         int yysyntax_error_status;
3227         yysyntax_error_status = YYSYNTAX_ERROR;
3228         if (yysyntax_error_status == 0)
3229           yymsgp = yymsg;
3230         else if (yysyntax_error_status == 1)
3231           {
3232             if (yymsg != yymsgbuf)
3233               YYSTACK_FREE (yymsg);
3234             yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
3235             if (!yymsg)
3236               {
3237                 yymsg = yymsgbuf;
3238                 yymsg_alloc = sizeof yymsgbuf;
3239                 yysyntax_error_status = 2;
3240               }
3241             else
3242               {
3243                 yysyntax_error_status = YYSYNTAX_ERROR;
3244                 yymsgp = yymsg;
3245               }
3246           }
3247         yyerror (&yylloc, context, yymsgp);
3248         if (yysyntax_error_status == 2)
3249           goto yyexhaustedlab;
3250       }
3251 # undef YYSYNTAX_ERROR
3252 #endif
3253     }
3254 
3255   yyerror_range[1] = yylloc;
3256 
3257   if (yyerrstatus == 3)
3258     {
3259       /* If just tried and failed to reuse lookahead token after an
3260          error, discard it.  */
3261 
3262       if (yychar <= YYEOF)
3263         {
3264           /* Return failure if at end of input.  */
3265           if (yychar == YYEOF)
3266             YYABORT;
3267         }
3268       else
3269         {
3270           yydestruct ("Error: discarding",
3271                       yytoken, &yylval, &yylloc, context);
3272           yychar = YYEMPTY;
3273         }
3274     }
3275 
3276   /* Else will try to reuse lookahead token after shifting the error
3277      token.  */
3278   goto yyerrlab1;
3279 
3280 
3281 /*---------------------------------------------------.
3282 | yyerrorlab -- error raised explicitly by YYERROR.  |
3283 `---------------------------------------------------*/
3284 yyerrorlab:
3285   /* Pacify compilers when the user code never invokes YYERROR and the
3286      label yyerrorlab therefore never appears in user code.  */
3287   if (0)
3288     YYERROR;
3289 
3290   /* Do not reclaim the symbols of the rule whose action triggered
3291      this YYERROR.  */
3292   YYPOPSTACK (yylen);
3293   yylen = 0;
3294   YY_STACK_PRINT (yyss, yyssp);
3295   yystate = *yyssp;
3296   goto yyerrlab1;
3297 
3298 
3299 /*-------------------------------------------------------------.
3300 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
3301 `-------------------------------------------------------------*/
3302 yyerrlab1:
3303   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
3304 
3305   for (;;)
3306     {
3307       yyn = yypact[yystate];
3308       if (!yypact_value_is_default (yyn))
3309         {
3310           yyn += YYTERROR;
3311           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
3312             {
3313               yyn = yytable[yyn];
3314               if (0 < yyn)
3315                 break;
3316             }
3317         }
3318 
3319       /* Pop the current state because it cannot handle the error token.  */
3320       if (yyssp == yyss)
3321         YYABORT;
3322 
3323       yyerror_range[1] = *yylsp;
3324       yydestruct ("Error: popping",
3325                   yystos[yystate], yyvsp, yylsp, context);
3326       YYPOPSTACK (1);
3327       yystate = *yyssp;
3328       YY_STACK_PRINT (yyss, yyssp);
3329     }
3330 
3331   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
3332   *++yyvsp = yylval;
3333   YY_IGNORE_MAYBE_UNINITIALIZED_END
3334 
3335   yyerror_range[2] = yylloc;
3336   /* Using YYLLOC is tempting, but would change the location of
3337      the lookahead.  YYLOC is available though.  */
3338   YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
3339   *++yylsp = yyloc;
3340 
3341   /* Shift the error token.  */
3342   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
3343 
3344   yystate = yyn;
3345   goto yynewstate;
3346 
3347 
3348 /*-------------------------------------.
3349 | yyacceptlab -- YYACCEPT comes here.  |
3350 `-------------------------------------*/
3351 yyacceptlab:
3352   yyresult = 0;
3353   goto yyreturn;
3354 
3355 
3356 /*-----------------------------------.
3357 | yyabortlab -- YYABORT comes here.  |
3358 `-----------------------------------*/
3359 yyabortlab:
3360   yyresult = 1;
3361   goto yyreturn;
3362 
3363 
3364 #if !defined yyoverflow || YYERROR_VERBOSE
3365 /*-------------------------------------------------.
3366 | yyexhaustedlab -- memory exhaustion comes here.  |
3367 `-------------------------------------------------*/
3368 yyexhaustedlab:
3369   yyerror (&yylloc, context, YY_("memory exhausted"));
3370   yyresult = 2;
3371   /* Fall through.  */
3372 #endif
3373 
3374 
3375 /*-----------------------------------------------------.
3376 | yyreturn -- parsing is finished, return the result.  |
3377 `-----------------------------------------------------*/
3378 yyreturn:
3379   if (yychar != YYEMPTY)
3380     {
3381       /* Make sure we have latest lookahead translation.  See comments at
3382          user semantic actions for why this is necessary.  */
3383       yytoken = YYTRANSLATE (yychar);
3384       yydestruct ("Cleanup: discarding lookahead",
3385                   yytoken, &yylval, &yylloc, context);
3386     }
3387   /* Do not reclaim the symbols of the rule whose action triggered
3388      this YYABORT or YYACCEPT.  */
3389   YYPOPSTACK (yylen);
3390   YY_STACK_PRINT (yyss, yyssp);
3391   while (yyssp != yyss)
3392     {
3393       yydestruct ("Cleanup: popping",
3394                   yystos[*yyssp], yyvsp, yylsp, context);
3395       YYPOPSTACK (1);
3396     }
3397 #ifndef yyoverflow
3398   if (yyss != yyssa)
3399     YYSTACK_FREE (yyss);
3400 #endif
3401 #if YYERROR_VERBOSE
3402   if (yymsg != yymsgbuf)
3403     YYSTACK_FREE (yymsg);
3404 #endif
3405   return yyresult;
3406 }
3407 #line 1362 "parser.y" /* yacc.c:1918  */
3408 
3409 
InstrScript_error(YYLTYPE * locp,LinuxSampler::ParserContext * context,const char * err)3410 void InstrScript_error(YYLTYPE* locp, LinuxSampler::ParserContext* context, const char* err) {
3411     //fprintf(stderr, "%d: %s\n", locp->first_line, err);
3412     context->addErr(locp->first_line, locp->last_line, locp->first_column+1,
3413                     locp->last_column+1, locp->first_byte, locp->length_bytes,
3414                     err);
3415 }
3416 
InstrScript_warning(YYLTYPE * locp,LinuxSampler::ParserContext * context,const char * txt)3417 void InstrScript_warning(YYLTYPE* locp, LinuxSampler::ParserContext* context, const char* txt) {
3418     //fprintf(stderr, "WRN %d: %s\n", locp->first_line, txt);
3419     context->addWrn(locp->first_line, locp->last_line, locp->first_column+1,
3420                     locp->last_column+1, locp->first_byte, locp->length_bytes,
3421                     txt);
3422 }
3423 
3424 /// Custom implementation of yytnamerr() to ensure quotation is always stripped from token names before printing them to error messages.
InstrScript_tnamerr(char * yyres,const char * yystr)3425 int InstrScript_tnamerr(char* yyres, const char* yystr) {
3426   if (*yystr == '"') {
3427       int yyn = 0;
3428       char const *yyp = yystr;
3429       for (;;)
3430         switch (*++yyp)
3431           {
3432 /*
3433           case '\'':
3434           case ',':
3435             goto do_not_strip_quotes;
3436 
3437           case '\\':
3438             if (*++yyp != '\\')
3439               goto do_not_strip_quotes;
3440 */
3441             /* Fall through.  */
3442           default:
3443             if (yyres)
3444               yyres[yyn] = *yyp;
3445             yyn++;
3446             break;
3447 
3448           case '"':
3449             if (yyres)
3450               yyres[yyn] = '\0';
3451             return yyn;
3452           }
3453 /*
3454     do_not_strip_quotes: ;
3455 */
3456     }
3457 
3458   if (! yyres)
3459     return (int) yystrlen (yystr);
3460 
3461   return int( yystpcpy (yyres, yystr) - yyres );
3462 }
3463