/* A Bison parser, made by GNU Bison 3.3.2.  */

/* Bison implementation for Yacc-like parsers in C

   Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
   Inc.

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

/* As a special exception, you may create a larger work that contains
   part or all of the Bison parser skeleton and distribute that work
   under terms of your choice, so long as that work isn't itself a
   parser generator using the skeleton or a modified version thereof
   as a parser skeleton.  Alternatively, if you modify or redistribute
   the parser skeleton itself, you may (at your option) remove this
   special exception, which will cause the skeleton and the resulting
   Bison output files to be licensed under the GNU General Public
   License without this special exception.

   This special exception was added by the Free Software Foundation in
   version 2.2 of Bison.  */

/* C LALR(1) parser skeleton written by Richard Stallman, by
   simplifying the original so-called "semantic" parser.  */

/* All symbols defined below should begin with yy or YY, to avoid
   infringing on user name space.  This should be done even for local
   variables, as they might otherwise be expanded by user macros.
   There are some unavoidable exceptions within include files to
   define necessary library symbols; they are noted "INFRINGES ON
   USER NAME SPACE" below.  */

/* Undocumented macros, especially those whose name start with YY_,
   are private implementation details.  Do not rely on them.  */

/* Identify Bison output.  */
#define YYBISON 1

/* Bison version.  */
#define YYBISON_VERSION "3.3.2"

/* Skeleton name.  */
#define YYSKELETON_NAME "yacc.c"

/* Pure parsers.  */
#define YYPURE 1

/* Push parsers.  */
#define YYPUSH 0

/* Pull parsers.  */
#define YYPULL 1


/* Substitute the variable and function names.  */
#define yyparse         InstrScript_parse
#define yylex           InstrScript_lex
#define yyerror         InstrScript_error
#define yydebug         InstrScript_debug
#define yynerrs         InstrScript_nerrs


/* First part of user prologue.  */
#line 12 "parser.y" /* yacc.c:337  */

    #define YYERROR_VERBOSE 1
    #include "parser_shared.h"
    #include <string>
    #include <map>
    using namespace LinuxSampler;

    void InstrScript_error(YYLTYPE* locp, LinuxSampler::ParserContext* context, const char* err);
    void InstrScript_warning(YYLTYPE* locp, LinuxSampler::ParserContext* context, const char* txt);
    int InstrScript_tnamerr(char* yyres, const char* yystr);
    int InstrScript_lex(YYSTYPE* lvalp, YYLTYPE* llocp, void* scanner);
    #define scanner context->scanner
    #define PARSE_ERR(loc,txt)  yyerror(&loc, context, txt)
    #define PARSE_WRN(loc,txt)  InstrScript_warning(&loc, context, txt)
    #define PARSE_DROP(loc) \
        context->addPreprocessorComment( \
            loc.first_line, loc.last_line, loc.first_column+1, \
            loc.last_column+1, loc.first_byte, loc.length_bytes \
        );
    #define CODE_BLOCK(loc) { \
        .firstLine = loc.first_line, .lastLine = loc.last_line, \
        .firstColumn = loc.first_column+1, .lastColumn = loc.last_column+1, \
        .firstByte = loc.first_byte, .lengthBytes = loc.length_bytes \
    }
    #define ASSIGNED_EXPR_BLOCK(loc) { \
        .firstLine = loc.first_line, .lastLine = loc.last_line, \
        .firstColumn = loc.first_column+3, .lastColumn = loc.last_column+1, \
        .firstByte = loc.first_byte+2, .lengthBytes = loc.length_bytes-2 \
    }
    #define yytnamerr(res,str)  InstrScript_tnamerr(res, str)

#line 108 "y.tab.c" /* yacc.c:337  */
# ifndef YY_NULLPTR
#  if defined __cplusplus
#   if 201103L <= __cplusplus
#    define YY_NULLPTR nullptr
#   else
#    define YY_NULLPTR 0
#   endif
#  else
#   define YY_NULLPTR ((void*)0)
#  endif
# endif

/* Enabling verbose error messages.  */
#ifdef YYERROR_VERBOSE
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
# define YYERROR_VERBOSE 1
#endif

/* In a future release of Bison, this section will be replaced
   by #include "y.tab.h".  */
#ifndef YY_INSTRSCRIPT_Y_TAB_H_INCLUDED
# define YY_INSTRSCRIPT_Y_TAB_H_INCLUDED
/* Debug traces.  */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int InstrScript_debug;
#endif

/* Token type.  */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
  enum yytokentype
  {
    END_OF_FILE = 0,
    INTEGER = 258,
    REAL = 259,
    INTEGER_UNIT = 260,
    REAL_UNIT = 261,
    STRING = 262,
    IDENTIFIER = 263,
    VARIABLE = 264,
    ON = 265,
    END = 266,
    INIT = 267,
    NOTE = 268,
    RELEASE = 269,
    CONTROLLER = 270,
    RPN = 271,
    NRPN = 272,
    DECLARE = 273,
    ASSIGNMENT = 274,
    CONST_ = 275,
    POLYPHONIC = 276,
    PATCH = 277,
    WHILE = 278,
    SYNCHRONIZED = 279,
    IF = 280,
    ELSE = 281,
    SELECT = 282,
    CASE = 283,
    TO = 284,
    OR = 285,
    AND = 286,
    NOT = 287,
    BITWISE_OR = 288,
    BITWISE_AND = 289,
    BITWISE_NOT = 290,
    FUNCTION = 291,
    CALL = 292,
    MOD = 293,
    LE = 294,
    GE = 295,
    UNKNOWN_CHAR = 296
  };
#endif
/* Tokens.  */
#define END_OF_FILE 0
#define INTEGER 258
#define REAL 259
#define INTEGER_UNIT 260
#define REAL_UNIT 261
#define STRING 262
#define IDENTIFIER 263
#define VARIABLE 264
#define ON 265
#define END 266
#define INIT 267
#define NOTE 268
#define RELEASE 269
#define CONTROLLER 270
#define RPN 271
#define NRPN 272
#define DECLARE 273
#define ASSIGNMENT 274
#define CONST_ 275
#define POLYPHONIC 276
#define PATCH 277
#define WHILE 278
#define SYNCHRONIZED 279
#define IF 280
#define ELSE 281
#define SELECT 282
#define CASE 283
#define TO 284
#define OR 285
#define AND 286
#define NOT 287
#define BITWISE_OR 288
#define BITWISE_AND 289
#define BITWISE_NOT 290
#define FUNCTION 291
#define CALL 292
#define MOD 293
#define LE 294
#define GE 295
#define UNKNOWN_CHAR 296

/* Value type.  */

/* Location type.  */
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
typedef struct YYLTYPE YYLTYPE;
struct YYLTYPE
{
  int first_line;
  int first_column;
  int last_line;
  int last_column;
};
# define YYLTYPE_IS_DECLARED 1
# define YYLTYPE_IS_TRIVIAL 1
#endif



int InstrScript_parse (LinuxSampler::ParserContext* context);

#endif /* !YY_INSTRSCRIPT_Y_TAB_H_INCLUDED  */



#ifdef short
# undef short
#endif

#ifdef YYTYPE_UINT8
typedef YYTYPE_UINT8 yytype_uint8;
#else
typedef unsigned char yytype_uint8;
#endif

#ifdef YYTYPE_INT8
typedef YYTYPE_INT8 yytype_int8;
#else
typedef signed char yytype_int8;
#endif

#ifdef YYTYPE_UINT16
typedef YYTYPE_UINT16 yytype_uint16;
#else
typedef unsigned short yytype_uint16;
#endif

#ifdef YYTYPE_INT16
typedef YYTYPE_INT16 yytype_int16;
#else
typedef short yytype_int16;
#endif

#ifndef YYSIZE_T
# ifdef __SIZE_TYPE__
#  define YYSIZE_T __SIZE_TYPE__
# elif defined size_t
#  define YYSIZE_T size_t
# elif ! defined YYSIZE_T
#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
#  define YYSIZE_T size_t
# else
#  define YYSIZE_T unsigned
# endif
#endif

#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)

#ifndef YY_
# if defined YYENABLE_NLS && YYENABLE_NLS
#  if ENABLE_NLS
#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
#   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
#  endif
# endif
# ifndef YY_
#  define YY_(Msgid) Msgid
# endif
#endif

#ifndef YY_ATTRIBUTE
# if (defined __GNUC__                                               \
      && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__)))  \
     || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
#  define YY_ATTRIBUTE(Spec) __attribute__(Spec)
# else
#  define YY_ATTRIBUTE(Spec) /* empty */
# endif
#endif

#ifndef YY_ATTRIBUTE_PURE
# define YY_ATTRIBUTE_PURE   YY_ATTRIBUTE ((__pure__))
#endif

#ifndef YY_ATTRIBUTE_UNUSED
# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
#endif

/* Suppress unused-variable warnings by "using" E.  */
#if ! defined lint || defined __GNUC__
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(E) /* empty */
#endif

#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized.  */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
    _Pragma ("GCC diagnostic push") \
    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
    _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
    _Pragma ("GCC diagnostic pop")
#else
# define YY_INITIAL_VALUE(Value) Value
#endif
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
#endif
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif


#if ! defined yyoverflow || YYERROR_VERBOSE

/* The parser invokes alloca or malloc; define the necessary symbols.  */

# ifdef YYSTACK_USE_ALLOCA
#  if YYSTACK_USE_ALLOCA
#   ifdef __GNUC__
#    define YYSTACK_ALLOC __builtin_alloca
#   elif defined __BUILTIN_VA_ARG_INCR
#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
#   elif defined _AIX
#    define YYSTACK_ALLOC __alloca
#   elif defined _MSC_VER
#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
#    define alloca _alloca
#   else
#    define YYSTACK_ALLOC alloca
#    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
      /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
#     ifndef EXIT_SUCCESS
#      define EXIT_SUCCESS 0
#     endif
#    endif
#   endif
#  endif
# endif

# ifdef YYSTACK_ALLOC
   /* Pacify GCC's 'empty if-body' warning.  */
#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
#  ifndef YYSTACK_ALLOC_MAXIMUM
    /* The OS might guarantee only one guard page at the bottom of the stack,
       and a page size can be as small as 4096 bytes.  So we cannot safely
       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
       to allow for a few compiler-allocated temporary stack slots.  */
#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
#  endif
# else
#  define YYSTACK_ALLOC YYMALLOC
#  define YYSTACK_FREE YYFREE
#  ifndef YYSTACK_ALLOC_MAXIMUM
#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
#  endif
#  if (defined __cplusplus && ! defined EXIT_SUCCESS \
       && ! ((defined YYMALLOC || defined malloc) \
             && (defined YYFREE || defined free)))
#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
#   ifndef EXIT_SUCCESS
#    define EXIT_SUCCESS 0
#   endif
#  endif
#  ifndef YYMALLOC
#   define YYMALLOC malloc
#   if ! defined malloc && ! defined EXIT_SUCCESS
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
#   endif
#  endif
#  ifndef YYFREE
#   define YYFREE free
#   if ! defined free && ! defined EXIT_SUCCESS
void free (void *); /* INFRINGES ON USER NAME SPACE */
#   endif
#  endif
# endif
#endif /* ! defined yyoverflow || YYERROR_VERBOSE */


#if (! defined yyoverflow \
     && (! defined __cplusplus \
         || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
             && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))

/* A type that is properly aligned for any stack member.  */
union yyalloc
{
  yytype_int16 yyss_alloc;
  YYSTYPE yyvs_alloc;
  YYLTYPE yyls_alloc;
};

/* The size of the maximum gap between one aligned stack and the next.  */
# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)

/* The size of an array large to enough to hold all stacks, each with
   N elements.  */
# define YYSTACK_BYTES(N) \
     ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
      + 2 * YYSTACK_GAP_MAXIMUM)

# define YYCOPY_NEEDED 1

/* Relocate STACK from its old location to the new one.  The
   local variables YYSIZE and YYSTACKSIZE give the old and new number of
   elements in the stack, and YYPTR gives the new location of the
   stack.  Advance YYPTR to a properly aligned location for the next
   stack.  */
# define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
    do                                                                  \
      {                                                                 \
        YYSIZE_T yynewbytes;                                            \
        YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
        Stack = &yyptr->Stack_alloc;                                    \
        yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
        yyptr += yynewbytes / sizeof (*yyptr);                          \
      }                                                                 \
    while (0)

#endif

#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
/* Copy COUNT objects from SRC to DST.  The source and destination do
   not overlap.  */
# ifndef YYCOPY
#  if defined __GNUC__ && 1 < __GNUC__
#   define YYCOPY(Dst, Src, Count) \
      __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
#  else
#   define YYCOPY(Dst, Src, Count)              \
      do                                        \
        {                                       \
          YYSIZE_T yyi;                         \
          for (yyi = 0; yyi < (Count); yyi++)   \
            (Dst)[yyi] = (Src)[yyi];            \
        }                                       \
      while (0)
#  endif
# endif
#endif /* !YYCOPY_NEEDED */

/* YYFINAL -- State number of the termination state.  */
#define YYFINAL  15
/* YYLAST -- Last index in YYTABLE.  */
#define YYLAST   191

/* YYNTOKENS -- Number of terminals.  */
#define YYNTOKENS  57
/* YYNNTS -- Number of nonterminals.  */
#define YYNNTS  32
/* YYNRULES -- Number of rules.  */
#define YYNRULES  92
/* YYNSTATES -- Number of states.  */
#define YYNSTATES  183

#define YYUNDEFTOK  2
#define YYMAXUTOK   296

/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
   as returned by yylex, with out-of-bounds checking.  */
#define YYTRANSLATE(YYX)                                                \
  ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)

/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
   as returned by yylex.  */
static const yytype_uint8 yytranslate[] =
{
       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,    49,     2,    54,     2,     2,    50,     2,
      44,    45,    55,    47,    46,    48,     2,    56,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
      51,    53,    52,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,    42,     2,    43,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
      35,    36,    37,    38,    39,    40,    41
};

#if YYDEBUG
  /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
static const yytype_uint16 yyrline[] =
{
       0,   112,   112,   117,   121,   127,   130,   135,   141,   147,
     153,   159,   165,   173,   185,   188,   193,   200,   209,   212,
     215,   378,   503,   506,   520,   523,   537,   551,   569,   573,
     579,   584,   592,   607,   670,   691,   714,   718,   724,   727,
     730,   735,   738,   745,   748,   751,   756,   759,   764,   767,
     772,   798,   839,   842,   845,   853,   861,   864,   874,   904,
     907,   910,   918,   926,   937,   948,   958,   961,   966,   969,
     970,   983,   984,  1009,  1012,  1037,  1038,  1063,  1066,  1091,
    1092,  1114,  1136,  1158,  1180,  1202,  1226,  1227,  1253,  1281,
    1282,  1308,  1340
};
#endif

#if YYDEBUG || YYERROR_VERBOSE || 1
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
static const char *const yytname[] =
{
  "\"end of file\"", "error", "$undefined", "\"integer literal\"",
  "\"real number literal\"", "\"integer literal with unit\"",
  "\"real number literal with unit\"", "\"string literal\"",
  "\"function name\"", "\"variable name\"", "\"keyword 'on'\"",
  "\"keyword 'end'\"", "\"keyword 'init'\"", "\"keyword 'note'\"",
  "\"keyword 'release'\"", "\"keyword 'controller'\"", "\"keyword 'rpn'\"",
  "\"keyword 'nrpn'\"", "\"keyword 'declare'\"", "\"operator ':='\"",
  "\"keyword 'const'\"", "\"keyword 'polyphonic'\"", "\"keyword 'patch'\"",
  "\"keyword 'while'\"", "\"keyword 'synchronized'\"", "\"keyword 'if'\"",
  "\"keyword 'else'\"", "\"keyword 'select'\"", "\"keyword 'case'\"",
  "\"keyword 'to'\"", "\"operator 'or'\"", "\"operator 'and'\"",
  "\"operator 'not'\"", "\"bitwise operator '.or.'\"",
  "\"bitwise operator '.and.'\"", "\"bitwise operator '.not.'\"",
  "\"keyword 'function'\"", "\"keyword 'call'\"", "\"operator 'mod'\"",
  "\"operator '<='\"", "\"operator '>='\"", "\"unknown character\"", "'['",
  "']'", "'('", "')'", "','", "'+'", "'-'", "'!'", "'&'", "'<'", "'>'",
  "'='", "'#'", "'*'", "'/'", "$accept", "script", "sections", "section",
  "eventhandler", "function_declaration", "opt_statements", "statements",
  "statement", "caseclauses", "caseclause", "userfunctioncall",
  "functioncall", "args", "arg", "opt_qualifiers", "qualifiers",
  "qualifier", "opt_assignment", "opt_arr_assignment", "assignment",
  "unary_expr", "opt_expr", "expr", "concat_expr", "logical_or_expr",
  "logical_and_expr", "bitwise_or_expr", "bitwise_and_expr", "rel_expr",
  "add_expr", "mul_expr", YY_NULLPTR
};
#endif

# ifdef YYPRINT
/* YYTOKNUM[NUM] -- (External) token number corresponding to the
   (internal) symbol number NUM (which must be that of a token).  */
static const yytype_uint16 yytoknum[] =
{
       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
     265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
     275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
     285,   286,   287,   288,   289,   290,   291,   292,   293,   294,
     295,   296,    91,    93,    40,    41,    44,    43,    45,    33,
      38,    60,    62,    61,    35,    42,    47
};
# endif

#define YYPACT_NINF -36

#define yypact_value_is_default(Yystate) \
  (!!((Yystate) == (-36)))

#define YYTABLE_NINF -1

#define yytable_value_is_error(Yytable_value) \
  0

  /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
     STATE-NUM.  */
static const yytype_int16 yypact[] =
{
       5,    60,    14,    36,     5,   -36,   -36,   -36,     8,     8,
       8,     8,     8,     8,     8,   -36,   -36,    -6,     9,    68,
      -4,     8,     3,    59,    42,    41,     8,   -36,   -36,   -36,
     -36,    43,    84,    91,    93,    94,   104,    52,    59,    59,
     -36,   -36,   -36,    89,    68,   -36,    59,   105,    59,   -36,
     -36,   -36,   -36,   -36,    75,    59,    59,    59,    59,    59,
      59,   -36,   -36,    90,    71,    92,    99,   100,    98,    87,
      -5,    15,   -36,   114,   -36,   132,   133,   134,   136,   138,
     101,   -36,    33,   -36,   -36,   -36,   106,    27,   -36,   108,
     131,   112,    59,   -36,   -36,   113,   -36,   -36,   -36,   156,
      16,   -36,    59,    59,    59,    59,    59,    59,    59,    59,
      59,    59,    59,    59,    59,    59,    59,    59,   -36,   -36,
     -36,   -36,   -36,   -36,   -36,   -36,    59,   141,    59,    59,
     -36,     8,   -36,     8,   118,   -36,   127,   139,   -36,    92,
      99,   100,    98,    87,    -5,    -5,    -5,    -5,    -5,    -5,
      15,    15,   -36,   -36,   -36,   -36,    59,   -36,   122,   -36,
     159,    23,   -36,   164,   -36,   -36,   -36,   152,   149,   148,
       8,     8,   130,   -36,   -36,   -36,   165,   -36,    59,   150,
      40,   -36,   -36
};

  /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
     Performed when YYTABLE does not specify something else to do.  Zero
     means the default is an error.  */
static const yytype_uint8 yydefact[] =
{
       0,     0,     0,     0,     2,     3,     6,     5,    14,    14,
      14,    14,    14,    14,    14,     1,     4,    35,     0,    39,
       0,    14,     0,     0,     0,     0,    15,    16,    19,    18,
      22,     0,     0,     0,     0,     0,     0,     0,     0,     0,
      43,    44,    45,     0,    40,    41,     0,     0,     0,    52,
      53,    54,    55,    56,    57,     0,     0,     0,     0,     0,
       0,    60,    89,     0,    68,    69,    71,    73,    75,    77,
      79,    86,    32,     0,    17,     0,     0,     0,     0,     0,
       0,    34,     0,    36,    38,    50,     0,    46,    42,     0,
       0,     0,     0,    64,    63,     0,    61,    62,    65,     0,
       0,    28,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     8,     7,
       9,    10,    11,    12,    13,    33,     0,     0,     0,    66,
      20,    14,    24,    14,     0,    59,    14,     0,    29,    70,
      72,    74,    76,    78,    82,    83,    80,    81,    84,    85,
      87,    88,    92,    90,    91,    37,     0,    47,     0,    67,
       0,     0,    58,     0,    30,    27,    51,    48,     0,     0,
      14,    14,     0,    21,    23,    26,     0,    31,     0,     0,
       0,    25,    49
};

  /* YYPGOTO[NTERM-NUM].  */
static const yytype_int16 yypgoto[] =
{
     -36,   -36,   -36,   173,   -36,   -36,    -2,   -36,   153,   -36,
      78,   -36,    -8,     4,    54,   -36,   -36,   137,   -36,   -36,
     -36,   -35,   -36,    -9,   -36,    81,    82,    80,    83,    85,
       2,   -21
};

  /* YYDEFGOTO[NTERM-NUM].  */
static const yytype_int16 yydefgoto[] =
{
      -1,     3,     4,     5,     6,     7,    25,    26,    27,   100,
     101,    28,    61,    82,    83,    43,    44,    45,   130,   173,
      30,    62,   158,    84,    64,    65,    66,    67,    68,    69,
      70,    71
};

  /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
     positive, shift that token.  If negative, reduce the rule whose
     number is the opposite.  If YYTABLE_NINF, syntax error.  */
static const yytype_uint8 yytable[] =
{
      29,    29,    29,    29,    29,    29,    29,    31,    32,    33,
      34,    35,    36,    29,    63,     1,    17,    18,    29,    47,
      93,    94,    14,    96,    97,    98,    19,   137,    38,    85,
      86,    20,    21,    22,   169,    23,    15,    89,    37,    91,
      46,     2,   113,   114,    99,    24,   128,    48,    95,   170,
      72,    39,    73,   115,    75,    49,    50,    51,    52,    53,
      17,    54,    49,    50,    51,    52,    53,    17,    54,   129,
     116,   117,     8,     9,    10,    11,    12,    13,   125,   126,
     152,   153,   154,   134,    55,   182,   126,    56,    40,    41,
      42,    55,   150,   151,    56,    76,    57,    81,    87,    58,
      59,    60,    77,    57,    78,    79,    58,    59,    60,   144,
     145,   146,   147,   148,   149,    80,    90,    92,    99,   157,
     159,   102,   103,    29,   118,    29,   107,   108,    29,   160,
     104,   161,   106,   105,   164,    17,    18,   124,   109,   110,
     111,   112,   119,   120,   121,    19,   122,   166,   123,   127,
      20,    21,    22,   131,    23,   132,   163,   133,   135,   136,
     156,   162,    29,    29,    24,   167,   165,   171,   176,   177,
     168,   172,   174,   175,   178,   181,   179,    16,   138,    74,
     155,    88,   180,   139,   141,   140,     0,     0,   142,     0,
       0,   143
};

static const yytype_int16 yycheck[] =
{
       8,     9,    10,    11,    12,    13,    14,     9,    10,    11,
      12,    13,    14,    21,    23,    10,     8,     9,    26,    21,
      55,    56,     8,    58,    59,    60,    18,    11,    19,    38,
      39,    23,    24,    25,    11,    27,     0,    46,    44,    48,
      44,    36,    47,    48,    28,    37,    19,    44,    57,    26,
       8,    42,    11,    38,    11,     3,     4,     5,     6,     7,
       8,     9,     3,     4,     5,     6,     7,     8,     9,    42,
      55,    56,    12,    13,    14,    15,    16,    17,    45,    46,
     115,   116,   117,    92,    32,    45,    46,    35,    20,    21,
      22,    32,   113,   114,    35,    11,    44,    45,     9,    47,
      48,    49,    11,    44,    11,    11,    47,    48,    49,   107,
     108,   109,   110,   111,   112,    11,    11,    42,    28,   128,
     129,    50,    30,   131,    10,   133,    39,    40,   136,   131,
      31,   133,    34,    33,   136,     8,     9,    36,    51,    52,
      53,    54,    10,    10,    10,    18,    10,   156,    10,    43,
      23,    24,    25,    45,    27,    24,    29,    45,    45,     3,
      19,    43,   170,   171,    37,    43,    27,     3,   170,   171,
      11,    19,    23,    25,    44,    25,    11,     4,   100,    26,
     126,    44,   178,   102,   104,   103,    -1,    -1,   105,    -1,
      -1,   106
};

  /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
     symbol of state STATE-NUM.  */
static const yytype_uint8 yystos[] =
{
       0,    10,    36,    58,    59,    60,    61,    62,    12,    13,
      14,    15,    16,    17,     8,     0,    60,     8,     9,    18,
      23,    24,    25,    27,    37,    63,    64,    65,    68,    69,
      77,    63,    63,    63,    63,    63,    63,    44,    19,    42,
      20,    21,    22,    72,    73,    74,    44,    63,    44,     3,
       4,     5,     6,     7,     9,    32,    35,    44,    47,    48,
      49,    69,    78,    80,    81,    82,    83,    84,    85,    86,
      87,    88,     8,    11,    65,    11,    11,    11,    11,    11,
      11,    45,    70,    71,    80,    80,    80,     9,    74,    80,
      11,    80,    42,    78,    78,    80,    78,    78,    78,    28,
      66,    67,    50,    30,    31,    33,    34,    39,    40,    51,
      52,    53,    54,    47,    48,    38,    55,    56,    10,    10,
      10,    10,    10,    10,    36,    45,    46,    43,    19,    42,
      75,    45,    24,    45,    80,    45,     3,    11,    67,    82,
      83,    84,    85,    86,    87,    87,    87,    87,    87,    87,
      88,    88,    78,    78,    78,    71,    19,    80,    79,    80,
      63,    63,    43,    29,    63,    27,    80,    43,    11,    11,
      26,     3,    19,    76,    23,    25,    63,    63,    44,    11,
      70,    25,    45
};

  /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
static const yytype_uint8 yyr1[] =
{
       0,    57,    58,    59,    59,    60,    60,    61,    61,    61,
      61,    61,    61,    62,    63,    63,    64,    64,    65,    65,
      65,    65,    65,    65,    65,    65,    65,    65,    66,    66,
      67,    67,    68,    69,    69,    69,    70,    70,    71,    72,
      72,    73,    73,    74,    74,    74,    75,    75,    76,    76,
      77,    77,    78,    78,    78,    78,    78,    78,    78,    78,
      78,    78,    78,    78,    78,    78,    79,    79,    80,    81,
      81,    82,    82,    83,    83,    84,    84,    85,    85,    86,
      86,    86,    86,    86,    86,    86,    87,    87,    87,    88,
      88,    88,    88
};

  /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
static const yytype_uint8 yyr2[] =
{
       0,     2,     1,     1,     2,     1,     1,     5,     5,     5,
       5,     5,     5,     5,     0,     1,     1,     2,     1,     1,
       4,     7,     1,     7,     4,     9,     7,     5,     1,     2,
       3,     5,     2,     4,     3,     1,     1,     3,     1,     0,
       1,     1,     2,     1,     1,     1,     0,     2,     0,     4,
       3,     6,     1,     1,     1,     1,     1,     1,     4,     3,
       1,     2,     2,     2,     2,     2,     0,     1,     1,     1,
       3,     1,     3,     1,     3,     1,     3,     1,     3,     1,
       3,     3,     3,     3,     3,     3,     1,     3,     3,     1,
       3,     3,     3
};


#define yyerrok         (yyerrstatus = 0)
#define yyclearin       (yychar = YYEMPTY)
#define YYEMPTY         (-2)
#define YYEOF           0

#define YYACCEPT        goto yyacceptlab
#define YYABORT         goto yyabortlab
#define YYERROR         goto yyerrorlab


#define YYRECOVERING()  (!!yyerrstatus)

#define YYBACKUP(Token, Value)                                    \
  do                                                              \
    if (yychar == YYEMPTY)                                        \
      {                                                           \
        yychar = (Token);                                         \
        yylval = (Value);                                         \
        YYPOPSTACK (yylen);                                       \
        yystate = *yyssp;                                         \
        goto yybackup;                                            \
      }                                                           \
    else                                                          \
      {                                                           \
        yyerror (&yylloc, context, YY_("syntax error: cannot back up")); \
        YYERROR;                                                  \
      }                                                           \
  while (0)

/* Error token number */
#define YYTERROR        1
#define YYERRCODE       256


/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
   If N is 0, then set CURRENT to the empty location which ends
   the previous symbol: RHS[0] (always defined).  */

#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N)                                \
    do                                                                  \
      if (N)                                                            \
        {                                                               \
          (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
          (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
          (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
          (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
        }                                                               \
      else                                                              \
        {                                                               \
          (Current).first_line   = (Current).last_line   =              \
            YYRHSLOC (Rhs, 0).last_line;                                \
          (Current).first_column = (Current).last_column =              \
            YYRHSLOC (Rhs, 0).last_column;                              \
        }                                                               \
    while (0)
#endif

#define YYRHSLOC(Rhs, K) ((Rhs)[K])


/* Enable debugging if requested.  */
#if YYDEBUG

# ifndef YYFPRINTF
#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
#  define YYFPRINTF fprintf
# endif

# define YYDPRINTF(Args)                        \
do {                                            \
  if (yydebug)                                  \
    YYFPRINTF Args;                             \
} while (0)


/* YY_LOCATION_PRINT -- Print the location on the stream.
   This macro was not mandated originally: define only if we know
   we won't break user code: when these are the locations we know.  */

#ifndef YY_LOCATION_PRINT
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL

/* Print *YYLOCP on YYO.  Private, do not rely on its existence. */

YY_ATTRIBUTE_UNUSED
static int
yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
{
  int res = 0;
  int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
  if (0 <= yylocp->first_line)
    {
      res += YYFPRINTF (yyo, "%d", yylocp->first_line);
      if (0 <= yylocp->first_column)
        res += YYFPRINTF (yyo, ".%d", yylocp->first_column);
    }
  if (0 <= yylocp->last_line)
    {
      if (yylocp->first_line < yylocp->last_line)
        {
          res += YYFPRINTF (yyo, "-%d", yylocp->last_line);
          if (0 <= end_col)
            res += YYFPRINTF (yyo, ".%d", end_col);
        }
      else if (0 <= end_col && yylocp->first_column < end_col)
        res += YYFPRINTF (yyo, "-%d", end_col);
    }
  return res;
 }

#  define YY_LOCATION_PRINT(File, Loc)          \
  yy_location_print_ (File, &(Loc))

# else
#  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
# endif
#endif


# define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
do {                                                                      \
  if (yydebug)                                                            \
    {                                                                     \
      YYFPRINTF (stderr, "%s ", Title);                                   \
      yy_symbol_print (stderr,                                            \
                  Type, Value, Location, context); \
      YYFPRINTF (stderr, "\n");                                           \
    }                                                                     \
} while (0)


/*-----------------------------------.
| Print this symbol's value on YYO.  |
`-----------------------------------*/

static void
yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, LinuxSampler::ParserContext* context)
{
  FILE *yyoutput = yyo;
  YYUSE (yyoutput);
  YYUSE (yylocationp);
  YYUSE (context);
  if (!yyvaluep)
    return;
# ifdef YYPRINT
  if (yytype < YYNTOKENS)
    YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
# endif
  YYUSE (yytype);
}


/*---------------------------.
| Print this symbol on YYO.  |
`---------------------------*/

static void
yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, LinuxSampler::ParserContext* context)
{
  YYFPRINTF (yyo, "%s %s (",
             yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);

  YY_LOCATION_PRINT (yyo, *yylocationp);
  YYFPRINTF (yyo, ": ");
  yy_symbol_value_print (yyo, yytype, yyvaluep, yylocationp, context);
  YYFPRINTF (yyo, ")");
}

/*------------------------------------------------------------------.
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
| TOP (included).                                                   |
`------------------------------------------------------------------*/

static void
yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
{
  YYFPRINTF (stderr, "Stack now");
  for (; yybottom <= yytop; yybottom++)
    {
      int yybot = *yybottom;
      YYFPRINTF (stderr, " %d", yybot);
    }
  YYFPRINTF (stderr, "\n");
}

# define YY_STACK_PRINT(Bottom, Top)                            \
do {                                                            \
  if (yydebug)                                                  \
    yy_stack_print ((Bottom), (Top));                           \
} while (0)


/*------------------------------------------------.
| Report that the YYRULE is going to be reduced.  |
`------------------------------------------------*/

static void
yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, LinuxSampler::ParserContext* context)
{
  unsigned long yylno = yyrline[yyrule];
  int yynrhs = yyr2[yyrule];
  int yyi;
  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
             yyrule - 1, yylno);
  /* The symbols being reduced.  */
  for (yyi = 0; yyi < yynrhs; yyi++)
    {
      YYFPRINTF (stderr, "   $%d = ", yyi + 1);
      yy_symbol_print (stderr,
                       yystos[yyssp[yyi + 1 - yynrhs]],
                       &yyvsp[(yyi + 1) - (yynrhs)]
                       , &(yylsp[(yyi + 1) - (yynrhs)])                       , context);
      YYFPRINTF (stderr, "\n");
    }
}

# define YY_REDUCE_PRINT(Rule)          \
do {                                    \
  if (yydebug)                          \
    yy_reduce_print (yyssp, yyvsp, yylsp, Rule, context); \
} while (0)

/* Nonzero means print parse trace.  It is left uninitialized so that
   multiple parsers can coexist.  */
int yydebug;
#else /* !YYDEBUG */
# define YYDPRINTF(Args)
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
#endif /* !YYDEBUG */


/* YYINITDEPTH -- initial size of the parser's stacks.  */
#ifndef YYINITDEPTH
# define YYINITDEPTH 200
#endif

/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
   if the built-in stack extension method is used).

   Do not make this value too large; the results are undefined if
   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
   evaluated with infinite-precision integer arithmetic.  */

#ifndef YYMAXDEPTH
# define YYMAXDEPTH 10000
#endif


#if YYERROR_VERBOSE

# ifndef yystrlen
#  if defined __GLIBC__ && defined _STRING_H
#   define yystrlen strlen
#  else
/* Return the length of YYSTR.  */
static YYSIZE_T
yystrlen (const char *yystr)
{
  YYSIZE_T yylen;
  for (yylen = 0; yystr[yylen]; yylen++)
    continue;
  return yylen;
}
#  endif
# endif

# ifndef yystpcpy
#  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
#   define yystpcpy stpcpy
#  else
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
   YYDEST.  */
static char *
yystpcpy (char *yydest, const char *yysrc)
{
  char *yyd = yydest;
  const char *yys = yysrc;

  while ((*yyd++ = *yys++) != '\0')
    continue;

  return yyd - 1;
}
#  endif
# endif

# ifndef yytnamerr
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
   quotes and backslashes, so that it's suitable for yyerror.  The
   heuristic is that double-quoting is unnecessary unless the string
   contains an apostrophe, a comma, or backslash (other than
   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
   null, do not copy; instead, return the length of what the result
   would have been.  */
static YYSIZE_T
yytnamerr (char *yyres, const char *yystr)
{
  if (*yystr == '"')
    {
      YYSIZE_T yyn = 0;
      char const *yyp = yystr;

      for (;;)
        switch (*++yyp)
          {
          case '\'':
          case ',':
            goto do_not_strip_quotes;

          case '\\':
            if (*++yyp != '\\')
              goto do_not_strip_quotes;
            else
              goto append;

          append:
          default:
            if (yyres)
              yyres[yyn] = *yyp;
            yyn++;
            break;

          case '"':
            if (yyres)
              yyres[yyn] = '\0';
            return yyn;
          }
    do_not_strip_quotes: ;
    }

  if (! yyres)
    return yystrlen (yystr);

  return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres);
}
# endif

/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
   about the unexpected token YYTOKEN for the state stack whose top is
   YYSSP.

   Return 0 if *YYMSG was successfully written.  Return 1 if *YYMSG is
   not large enough to hold the message.  In that case, also set
   *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
   required number of bytes is too large to store.  */
static int
yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
                yytype_int16 *yyssp, int yytoken)
{
  YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
  YYSIZE_T yysize = yysize0;
  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
  /* Internationalized format string. */
  const char *yyformat = YY_NULLPTR;
  /* Arguments of yyformat. */
  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
  /* Number of reported tokens (one for the "unexpected", one per
     "expected"). */
  int yycount = 0;

  /* There are many possibilities here to consider:
     - If this state is a consistent state with a default action, then
       the only way this function was invoked is if the default action
       is an error action.  In that case, don't check for expected
       tokens because there are none.
     - The only way there can be no lookahead present (in yychar) is if
       this state is a consistent state with a default action.  Thus,
       detecting the absence of a lookahead is sufficient to determine
       that there is no unexpected or expected token to report.  In that
       case, just report a simple "syntax error".
     - Don't assume there isn't a lookahead just because this state is a
       consistent state with a default action.  There might have been a
       previous inconsistent state, consistent state with a non-default
       action, or user semantic action that manipulated yychar.
     - Of course, the expected token list depends on states to have
       correct lookahead information, and it depends on the parser not
       to perform extra reductions after fetching a lookahead from the
       scanner and before detecting a syntax error.  Thus, state merging
       (from LALR or IELR) and default reductions corrupt the expected
       token list.  However, the list is correct for canonical LR with
       one exception: it will still contain any token that will not be
       accepted due to an error action in a later state.
  */
  if (yytoken != YYEMPTY)
    {
      int yyn = yypact[*yyssp];
      yyarg[yycount++] = yytname[yytoken];
      if (!yypact_value_is_default (yyn))
        {
          /* Start YYX at -YYN if negative to avoid negative indexes in
             YYCHECK.  In other words, skip the first -YYN actions for
             this state because they are default actions.  */
          int yyxbegin = yyn < 0 ? -yyn : 0;
          /* Stay within bounds of both yycheck and yytname.  */
          int yychecklim = YYLAST - yyn + 1;
          int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
          int yyx;

          for (yyx = yyxbegin; yyx < yyxend; ++yyx)
            if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
                && !yytable_value_is_error (yytable[yyx + yyn]))
              {
                if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
                  {
                    yycount = 1;
                    yysize = yysize0;
                    break;
                  }
                yyarg[yycount++] = yytname[yyx];
                {
                  YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
                  if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
                    yysize = yysize1;
                  else
                    return 2;
                }
              }
        }
    }

  switch (yycount)
    {
# define YYCASE_(N, S)                      \
      case N:                               \
        yyformat = S;                       \
      break
    default: /* Avoid compiler warnings. */
      YYCASE_(0, YY_("syntax error"));
      YYCASE_(1, YY_("syntax error, unexpected %s"));
      YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
      YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
      YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
      YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
# undef YYCASE_
    }

  {
    YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
    if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
      yysize = yysize1;
    else
      return 2;
  }

  if (*yymsg_alloc < yysize)
    {
      *yymsg_alloc = 2 * yysize;
      if (! (yysize <= *yymsg_alloc
             && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
        *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
      return 1;
    }

  /* Avoid sprintf, as that infringes on the user's name space.
     Don't have undefined behavior even if the translation
     produced a string with the wrong number of "%s"s.  */
  {
    char *yyp = *yymsg;
    int yyi = 0;
    while ((*yyp = *yyformat) != '\0')
      if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
        {
          yyp += yytnamerr (yyp, yyarg[yyi++]);
          yyformat += 2;
        }
      else
        {
          yyp++;
          yyformat++;
        }
  }
  return 0;
}
#endif /* YYERROR_VERBOSE */

/*-----------------------------------------------.
| Release the memory associated to this symbol.  |
`-----------------------------------------------*/

static void
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, LinuxSampler::ParserContext* context)
{
  YYUSE (yyvaluep);
  YYUSE (yylocationp);
  YYUSE (context);
  if (!yymsg)
    yymsg = "Deleting";
  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);

  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  YYUSE (yytype);
  YY_IGNORE_MAYBE_UNINITIALIZED_END
}




/*----------.
| yyparse.  |
`----------*/

int
yyparse (LinuxSampler::ParserContext* context)
{
/* The lookahead symbol.  */
int yychar;


/* The semantic value of the lookahead symbol.  */
/* Default value used for initialization, for pacifying older GCCs
   or non-GCC compilers.  */
YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);

/* Location data for the lookahead symbol.  */
static YYLTYPE yyloc_default
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
  = { 1, 1, 1, 1 }
# endif
;
YYLTYPE yylloc = yyloc_default;

    /* Number of syntax errors so far.  */
    int yynerrs;

    int yystate;
    /* Number of tokens to shift before error messages enabled.  */
    int yyerrstatus;

    /* The stacks and their tools:
       'yyss': related to states.
       'yyvs': related to semantic values.
       'yyls': related to locations.

       Refer to the stacks through separate pointers, to allow yyoverflow
       to reallocate them elsewhere.  */

    /* The state stack.  */
    yytype_int16 yyssa[YYINITDEPTH];
    yytype_int16 *yyss;
    yytype_int16 *yyssp;

    /* The semantic value stack.  */
    YYSTYPE yyvsa[YYINITDEPTH];
    YYSTYPE *yyvs;
    YYSTYPE *yyvsp;

    /* The location stack.  */
    YYLTYPE yylsa[YYINITDEPTH];
    YYLTYPE *yyls;
    YYLTYPE *yylsp;

    /* The locations where the error started and ended.  */
    YYLTYPE yyerror_range[3];

    YYSIZE_T yystacksize;

  int yyn;
  int yyresult;
  /* Lookahead token as an internal (translated) token number.  */
  int yytoken = 0;
  /* The variables used to return semantic value and location from the
     action routines.  */
  YYSTYPE yyval;
  YYLTYPE yyloc;

#if YYERROR_VERBOSE
  /* Buffer for error messages, and its allocated size.  */
  char yymsgbuf[128];
  char *yymsg = yymsgbuf;
  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
#endif

#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N), yylsp -= (N))

  /* The number of symbols on the RHS of the reduced rule.
     Keep to zero when no symbol should be popped.  */
  int yylen = 0;

  yyssp = yyss = yyssa;
  yyvsp = yyvs = yyvsa;
  yylsp = yyls = yylsa;
  yystacksize = YYINITDEPTH;

  YYDPRINTF ((stderr, "Starting parse\n"));

  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = YYEMPTY; /* Cause a token to be read.  */
  yylsp[0] = yylloc;
  goto yysetstate;


/*------------------------------------------------------------.
| yynewstate -- push a new state, which is found in yystate.  |
`------------------------------------------------------------*/
yynewstate:
  /* In all cases, when you get here, the value and location stacks
     have just been pushed.  So pushing a state here evens the stacks.  */
  yyssp++;


/*--------------------------------------------------------------------.
| yynewstate -- set current state (the top of the stack) to yystate.  |
`--------------------------------------------------------------------*/
yysetstate:
  *yyssp = (yytype_int16) yystate;

  if (yyss + yystacksize - 1 <= yyssp)
#if !defined yyoverflow && !defined YYSTACK_RELOCATE
    goto yyexhaustedlab;
#else
    {
      /* Get the current used size of the three stacks, in elements.  */
      YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1);

# if defined yyoverflow
      {
        /* Give user a chance to reallocate the stack.  Use copies of
           these so that the &'s don't force the real ones into
           memory.  */
        YYSTYPE *yyvs1 = yyvs;
        yytype_int16 *yyss1 = yyss;
        YYLTYPE *yyls1 = yyls;

        /* Each stack pointer address is followed by the size of the
           data in use in that stack, in bytes.  This used to be a
           conditional around just the two extra args, but that might
           be undefined if yyoverflow is a macro.  */
        yyoverflow (YY_("memory exhausted"),
                    &yyss1, yysize * sizeof (*yyssp),
                    &yyvs1, yysize * sizeof (*yyvsp),
                    &yyls1, yysize * sizeof (*yylsp),
                    &yystacksize);
        yyss = yyss1;
        yyvs = yyvs1;
        yyls = yyls1;
      }
# else /* defined YYSTACK_RELOCATE */
      /* Extend the stack our own way.  */
      if (YYMAXDEPTH <= yystacksize)
        goto yyexhaustedlab;
      yystacksize *= 2;
      if (YYMAXDEPTH < yystacksize)
        yystacksize = YYMAXDEPTH;

      {
        yytype_int16 *yyss1 = yyss;
        union yyalloc *yyptr =
          (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
        if (! yyptr)
          goto yyexhaustedlab;
        YYSTACK_RELOCATE (yyss_alloc, yyss);
        YYSTACK_RELOCATE (yyvs_alloc, yyvs);
        YYSTACK_RELOCATE (yyls_alloc, yyls);
# undef YYSTACK_RELOCATE
        if (yyss1 != yyssa)
          YYSTACK_FREE (yyss1);
      }
# endif

      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;
      yylsp = yyls + yysize - 1;

      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
                  (unsigned long) yystacksize));

      if (yyss + yystacksize - 1 <= yyssp)
        YYABORT;
    }
#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */

  YYDPRINTF ((stderr, "Entering state %d\n", yystate));

  if (yystate == YYFINAL)
    YYACCEPT;

  goto yybackup;


/*-----------.
| yybackup.  |
`-----------*/
yybackup:
  /* Do appropriate processing given the current state.  Read a
     lookahead token if we need one and don't already have one.  */

  /* First try to decide what to do without reference to lookahead token.  */
  yyn = yypact[yystate];
  if (yypact_value_is_default (yyn))
    goto yydefault;

  /* Not known => get a lookahead token if don't already have one.  */

  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
  if (yychar == YYEMPTY)
    {
      YYDPRINTF ((stderr, "Reading a token: "));
      yychar = yylex (&yylval, &yylloc, scanner);
    }

  if (yychar <= YYEOF)
    {
      yychar = yytoken = YYEOF;
      YYDPRINTF ((stderr, "Now at end of input.\n"));
    }
  else
    {
      yytoken = YYTRANSLATE (yychar);
      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
    }

  /* If the proper action on seeing token YYTOKEN is to reduce or to
     detect an error, take that action.  */
  yyn += yytoken;
  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (yytable_value_is_error (yyn))
        goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }

  /* Count tokens shifted since error; after three, turn off error
     status.  */
  if (yyerrstatus)
    yyerrstatus--;

  /* Shift the lookahead token.  */
  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);

  /* Discard the shifted token.  */
  yychar = YYEMPTY;

  yystate = yyn;
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  *++yyvsp = yylval;
  YY_IGNORE_MAYBE_UNINITIALIZED_END
  *++yylsp = yylloc;
  goto yynewstate;


/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state.  |
`-----------------------------------------------------------*/
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;


/*-----------------------------.
| yyreduce -- do a reduction.  |
`-----------------------------*/
yyreduce:
  /* yyn is the number of a rule to reduce with.  */
  yylen = yyr2[yyn];

  /* If YYLEN is nonzero, implement the default value of the action:
     '$$ = $1'.

     Otherwise, the following line sets YYVAL to garbage.
     This behavior is undocumented and Bison
     users should not rely upon it.  Assigning to YYVAL
     unconditionally makes the parser a bit smaller, and it avoids a
     GCC warning that YYVAL may be used uninitialized.  */
  yyval = yyvsp[1-yylen];

  /* Default location. */
  YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
  yyerror_range[1] = yyloc;
  YY_REDUCE_PRINT (yyn);
  switch (yyn)
    {
        case 2:
#line 112 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nEventHandlers) = context->handlers = (yyvsp[0].nEventHandlers);
    }
#line 1579 "y.tab.c" /* yacc.c:1652  */
    break;

  case 3:
#line 117 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nEventHandlers) = new EventHandlers();
        if ((yyvsp[0].nEventHandler)) (yyval.nEventHandlers)->add((yyvsp[0].nEventHandler));
    }
#line 1588 "y.tab.c" /* yacc.c:1652  */
    break;

  case 4:
#line 121 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nEventHandlers) = (yyvsp[-1].nEventHandlers);
        if ((yyvsp[0].nEventHandler)) (yyval.nEventHandlers)->add((yyvsp[0].nEventHandler));
    }
#line 1597 "y.tab.c" /* yacc.c:1652  */
    break;

  case 5:
#line 127 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nEventHandler) = EventHandlerRef();
    }
#line 1605 "y.tab.c" /* yacc.c:1652  */
    break;

  case 6:
#line 130 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nEventHandler) = (yyvsp[0].nEventHandler);
    }
#line 1613 "y.tab.c" /* yacc.c:1652  */
    break;

  case 7:
#line 135 "parser.y" /* yacc.c:1652  */
    {
        if (context->onNote)
            PARSE_ERR((yylsp[-3]), "Redeclaration of 'note' event handler.");
        context->onNote = new OnNote((yyvsp[-2].nStatements));
        (yyval.nEventHandler) = context->onNote;
    }
#line 1624 "y.tab.c" /* yacc.c:1652  */
    break;

  case 8:
#line 141 "parser.y" /* yacc.c:1652  */
    {
        if (context->onInit)
            PARSE_ERR((yylsp[-3]), "Redeclaration of 'init' event handler.");
        context->onInit = new OnInit((yyvsp[-2].nStatements));
        (yyval.nEventHandler) = context->onInit;
    }
#line 1635 "y.tab.c" /* yacc.c:1652  */
    break;

  case 9:
#line 147 "parser.y" /* yacc.c:1652  */
    {
        if (context->onRelease)
            PARSE_ERR((yylsp[-3]), "Redeclaration of 'release' event handler.");
        context->onRelease = new OnRelease((yyvsp[-2].nStatements));
        (yyval.nEventHandler) = context->onRelease;
    }
#line 1646 "y.tab.c" /* yacc.c:1652  */
    break;

  case 10:
#line 153 "parser.y" /* yacc.c:1652  */
    {
        if (context->onController)
            PARSE_ERR((yylsp[-3]), "Redeclaration of 'controller' event handler.");
        context->onController = new OnController((yyvsp[-2].nStatements));
        (yyval.nEventHandler) = context->onController;
    }
#line 1657 "y.tab.c" /* yacc.c:1652  */
    break;

  case 11:
#line 159 "parser.y" /* yacc.c:1652  */
    {
        if (context->onRpn)
            PARSE_ERR((yylsp[-3]), "Redeclaration of 'rpn' event handler.");
        context->onRpn = new OnRpn((yyvsp[-2].nStatements));
        (yyval.nEventHandler) = context->onRpn;
    }
#line 1668 "y.tab.c" /* yacc.c:1652  */
    break;

  case 12:
#line 165 "parser.y" /* yacc.c:1652  */
    {
        if (context->onNrpn)
            PARSE_ERR((yylsp[-3]), "Redeclaration of 'nrpn' event handler.");
        context->onNrpn = new OnNrpn((yyvsp[-2].nStatements));
        (yyval.nEventHandler) = context->onNrpn;
    }
#line 1679 "y.tab.c" /* yacc.c:1652  */
    break;

  case 13:
#line 173 "parser.y" /* yacc.c:1652  */
    {
        const char* name = (yyvsp[-3].sValue);
        if (context->functionProvider->functionByName(name)) {
            PARSE_ERR((yylsp[-3]), (String("There is already a built-in function with name '") + name + "'.").c_str());
        } else if (context->userFunctionByName(name)) {
            PARSE_ERR((yylsp[-3]), (String("There is already a user defined function with name '") + name + "'.").c_str());
        } else {
            context->userFnTable[name] = new UserFunction((yyvsp[-2].nStatements));
        }
    }
#line 1694 "y.tab.c" /* yacc.c:1652  */
    break;

  case 14:
#line 185 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nStatements) = new Statements();
    }
#line 1702 "y.tab.c" /* yacc.c:1652  */
    break;

  case 15:
#line 188 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nStatements) = (yyvsp[0].nStatements);
    }
#line 1710 "y.tab.c" /* yacc.c:1652  */
    break;

  case 16:
#line 193 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nStatements) = new Statements();
        if ((yyvsp[0].nStatement)) {
            if (!isNoOperation((yyvsp[0].nStatement))) (yyval.nStatements)->add((yyvsp[0].nStatement)); // filter out NoOperation statements
        } else 
            PARSE_WRN((yylsp[0]), "Not a statement.");
    }
#line 1722 "y.tab.c" /* yacc.c:1652  */
    break;

  case 17:
#line 200 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nStatements) = (yyvsp[-1].nStatements);
        if ((yyvsp[0].nStatement)) {
            if (!isNoOperation((yyvsp[0].nStatement))) (yyval.nStatements)->add((yyvsp[0].nStatement)); // filter out NoOperation statements
        } else
            PARSE_WRN((yylsp[0]), "Not a statement.");
    }
#line 1734 "y.tab.c" /* yacc.c:1652  */
    break;

  case 18:
#line 209 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nStatement) = (yyvsp[0].nFunctionCall);
    }
#line 1742 "y.tab.c" /* yacc.c:1652  */
    break;

  case 19:
#line 212 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nStatement) = (yyvsp[0].nStatements);
    }
#line 1750 "y.tab.c" /* yacc.c:1652  */
    break;

  case 20:
#line 215 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nStatement) = new NoOperation; // just as default result value
        const bool qConst      = (yyvsp[-2].varQualifier) & QUALIFIER_CONST;
        const bool qPolyphonic = (yyvsp[-2].varQualifier) & QUALIFIER_POLYPHONIC;
        const bool qPatch      = (yyvsp[-2].varQualifier) & QUALIFIER_PATCH;
        const char* name = (yyvsp[-1].sValue);
        ExpressionRef expr = (yyvsp[0].nExpression);
        //printf("declared var '%s'\n", name);
        const ExprType_t declType = exprTypeOfVarName(name);
        if (qPatch)
            context->patchVars[name].nameBlock = CODE_BLOCK((yylsp[-1]));
        if (context->variableByName(name)) {
            PARSE_ERR((yylsp[-1]), (String("Redeclaration of variable '") + name + "'.").c_str());
        } else if (qConst && !expr) {
            PARSE_ERR((yylsp[-2]), (String("Variable '") + name + "' declared const without value assignment.").c_str());
        } else if (qConst && qPolyphonic) {
            PARSE_ERR((yylsp[-2]), (String("Variable '") + name + "' must not be declared both const and polyphonic.").c_str());
        } else {
            if (!expr) {
                if (qPolyphonic) {
                    if (name[0] != '$' && name[0] != '~') {
                        PARSE_ERR((yylsp[-1]), "Polyphonic variables must only be declared either as integer or real number type.");
                    } else if (name[0] == '~') {
                        context->vartable[name] = new PolyphonicRealVariable({
                            .ctx = context
                        });
                    } else {
                        context->vartable[name] = new PolyphonicIntVariable({
                            .ctx = context
                        });
                    }
                } else {
                    if (name[0] == '@') {
                        context->vartable[name] = new StringVariable(context);
                    } else if (name[0] == '~') {
                        context->vartable[name] = new RealVariable({
                            .ctx = context
                        });
                    } else if (name[0] == '$') {
                        context->vartable[name] = new IntVariable({
                            .ctx = context
                        });
                    } else if (name[0] == '?') {
                        PARSE_ERR((yylsp[-1]), (String("Real number array variable '") + name + "' declaration requires array size.").c_str());
                    } else if (name[0] == '%') {
                        PARSE_ERR((yylsp[-1]), (String("Integer array variable '") + name + "' declaration requires array size.").c_str());
                    } else {
                        PARSE_ERR((yylsp[-1]), (String("Variable '") + name + "' declared with unknown type.").c_str());
                    }
                }
            } else {
                if (qPatch)
                    context->patchVars[name].exprBlock = ASSIGNED_EXPR_BLOCK((yylsp[0]));
                if (qPolyphonic && !isNumber(expr->exprType())) {
                    PARSE_ERR((yylsp[-1]), "Polyphonic variables must only be declared either as integer or real number type.");
                } else if (expr->exprType() == STRING_EXPR) {
                    if (name[0] != '@')
                        PARSE_WRN((yylsp[-1]), (String("Variable '") + name + "' declared as " + typeStr(declType) + ", string expression assigned though.").c_str());
                    StringExprRef strExpr = expr;
                    String s;
                    if (qConst) {
                        if (strExpr->isConstExpr())
                            s = strExpr->evalStr();
                        else
                            PARSE_ERR((yylsp[0]), (String("Assignment to const string variable '") + name + "' requires const expression.").c_str());
                        ConstStringVariableRef var = new ConstStringVariable(context, s);
                        context->vartable[name] = var;
                    } else {
                        if (strExpr->isConstExpr()) {
                            s = strExpr->evalStr();
                            StringVariableRef var = new StringVariable(context);
                            context->vartable[name] = var;
                            (yyval.nStatement) = new Assignment(var, new StringLiteral(s));
                        } else {
                            StringVariableRef var = new StringVariable(context);
                            context->vartable[name] = var;
                            (yyval.nStatement) = new Assignment(var, strExpr);
                        }
                    }
                } else if (expr->exprType() == REAL_EXPR) {
                    if (name[0] != '~')
                        PARSE_WRN((yylsp[-1]), (String("Variable '") + name + "' declared as " + typeStr(declType) + ", real number expression assigned though.").c_str());
                    RealExprRef realExpr = expr;
                    if (qConst) {
                        if (!realExpr->isConstExpr()) {
                            PARSE_ERR((yylsp[0]), (String("Assignment to const real number variable '") + name + "' requires const expression.").c_str());
                        }
                        ConstRealVariableRef var = new ConstRealVariable(
                            #if defined(__GNUC__) && !defined(__clang__)
                            (const RealVarDef&) // GCC 8.x requires this cast here (looks like a GCC bug to me); cast would cause an error with clang though
                            #endif
                        {
                            .value = (realExpr->isConstExpr()) ? realExpr->evalReal() : vmfloat(0),
                            .unitFactor = (realExpr->isConstExpr()) ? realExpr->unitFactor() : VM_NO_FACTOR,
                            .unitType = realExpr->unitType(),
                            .isFinal = realExpr->isFinal()
                        });
                        context->vartable[name] = var;
                    } else {
                        RealVariableRef var = new RealVariable({
                            .ctx = context,
                            .unitType = realExpr->unitType(),
                            .isFinal = realExpr->isFinal()
                        });
                        if (realExpr->isConstExpr()) {
                            (yyval.nStatement) = new Assignment(var, new RealLiteral({
                                .value = realExpr->evalReal(),
                                .unitFactor = realExpr->unitFactor(),
                                .unitType = realExpr->unitType(),
                                .isFinal = realExpr->isFinal()
                            }));
                        } else {
                            (yyval.nStatement) = new Assignment(var, realExpr);
                        }
                        context->vartable[name] = var;
                    }
                } else if (expr->exprType() == INT_EXPR) {
                    if (name[0] != '$')
                        PARSE_WRN((yylsp[-1]), (String("Variable '") + name + "' declared as " + typeStr(declType) + ", integer expression assigned though.").c_str());
                    IntExprRef intExpr = expr;
                    if (qConst) {
                        if (!intExpr->isConstExpr()) {
                            PARSE_ERR((yylsp[0]), (String("Assignment to const integer variable '") + name + "' requires const expression.").c_str());
                        }
                        ConstIntVariableRef var = new ConstIntVariable(
                            #if defined(__GNUC__) && !defined(__clang__)
                            (const IntVarDef&) // GCC 8.x requires this cast here (looks like a GCC bug to me); cast would cause an error with clang though
                            #endif
                        {
                            .value = (intExpr->isConstExpr()) ? intExpr->evalInt() : 0,
                            .unitFactor = (intExpr->isConstExpr()) ? intExpr->unitFactor() : VM_NO_FACTOR,
                            .unitType = intExpr->unitType(),
                            .isFinal = intExpr->isFinal()
                        });
                        context->vartable[name] = var;
                    } else {
                        IntVariableRef var = new IntVariable({
                            .ctx = context,
                            .unitType = intExpr->unitType(),
                            .isFinal = intExpr->isFinal()
                        });
                        if (intExpr->isConstExpr()) {
                            (yyval.nStatement) = new Assignment(var, new IntLiteral({
                                .value = intExpr->evalInt(),
                                .unitFactor = intExpr->unitFactor(),
                                .unitType = intExpr->unitType(),
                                .isFinal = intExpr->isFinal()
                            }));
                        } else {
                            (yyval.nStatement) = new Assignment(var, intExpr);
                        }
                        context->vartable[name] = var;
                    }
                } else if (expr->exprType() == EMPTY_EXPR) {
                    PARSE_ERR((yylsp[0]), "Expression does not result in a value.");
                    (yyval.nStatement) = new NoOperation;
                } else if (isArray(expr->exprType())) {
                    PARSE_ERR((yylsp[-1]), (String("Variable '") + name + "' declared as scalar type, array expression assigned though.").c_str());
                    (yyval.nStatement) = new NoOperation;
                }
            }
        }
    }
#line 1918 "y.tab.c" /* yacc.c:1652  */
    break;

  case 21:
#line 378 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nStatement) = new NoOperation; // just as default result value
        const bool qConst      = (yyvsp[-5].varQualifier) & QUALIFIER_CONST;
        const bool qPolyphonic = (yyvsp[-5].varQualifier) & QUALIFIER_POLYPHONIC;
        const bool qPatch      = (yyvsp[-5].varQualifier) & QUALIFIER_PATCH;
        const char* name = (yyvsp[-4].sValue);
        if (qPatch)
            context->patchVars[name].nameBlock = CODE_BLOCK((yylsp[-4]));
        if ((yyvsp[-2].nExpression) && !(yyvsp[-2].nExpression)->isConstExpr()) {
            PARSE_ERR((yylsp[-2]), (String("Array variable '") + name + "' must be declared with constant array size.").c_str());
        } else if ((yyvsp[-2].nExpression) && (yyvsp[-2].nExpression)->exprType() != INT_EXPR) {
            PARSE_ERR((yylsp[-2]), (String("Size of array variable '") + name + "' declared with non integer expression.").c_str());
        } else if (context->variableByName(name)) {
            PARSE_ERR((yylsp[-4]), (String("Redeclaration of variable '") + name + "'.").c_str());
        } else if (qConst && !(yyvsp[0].nArgs)) {
            PARSE_ERR((yylsp[-5]), (String("Array variable '") + name + "' declared const without value assignment.").c_str());
        } else if (qPolyphonic) {
            PARSE_ERR((yylsp[-5]), (String("Array variable '") + name + "' must not be declared polyphonic.").c_str());
        } else {
            IntExprRef sizeExpr = (yyvsp[-2].nExpression);
            ArgsRef args = (yyvsp[0].nArgs);
            vmint size = (sizeExpr) ? sizeExpr->evalInt() : (args) ? args->argsCount() : 0;
            if (size == 0)
                PARSE_WRN((yylsp[-2]), (String("Array variable '") + name + "' declared with zero array size.").c_str());
            if (size < 0) {
                PARSE_ERR((yylsp[-2]), (String("Array variable '") + name + "' must not be declared with negative array size.").c_str());
            } else if (sizeExpr && (sizeExpr->unitType() || sizeExpr->hasUnitFactorNow())) {
                PARSE_ERR((yylsp[-2]), "Units are not allowed as array size.");
            } else {
                if (sizeExpr && sizeExpr->isFinal())
                    PARSE_WRN((yylsp[-2]), "Final operator '!' is meaningless here.");
                if (!args) {
                    if (name[0] == '?') {
                        context->vartable[name] = new RealArrayVariable(context, size);
                    } else if (name[0] == '%') {
                        context->vartable[name] = new IntArrayVariable(context, size);
                    } else {
                        PARSE_ERR((yylsp[-4]), (String("Variable '") + name + "' declared as unknown array type: use either '%' or '?' instead of '" + String(name).substr(0,1) + "'.").c_str());
                    }
                } else {
                    if (qPatch)
                        context->patchVars[name].exprBlock = ASSIGNED_EXPR_BLOCK((yylsp[0]));
                    if (size == 0)
                        PARSE_WRN((yylsp[-2]), (String("Array variable '") + name + "' declared with zero array size.").c_str());
                    if (size < 0) {
                        PARSE_ERR((yylsp[-2]), (String("Array variable '") + name + "' must not be declared with negative array size.").c_str());
                    } else if (args->argsCount() > size) {
                        PARSE_ERR((yylsp[0]), (String("Array variable '") + name +
                                  "' was declared with size " + ToString(size) +
                                  " but " + ToString(args->argsCount()) +
                                  " values were assigned." ).c_str());
                    } else {
                        if (args->argsCount() < size) {
                            PARSE_WRN((yylsp[-2]), (String("Array variable '") + name +
                                      "' was declared with size " + ToString(size) +
                                      " but only " + ToString(args->argsCount()) +
                                      " values were assigned." ).c_str());
                        }
                        ExprType_t declType = EMPTY_EXPR;
                        if (name[0] == '%') {
                            declType = INT_EXPR;
                        } else if (name[0] == '?') {
                            declType = REAL_EXPR;
                        } else if (name[0] == '$') {
                            PARSE_ERR((yylsp[-4]), (String("Variable '") + name + "' declaration ambiguous: Use '%' as name prefix for integer arrays instead of '$'.").c_str());
                        } else if (name[0] == '~') {
                            PARSE_ERR((yylsp[-4]), (String("Variable '") + name + "' declaration ambiguous: Use '?' as name prefix for real number arrays instead of '~'.").c_str());
                        } else {
                            PARSE_ERR((yylsp[-4]), (String("Variable '") + name + "' declared as unknown array type: use either '%' or '?' instead of '" + String(name).substr(0,1) + "'.").c_str());
                        }
                        bool argsOK = true;
                        if (declType == EMPTY_EXPR) {
                            argsOK = false;
                        } else {
                            for (vmint i = 0; i < args->argsCount(); ++i) {
                                if (args->arg(i)->exprType() != declType) {
                                    PARSE_ERR(
                                        (yylsp[0]),
                                        (String("Array variable '") + name +
                                        "' declared with invalid assignment values. Assigned element " +
                                        ToString(i+1) + " is not an " + typeStr(declType) + " expression.").c_str()
                                    );
                                    argsOK = false;
                                    break;
                                } else if (qConst && !args->arg(i)->isConstExpr()) {
                                    PARSE_ERR(
                                        (yylsp[0]),
                                        (String("const array variable '") + name +
                                        "' must be defined with const values. Assigned element " +
                                        ToString(i+1) + " is not a const expression though.").c_str()
                                    );
                                    argsOK = false;
                                    break;
                                } else if (args->arg(i)->asNumber()->unitType()) {
                                    PARSE_ERR(
                                        (yylsp[0]),
                                        (String("Array variable '") + name +
                                        "' declared with invalid assignment values. Assigned element " +
                                        ToString(i+1) + " contains a unit type, only metric prefixes are allowed for arrays.").c_str()
                                    );
                                    argsOK = false;
                                    break;
                                } else if (args->arg(i)->asNumber()->isFinal()) {
                                    PARSE_ERR(
                                        (yylsp[0]),
                                        (String("Array variable '") + name +
                                        "' declared with invalid assignment values. Assigned element " +
                                        ToString(i+1) + " declared as 'final' value.").c_str()
                                    );
                                    argsOK = false;
                                    break;
                                }
                            }
                        }
                        if (argsOK) {
                            if (declType == REAL_EXPR)
                                context->vartable[name] = new RealArrayVariable(context, size, args, qConst);
                            else
                                context->vartable[name] = new IntArrayVariable(context, size, args, qConst);
                        }
                    }
                }
            }
        }
    }
#line 2048 "y.tab.c" /* yacc.c:1652  */
    break;

  case 22:
#line 503 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nStatement) = (yyvsp[0].nStatement);
    }
#line 2056 "y.tab.c" /* yacc.c:1652  */
    break;

  case 23:
#line 506 "parser.y" /* yacc.c:1652  */
    {
        if ((yyvsp[-4].nExpression)->exprType() == INT_EXPR) {
            IntExprRef expr = (yyvsp[-4].nExpression);
            if (expr->asNumber()->unitType() ||
                expr->asNumber()->hasUnitFactorEver())
                PARSE_WRN((yylsp[-4]), "Condition for 'while' loops contains a unit.");
            else if (expr->isFinal() && expr->isConstExpr())
                PARSE_WRN((yylsp[-4]), "Final operator '!' is meaningless here.");
            (yyval.nStatement) = new While(expr, (yyvsp[-2].nStatements));
        } else {
            PARSE_ERR((yylsp[-4]), "Condition for 'while' loops must be integer expression.");
            (yyval.nStatement) = new While(new IntLiteral({ .value = 0 }), (yyvsp[-2].nStatements));
        }
    }
#line 2075 "y.tab.c" /* yacc.c:1652  */
    break;

  case 24:
#line 520 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nStatement) = new SyncBlock((yyvsp[-2].nStatements));
    }
#line 2083 "y.tab.c" /* yacc.c:1652  */
    break;

  case 25:
#line 523 "parser.y" /* yacc.c:1652  */
    {
        if ((yyvsp[-6].nExpression)->exprType() == INT_EXPR) {
            IntExprRef expr = (yyvsp[-6].nExpression);
            if (expr->asNumber()->unitType() ||
                expr->asNumber()->hasUnitFactorEver())
                PARSE_WRN((yylsp[-6]), "Condition for 'if' contains a unit.");
            else if (expr->isFinal() && expr->isConstExpr())
                PARSE_WRN((yylsp[-6]), "Final operator '!' is meaningless here.");
            (yyval.nStatement) = new If((yyvsp[-6].nExpression), (yyvsp[-4].nStatements), (yyvsp[-2].nStatements));
        } else {
            PARSE_ERR((yylsp[-6]), "Condition for 'if' must be integer expression.");
            (yyval.nStatement) = new If(new IntLiteral({ .value = 0 }), (yyvsp[-4].nStatements), (yyvsp[-2].nStatements));
        }
    }
#line 2102 "y.tab.c" /* yacc.c:1652  */
    break;

  case 26:
#line 537 "parser.y" /* yacc.c:1652  */
    {
        if ((yyvsp[-4].nExpression)->exprType() == INT_EXPR) {
            IntExprRef expr = (yyvsp[-4].nExpression);
            if (expr->asNumber()->unitType() ||
                expr->asNumber()->hasUnitFactorEver())
                PARSE_WRN((yylsp[-4]), "Condition for 'if' contains a unit.");
            else if (expr->isFinal() && expr->isConstExpr())
                PARSE_WRN((yylsp[-4]), "Final operator '!' is meaningless here.");
            (yyval.nStatement) = new If((yyvsp[-4].nExpression), (yyvsp[-2].nStatements));
        } else {
            PARSE_ERR((yylsp[-4]), "Condition for 'if' must be integer expression.");
            (yyval.nStatement) = new If(new IntLiteral({ .value = 0 }), (yyvsp[-2].nStatements));
        }
    }
#line 2121 "y.tab.c" /* yacc.c:1652  */
    break;

  case 27:
#line 551 "parser.y" /* yacc.c:1652  */
    {
        if ((yyvsp[-3].nExpression)->exprType() == INT_EXPR) {
            IntExprRef expr = (yyvsp[-3].nExpression);
            if (expr->unitType() || expr->hasUnitFactorEver()) {
                PARSE_ERR((yylsp[-3]), "Units are not allowed here.");
                (yyval.nStatement) = new SelectCase(new IntLiteral({ .value = 0 }), (yyvsp[-2].nCaseBranches));
            } else {
                if (expr->isFinal() && expr->isConstExpr())
                    PARSE_WRN((yylsp[-3]), "Final operator '!' is meaningless here.");
                (yyval.nStatement) = new SelectCase(expr, (yyvsp[-2].nCaseBranches));
            }
        } else {
            PARSE_ERR((yylsp[-3]), "Statement 'select' can only by applied to integer expressions.");
            (yyval.nStatement) = new SelectCase(new IntLiteral({ .value = 0 }), (yyvsp[-2].nCaseBranches));
        }
    }
#line 2142 "y.tab.c" /* yacc.c:1652  */
    break;

  case 28:
#line 569 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nCaseBranches) = CaseBranches();
        (yyval.nCaseBranches).push_back((yyvsp[0].nCaseBranch));
    }
#line 2151 "y.tab.c" /* yacc.c:1652  */
    break;

  case 29:
#line 573 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nCaseBranches) = (yyvsp[-1].nCaseBranches);
        (yyval.nCaseBranches).push_back((yyvsp[0].nCaseBranch));
    }
#line 2160 "y.tab.c" /* yacc.c:1652  */
    break;

  case 30:
#line 579 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nCaseBranch) = CaseBranch();
        (yyval.nCaseBranch).from = new IntLiteral({ .value = (yyvsp[-1].iValue) });
        (yyval.nCaseBranch).statements = (yyvsp[0].nStatements);
    }
#line 2170 "y.tab.c" /* yacc.c:1652  */
    break;

  case 31:
#line 584 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nCaseBranch) = CaseBranch();
        (yyval.nCaseBranch).from = new IntLiteral({ .value = (yyvsp[-3].iValue) });
        (yyval.nCaseBranch).to   = new IntLiteral({ .value = (yyvsp[-1].iValue) });
        (yyval.nCaseBranch).statements = (yyvsp[0].nStatements);
    }
#line 2181 "y.tab.c" /* yacc.c:1652  */
    break;

  case 32:
#line 592 "parser.y" /* yacc.c:1652  */
    {
        const char* name = (yyvsp[0].sValue);
        UserFunctionRef fn = context->userFunctionByName(name);
        if (context->functionProvider->functionByName(name)) {
            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());
            (yyval.nStatements) = StatementsRef();
        } else if (!fn) {
            PARSE_ERR((yylsp[0]), (String("No user defined function with name '") + name + "'.").c_str());
            (yyval.nStatements) = StatementsRef();
        } else {
            (yyval.nStatements) = fn;
        }
    }
#line 2199 "y.tab.c" /* yacc.c:1652  */
    break;

  case 33:
#line 607 "parser.y" /* yacc.c:1652  */
    {
        const char* name = (yyvsp[-3].sValue);
        //printf("function call of '%s' with args\n", name);
        ArgsRef args = (yyvsp[-1].nArgs);
        VMFunction* fn = context->functionProvider->functionByName(name);
        if (context->userFunctionByName(name)) {
            PARSE_ERR((yylsp[-3]), (String("Missing 'call' keyword before user defined function name '") + name + "'.").c_str());
            (yyval.nFunctionCall) = new FunctionCall(name, args, NULL);
        } else if (!fn) {
            PARSE_ERR((yylsp[-3]), (String("No built-in function with name '") + name + "'.").c_str());
            (yyval.nFunctionCall) = new FunctionCall(name, args, NULL);
        } else if (context->functionProvider->isFunctionDisabled(fn,context)) {
            PARSE_DROP((yyloc));
            (yyval.nFunctionCall) = new NoFunctionCall;
        } else if (args->argsCount() < fn->minRequiredArgs()) {
            PARSE_ERR((yylsp[-1]), (String("Built-in function '") + name + "' requires at least " + ToString(fn->minRequiredArgs()) + " arguments.").c_str());
            (yyval.nFunctionCall) = new FunctionCall(name, args, NULL);
        } else if (args->argsCount() > fn->maxAllowedArgs()) {
            PARSE_ERR((yylsp[-1]), (String("Built-in function '") + name + "' accepts max. " + ToString(fn->maxAllowedArgs()) + " arguments.").c_str());
            (yyval.nFunctionCall) = new FunctionCall(name, args, NULL);
        } else {
            bool argsOK = true;
            for (vmint i = 0; i < args->argsCount(); ++i) {
                if (!fn->acceptsArgType(i, args->arg(i)->exprType())) {
                    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());
                    argsOK = false;
                    break;
                } else if (fn->modifiesArg(i) && !args->arg(i)->isModifyable()) {
                    PARSE_ERR((yylsp[-1]), (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' expects an assignable variable.").c_str());
                    argsOK = false;
                    break;
                } else if (isNumber(args->arg(i)->exprType()) && !fn->acceptsArgUnitType(i, args->arg(i)->asNumber()->unitType())) {
                    if (args->arg(i)->asNumber()->unitType())
                        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());
                    else
                        PARSE_ERR((yylsp[-1]), (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' expects a unit.").c_str());
                    argsOK = false;
                    break;
                } else if (isNumber(args->arg(i)->exprType()) && args->arg(i)->asNumber()->hasUnitFactorEver() && !fn->acceptsArgUnitPrefix(i, args->arg(i)->asNumber()->unitType())) {
                    if (args->arg(i)->asNumber()->unitType())
                        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());
                    else
                        PARSE_ERR((yylsp[-1]), (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' does not expect a unit prefix.").c_str());
                    argsOK = false;
                    break;
                } else if (!fn->acceptsArgFinal(i) && isNumber(args->arg(i)->exprType()) && args->arg(i)->asNumber()->isFinal()) {
                    PARSE_ERR((yylsp[-1]), (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' does not expect a \"final\" value.").c_str());
                    argsOK = false;
                    break;
                }
            }
            if (argsOK) {
                // perform built-in function's own, custom arguments checks (if any)
                fn->checkArgs(&*args, [&](String err) {
                    PARSE_ERR((yylsp[-1]), (String("Built-in function '") + name + "()': " + err).c_str());
                    argsOK = false;
                }, [&](String wrn) {
                    PARSE_WRN((yylsp[-1]), (String("Built-in function '") + name + "()': " + wrn).c_str());
                });
            }
            (yyval.nFunctionCall) = new FunctionCall(name, args, argsOK ? fn : NULL);
        }
    }
#line 2267 "y.tab.c" /* yacc.c:1652  */
    break;

  case 34:
#line 670 "parser.y" /* yacc.c:1652  */
    {
        const char* name = (yyvsp[-2].sValue);
        //printf("function call of '%s' (with empty args)\n", name);
        ArgsRef args = new Args;
        VMFunction* fn = context->functionProvider->functionByName(name);
        if (context->userFunctionByName(name)) {
            PARSE_ERR((yylsp[-2]), (String("Missing 'call' keyword before user defined function name '") + name + "'.").c_str());
            (yyval.nFunctionCall) = new FunctionCall(name, args, NULL);
        } else if (!fn) {
            PARSE_ERR((yylsp[-2]), (String("No built-in function with name '") + name + "'.").c_str());
            (yyval.nFunctionCall) = new FunctionCall(name, args, NULL);
        } else if (context->functionProvider->isFunctionDisabled(fn,context)) {
            PARSE_DROP((yyloc));
            (yyval.nFunctionCall) = new NoFunctionCall;
        } else if (fn->minRequiredArgs() > 0) {
            PARSE_ERR((yylsp[0]), (String("Built-in function '") + name + "' requires at least " + ToString(fn->minRequiredArgs()) + " arguments.").c_str());
            (yyval.nFunctionCall) = new FunctionCall(name, args, NULL);
        } else {
            (yyval.nFunctionCall) = new FunctionCall(name, args, fn);
        }
    }
#line 2293 "y.tab.c" /* yacc.c:1652  */
    break;

  case 35:
#line 691 "parser.y" /* yacc.c:1652  */
    {
        const char* name = (yyvsp[0].sValue);
        //printf("function call of '%s' (without args)\n", name);
        ArgsRef args = new Args;
        VMFunction* fn = context->functionProvider->functionByName(name);
        if (context->userFunctionByName(name)) {
            PARSE_ERR((yylsp[0]), (String("Missing 'call' keyword before user defined function name '") + name + "'.").c_str());
            (yyval.nFunctionCall) = new FunctionCall(name, args, NULL);
        } else if (!fn) {
            PARSE_ERR((yylsp[0]), (String("No built-in function with name '") + name + "'.").c_str());
            (yyval.nFunctionCall) = new FunctionCall(name, args, NULL);
        } else if (context->functionProvider->isFunctionDisabled(fn,context)) {
            PARSE_DROP((yyloc));
            (yyval.nFunctionCall) = new NoFunctionCall;
        } else if (fn->minRequiredArgs() > 0) {
            PARSE_ERR((yylsp[0]), (String("Built-in function '") + name + "' requires at least " + ToString(fn->minRequiredArgs()) + " arguments.").c_str());
            (yyval.nFunctionCall) = new FunctionCall(name, args, NULL);
        } else {
            (yyval.nFunctionCall) = new FunctionCall(name, args, fn);
        }
    }
#line 2319 "y.tab.c" /* yacc.c:1652  */
    break;

  case 36:
#line 714 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nArgs) = new Args();
        (yyval.nArgs)->add((yyvsp[0].nExpression));
    }
#line 2328 "y.tab.c" /* yacc.c:1652  */
    break;

  case 37:
#line 718 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nArgs) = (yyvsp[-2].nArgs);
        (yyval.nArgs)->add((yyvsp[0].nExpression));
    }
#line 2337 "y.tab.c" /* yacc.c:1652  */
    break;

  case 39:
#line 727 "parser.y" /* yacc.c:1652  */
    {
        (yyval.varQualifier) = QUALIFIER_NONE;
    }
#line 2345 "y.tab.c" /* yacc.c:1652  */
    break;

  case 40:
#line 730 "parser.y" /* yacc.c:1652  */
    {
        (yyval.varQualifier) = (yyvsp[0].varQualifier);
    }
#line 2353 "y.tab.c" /* yacc.c:1652  */
    break;

  case 41:
#line 735 "parser.y" /* yacc.c:1652  */
    {
        (yyval.varQualifier) = (yyvsp[0].varQualifier);
    }
#line 2361 "y.tab.c" /* yacc.c:1652  */
    break;

  case 42:
#line 738 "parser.y" /* yacc.c:1652  */
    {
        if ((yyvsp[-1].varQualifier) & (yyvsp[0].varQualifier))
            PARSE_ERR((yylsp[0]), ("Qualifier '" + qualifierStr((yyvsp[0].varQualifier)) + "' must only be listed once.").c_str());
        (yyval.varQualifier) = (Qualifier_t) ((yyvsp[-1].varQualifier) | (yyvsp[0].varQualifier));
    }
#line 2371 "y.tab.c" /* yacc.c:1652  */
    break;

  case 43:
#line 745 "parser.y" /* yacc.c:1652  */
    {
        (yyval.varQualifier) = QUALIFIER_CONST;
    }
#line 2379 "y.tab.c" /* yacc.c:1652  */
    break;

  case 44:
#line 748 "parser.y" /* yacc.c:1652  */
    {
        (yyval.varQualifier) = QUALIFIER_POLYPHONIC;
    }
#line 2387 "y.tab.c" /* yacc.c:1652  */
    break;

  case 45:
#line 751 "parser.y" /* yacc.c:1652  */
    {
        (yyval.varQualifier) = QUALIFIER_PATCH;
    }
#line 2395 "y.tab.c" /* yacc.c:1652  */
    break;

  case 46:
#line 756 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nExpression) = ExpressionRef();
    }
#line 2403 "y.tab.c" /* yacc.c:1652  */
    break;

  case 47:
#line 759 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nExpression) = (yyvsp[0].nExpression);
    }
#line 2411 "y.tab.c" /* yacc.c:1652  */
    break;

  case 48:
#line 764 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nArgs) = ArgsRef();
    }
#line 2419 "y.tab.c" /* yacc.c:1652  */
    break;

  case 49:
#line 767 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nArgs) = (yyvsp[-1].nArgs);
    }
#line 2427 "y.tab.c" /* yacc.c:1652  */
    break;

  case 50:
#line 772 "parser.y" /* yacc.c:1652  */
    {
        //printf("variable lookup with name '%s' as assignment expr\n", $1);
        const char* name = (yyvsp[-2].sValue);
        VariableRef var = context->variableByName(name);
        if (!var)
            PARSE_ERR((yylsp[-2]), (String("Variable assignment: No variable declared with name '") + name + "'.").c_str());
        else if (var->isConstExpr())
            PARSE_ERR((yylsp[-1]), (String("Variable assignment: Cannot modify const variable '") + name + "'.").c_str());
        else if (!var->isAssignable())
            PARSE_ERR((yylsp[-1]), (String("Variable assignment: Variable '") + name + "' is not assignable.").c_str());
        else if (var->exprType() != (yyvsp[0].nExpression)->exprType())
            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());
        else if (isNumber(var->exprType())) {
            NumberVariableRef numberVar = var;
            NumberExprRef expr = (yyvsp[0].nExpression);
            if (numberVar->unitType() != expr->unitType())
                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());
            else if (numberVar->isFinal() != expr->isFinal())
                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());
        }

        if (var)
            (yyval.nStatement) = new Assignment(var, (yyvsp[0].nExpression));
        else
            (yyval.nStatement) = new NoOperation;
    }
#line 2458 "y.tab.c" /* yacc.c:1652  */
    break;

  case 51:
#line 798 "parser.y" /* yacc.c:1652  */
    {
        const char* name = (yyvsp[-5].sValue);
        VariableRef var = context->variableByName(name);
        if (!var)
            PARSE_ERR((yylsp[-5]), (String("No variable declared with name '") + name + "'.").c_str());
        else if (!isArray(var->exprType()))
            PARSE_ERR((yylsp[-4]), (String("Variable '") + name + "' is not an array variable.").c_str());
        else if (var->isConstExpr())
            PARSE_ERR((yylsp[-1]), (String("Variable assignment: Cannot modify const array variable '") + name + "'.").c_str());
        else if (!var->isAssignable())
            PARSE_ERR((yylsp[-1]), (String("Variable assignment: Array variable '") + name + "' is not assignable.").c_str());
        else if ((yyvsp[-3].nExpression)->exprType() != INT_EXPR)
            PARSE_ERR((yylsp[-3]), (String("Array variable '") + name + "' accessed with non integer expression.").c_str());
        else if ((yyvsp[-3].nExpression)->asInt()->unitType())
            PARSE_ERR((yylsp[-3]), "Unit types are not allowed as array index.");
        else if ((yyvsp[0].nExpression)->exprType() != scalarTypeOfArray(var->exprType()))
            PARSE_ERR((yylsp[-1]), (String("Variable '") + name + "' was declared as " + typeStr(var->exprType()) + ", assigned expression is " + typeStr((yyvsp[0].nExpression)->exprType()) + " though.").c_str());
        else if ((yyvsp[0].nExpression)->asNumber()->unitType())
            PARSE_ERR((yylsp[0]), "Unit types are not allowed for array variables.");
        else if ((yyvsp[0].nExpression)->asNumber()->isFinal())
            PARSE_ERR((yylsp[0]), "Final operator '!' not allowed for array variables.");
        else if ((yyvsp[-3].nExpression)->isConstExpr() && (yyvsp[-3].nExpression)->asInt()->evalInt() >= ((ArrayExprRef)var)->arraySize())
            PARSE_WRN((yylsp[-3]), (String("Index ") + ToString((yyvsp[-3].nExpression)->asInt()->evalInt()) +
                          " exceeds size of array variable '" + name +
                          "' which was declared with size " +
                          ToString(((ArrayExprRef)var)->arraySize()) + ".").c_str());
        else if ((yyvsp[-3].nExpression)->asInt()->isFinal())
            PARSE_WRN((yylsp[-3]), "Final operator '!' is meaningless here.");

        if (!var) {
            (yyval.nStatement) = new NoOperation;
        } else if (var->exprType() == INT_ARR_EXPR) {
            IntArrayElementRef element = new IntArrayElement(var, (yyvsp[-3].nExpression));
            (yyval.nStatement) = new Assignment(element, (yyvsp[0].nExpression));
        } else if (var->exprType() == REAL_ARR_EXPR) {
            RealArrayElementRef element = new RealArrayElement(var, (yyvsp[-3].nExpression));
            (yyval.nStatement) = new Assignment(element, (yyvsp[0].nExpression));
        }
    }
#line 2502 "y.tab.c" /* yacc.c:1652  */
    break;

  case 52:
#line 839 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nExpression) = new IntLiteral({ .value = (yyvsp[0].iValue) });
    }
#line 2510 "y.tab.c" /* yacc.c:1652  */
    break;

  case 53:
#line 842 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nExpression) = new RealLiteral({ .value = (yyvsp[0].fValue) });
    }
#line 2518 "y.tab.c" /* yacc.c:1652  */
    break;

  case 54:
#line 845 "parser.y" /* yacc.c:1652  */
    {
        IntLiteralRef literal = new IntLiteral({
            .value = (yyvsp[0].iUnitValue).iValue,
            .unitFactor = VMUnit::unitFactor((yyvsp[0].iUnitValue).prefix),
            .unitType = (yyvsp[0].iUnitValue).unit
        });
        (yyval.nExpression) = literal;
    }
#line 2531 "y.tab.c" /* yacc.c:1652  */
    break;

  case 55:
#line 853 "parser.y" /* yacc.c:1652  */
    {
        RealLiteralRef literal = new RealLiteral({
            .value = (yyvsp[0].fUnitValue).fValue,
            .unitFactor = VMUnit::unitFactor((yyvsp[0].fUnitValue).prefix),
            .unitType = (yyvsp[0].fUnitValue).unit
        });
        (yyval.nExpression) = literal;
    }
#line 2544 "y.tab.c" /* yacc.c:1652  */
    break;

  case 56:
#line 861 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nExpression) = new StringLiteral((yyvsp[0].sValue));
    }
#line 2552 "y.tab.c" /* yacc.c:1652  */
    break;

  case 57:
#line 864 "parser.y" /* yacc.c:1652  */
    {
        //printf("variable lookup with name '%s' as unary expr\n", $1);
        VariableRef var = context->variableByName((yyvsp[0].sValue));
        if (var)
            (yyval.nExpression) = var;
        else {
            PARSE_ERR((yylsp[0]), (String("No variable declared with name '") + (yyvsp[0].sValue) + "'.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        }
    }
#line 2567 "y.tab.c" /* yacc.c:1652  */
    break;

  case 58:
#line 874 "parser.y" /* yacc.c:1652  */
    {
        const char* name = (yyvsp[-3].sValue);
        VariableRef var = context->variableByName(name);
        if (!var) {
            PARSE_ERR((yylsp[-3]), (String("No variable declared with name '") + name + "'.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (!isArray(var->exprType())) {
            PARSE_ERR((yylsp[-2]), (String("Variable '") + name + "' is not an array variable.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if ((yyvsp[-1].nExpression)->exprType() != INT_EXPR) {
            PARSE_ERR((yylsp[-1]), (String("Array variable '") + name + "' accessed with non integer expression.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if ((yyvsp[-1].nExpression)->asInt()->unitType() || (yyvsp[-1].nExpression)->asInt()->hasUnitFactorEver()) {
            PARSE_ERR((yylsp[-1]), "Units are not allowed as array index.");
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else {
            if ((yyvsp[-1].nExpression)->isConstExpr() && (yyvsp[-1].nExpression)->asInt()->evalInt() >= ((ArrayExprRef)var)->arraySize())
                PARSE_WRN((yylsp[-1]), (String("Index ") + ToString((yyvsp[-1].nExpression)->asInt()->evalInt()) +
                               " exceeds size of array variable '" + name +
                               "' which was declared with size " +
                               ToString(((ArrayExprRef)var)->arraySize()) + ".").c_str());
            else if ((yyvsp[-1].nExpression)->asInt()->isFinal())
                PARSE_WRN((yylsp[-1]), "Final operator '!' is meaningless here.");
            if (var->exprType() == REAL_ARR_EXPR) {
                (yyval.nExpression) = new RealArrayElement(var, (yyvsp[-1].nExpression));
            } else {
                (yyval.nExpression) = new IntArrayElement(var, (yyvsp[-1].nExpression));
            }
        }
    }
#line 2602 "y.tab.c" /* yacc.c:1652  */
    break;

  case 59:
#line 904 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nExpression) = (yyvsp[-1].nExpression);
    }
#line 2610 "y.tab.c" /* yacc.c:1652  */
    break;

  case 60:
#line 907 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nExpression) = (yyvsp[0].nFunctionCall);
    }
#line 2618 "y.tab.c" /* yacc.c:1652  */
    break;

  case 61:
#line 910 "parser.y" /* yacc.c:1652  */
    {
        if (isNumber((yyvsp[0].nExpression)->exprType())) {
            (yyval.nExpression) = (yyvsp[0].nExpression);
        } else {
            PARSE_ERR((yylsp[0]), (String("Unary '+' operator requires number, is ") + typeStr((yyvsp[0].nExpression)->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        }
    }
#line 2631 "y.tab.c" /* yacc.c:1652  */
    break;

  case 62:
#line 918 "parser.y" /* yacc.c:1652  */
    {
        if (isNumber((yyvsp[0].nExpression)->exprType())) {
            (yyval.nExpression) = new Neg((yyvsp[0].nExpression));
        } else {
            PARSE_ERR((yylsp[0]), (String("Unary '-' operator requires number, is ") + typeStr((yyvsp[0].nExpression)->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        }
    }
#line 2644 "y.tab.c" /* yacc.c:1652  */
    break;

  case 63:
#line 926 "parser.y" /* yacc.c:1652  */
    {
        if ((yyvsp[0].nExpression)->exprType() != INT_EXPR) {
            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());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if ((yyvsp[0].nExpression)->asInt()->unitType() || (yyvsp[0].nExpression)->asInt()->hasUnitFactorEver()) {
            PARSE_ERR((yylsp[0]), "Units are not allowed for operands of bitwise operations.");
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else {
            (yyval.nExpression) = new BitwiseNot((yyvsp[0].nExpression));
        }
    }
#line 2660 "y.tab.c" /* yacc.c:1652  */
    break;

  case 64:
#line 937 "parser.y" /* yacc.c:1652  */
    {
        if ((yyvsp[0].nExpression)->exprType() != INT_EXPR) {
            PARSE_ERR((yylsp[0]), (String("Right operand of operator 'not' must be an integer expression, is ") + typeStr((yyvsp[0].nExpression)->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if ((yyvsp[0].nExpression)->asInt()->unitType() || (yyvsp[0].nExpression)->asInt()->hasUnitFactorEver()) {
            PARSE_ERR((yylsp[0]), "Units are not allowed for operands of logical operations.");
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else {
            (yyval.nExpression) = new Not((yyvsp[0].nExpression));
        }
    }
#line 2676 "y.tab.c" /* yacc.c:1652  */
    break;

  case 65:
#line 948 "parser.y" /* yacc.c:1652  */
    {
        if (!isNumber((yyvsp[0].nExpression)->exprType())) {
            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());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else {
            (yyval.nExpression) = new Final((yyvsp[0].nExpression));
        }
    }
#line 2689 "y.tab.c" /* yacc.c:1652  */
    break;

  case 66:
#line 958 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nExpression) = NULL;
    }
#line 2697 "y.tab.c" /* yacc.c:1652  */
    break;

  case 67:
#line 961 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nExpression) = (yyvsp[0].nExpression);
    }
#line 2705 "y.tab.c" /* yacc.c:1652  */
    break;

  case 70:
#line 970 "parser.y" /* yacc.c:1652  */
    {
        ExpressionRef lhs = (yyvsp[-2].nExpression);
        ExpressionRef rhs = (yyvsp[0].nExpression);
        if (lhs->isConstExpr() && rhs->isConstExpr()) {
            (yyval.nExpression) = new StringLiteral(
                lhs->evalCastToStr() + rhs->evalCastToStr()
            );
        } else {
            (yyval.nExpression) = new ConcatString(lhs, rhs);
        }
    }
#line 2721 "y.tab.c" /* yacc.c:1652  */
    break;

  case 72:
#line 984 "parser.y" /* yacc.c:1652  */
    {
        ExpressionRef lhs = (yyvsp[-2].nExpression);
        ExpressionRef rhs = (yyvsp[0].nExpression);
        if (lhs->exprType() != INT_EXPR) {
            PARSE_ERR((yylsp[-2]), (String("Left operand of operator 'or' must be an integer expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (rhs->exprType() != INT_EXPR) {
            PARSE_ERR((yylsp[0]), (String("Right operand of operator 'or' must be an integer expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (lhs->asInt()->unitType() || lhs->asInt()->hasUnitFactorEver()) {
            PARSE_ERR((yylsp[-2]), "Units are not allowed for operands of logical operations.");
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (rhs->asInt()->unitType() || rhs->asInt()->hasUnitFactorEver()) {
            PARSE_ERR((yylsp[0]), "Units are not allowed for operands of logical operations.");
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else {
            if (lhs->asInt()->isFinal() && !rhs->asInt()->isFinal())
                PARSE_WRN((yylsp[0]), "Right operand of 'or' operation is not 'final', result will be 'final' though since left operand is 'final'.");
            else if (!lhs->asInt()->isFinal() && rhs->asInt()->isFinal())
                PARSE_WRN((yylsp[-2]), "Left operand of 'or' operation is not 'final', result will be 'final' though since right operand is 'final'.");
            (yyval.nExpression) = new Or(lhs, rhs);
        }
    }
#line 2749 "y.tab.c" /* yacc.c:1652  */
    break;

  case 73:
#line 1009 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nExpression) = (yyvsp[0].nExpression);
    }
#line 2757 "y.tab.c" /* yacc.c:1652  */
    break;

  case 74:
#line 1012 "parser.y" /* yacc.c:1652  */
    {
        ExpressionRef lhs = (yyvsp[-2].nExpression);
        ExpressionRef rhs = (yyvsp[0].nExpression);
        if (lhs->exprType() != INT_EXPR) {
            PARSE_ERR((yylsp[-2]), (String("Left operand of operator 'and' must be an integer expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (rhs->exprType() != INT_EXPR) {
            PARSE_ERR((yylsp[0]), (String("Right operand of operator 'and' must be an integer expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (lhs->asInt()->unitType() || lhs->asInt()->hasUnitFactorEver()) {
            PARSE_ERR((yylsp[-2]), "Units are not allowed for operands of logical operations.");
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (rhs->asInt()->unitType() || rhs->asInt()->hasUnitFactorEver()) {
            PARSE_ERR((yylsp[0]), "Units are not allowed for operands of logical operations.");
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else {
            if (lhs->asInt()->isFinal() && !rhs->asInt()->isFinal())
                PARSE_WRN((yylsp[0]), "Right operand of 'and' operation is not 'final', result will be 'final' though since left operand is 'final'.");
            else if (!lhs->asInt()->isFinal() && rhs->asInt()->isFinal())
                PARSE_WRN((yylsp[-2]), "Left operand of 'and' operation is not 'final', result will be 'final' though since right operand is 'final'.");
            (yyval.nExpression) = new And(lhs, rhs);
        }
    }
#line 2785 "y.tab.c" /* yacc.c:1652  */
    break;

  case 76:
#line 1038 "parser.y" /* yacc.c:1652  */
    {
        ExpressionRef lhs = (yyvsp[-2].nExpression);
        ExpressionRef rhs = (yyvsp[0].nExpression);
        if (lhs->exprType() != INT_EXPR) {
            PARSE_ERR((yylsp[-2]), (String("Left operand of bitwise operator '.or.' must be an integer expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (rhs->exprType() != INT_EXPR) {
            PARSE_ERR((yylsp[0]), (String("Right operand of bitwise operator '.or.' must be an integer expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (lhs->asInt()->unitType() || lhs->asInt()->hasUnitFactorEver()) {
            PARSE_ERR((yylsp[-2]), "Units are not allowed for operands of bitwise operations.");
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (rhs->asInt()->unitType() || rhs->asInt()->hasUnitFactorEver()) {
            PARSE_ERR((yylsp[0]), "Units are not allowed for operands of bitwise operations.");
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else {
            if (lhs->asInt()->isFinal() && !rhs->asInt()->isFinal())
                PARSE_WRN((yylsp[0]), "Right operand of '.or.' operation is not 'final', result will be 'final' though since left operand is 'final'.");
            else if (!lhs->asInt()->isFinal() && rhs->asInt()->isFinal())
                PARSE_WRN((yylsp[-2]), "Left operand of '.or.' operation is not 'final', result will be 'final' though since right operand is 'final'.");
            (yyval.nExpression) = new BitwiseOr(lhs, rhs);
        }
    }
#line 2813 "y.tab.c" /* yacc.c:1652  */
    break;

  case 77:
#line 1063 "parser.y" /* yacc.c:1652  */
    {
        (yyval.nExpression) = (yyvsp[0].nExpression);
    }
#line 2821 "y.tab.c" /* yacc.c:1652  */
    break;

  case 78:
#line 1066 "parser.y" /* yacc.c:1652  */
    {
        ExpressionRef lhs = (yyvsp[-2].nExpression);
        ExpressionRef rhs = (yyvsp[0].nExpression);
        if (lhs->exprType() != INT_EXPR) {
            PARSE_ERR((yylsp[-2]), (String("Left operand of bitwise operator '.and.' must be an integer expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (rhs->exprType() != INT_EXPR) {
            PARSE_ERR((yylsp[0]), (String("Right operand of bitwise operator '.and.' must be an integer expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (lhs->asInt()->unitType() || lhs->asInt()->hasUnitFactorEver()) {
            PARSE_ERR((yylsp[-2]), "Units are not allowed for operands of bitwise operations.");
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (rhs->asInt()->unitType() || rhs->asInt()->hasUnitFactorEver()) {
            PARSE_ERR((yylsp[0]), "Units are not allowed for operands of bitwise operations.");
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else {
            if (lhs->asInt()->isFinal() && !rhs->asInt()->isFinal())
                PARSE_WRN((yylsp[0]), "Right operand of '.and.' operation is not 'final', result will be 'final' though since left operand is 'final'.");
            else if (!lhs->asInt()->isFinal() && rhs->asInt()->isFinal())
                PARSE_WRN((yylsp[-2]), "Left operand of '.and.' operation is not 'final', result will be 'final' though since right operand is 'final'.");
            (yyval.nExpression) = new BitwiseAnd(lhs, rhs);
        }
    }
#line 2849 "y.tab.c" /* yacc.c:1652  */
    break;

  case 80:
#line 1092 "parser.y" /* yacc.c:1652  */
    {
        ExpressionRef lhs = (yyvsp[-2].nExpression);
        ExpressionRef rhs = (yyvsp[0].nExpression);
        if (!isNumber(lhs->exprType())) {
            PARSE_ERR((yylsp[-2]), (String("Left operand of operator '<' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (!isNumber(rhs->exprType())) {
            PARSE_ERR((yylsp[0]), (String("Right operand of operator '<' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) {
            PARSE_ERR((yylsp[-1]), (String("Operands of relative operations must have same unit, left operand is ") +
                unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " +
                unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else {
            if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal())
                PARSE_WRN((yylsp[0]), "Right operand of '<' comparison is not 'final', left operand is 'final' though.");
            else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal())
                PARSE_WRN((yylsp[-2]), "Left operand of '<' comparison is not 'final', right operand is 'final' though.");
            (yyval.nExpression) = new Relation(lhs, Relation::LESS_THAN, rhs);
        }
    }
#line 2876 "y.tab.c" /* yacc.c:1652  */
    break;

  case 81:
#line 1114 "parser.y" /* yacc.c:1652  */
    {
        ExpressionRef lhs = (yyvsp[-2].nExpression);
        ExpressionRef rhs = (yyvsp[0].nExpression);
        if (!isNumber(lhs->exprType())) {
            PARSE_ERR((yylsp[-2]), (String("Left operand of operator '>' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (!isNumber(rhs->exprType())) {
            PARSE_ERR((yylsp[0]), (String("Right operand of operator '>' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) {
            PARSE_ERR((yylsp[-1]), (String("Operands of relative operations must have same unit, left operand is ") +
                unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " +
                unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else {
            if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal())
                PARSE_WRN((yylsp[0]), "Right operand of '>' comparison is not 'final', left operand is 'final' though.");
            else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal())
                PARSE_WRN((yylsp[-2]), "Left operand of '>' comparison is not 'final', right operand is 'final' though.");
            (yyval.nExpression) = new Relation(lhs, Relation::GREATER_THAN, rhs);
        }
    }
#line 2903 "y.tab.c" /* yacc.c:1652  */
    break;

  case 82:
#line 1136 "parser.y" /* yacc.c:1652  */
    {
        ExpressionRef lhs = (yyvsp[-2].nExpression);
        ExpressionRef rhs = (yyvsp[0].nExpression);
        if (!isNumber(lhs->exprType())) {
            PARSE_ERR((yylsp[-2]), (String("Left operand of operator '<=' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (!isNumber(rhs->exprType())) {
            PARSE_ERR((yylsp[0]), (String("Right operand of operator '<=' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) {
            PARSE_ERR((yylsp[-1]), (String("Operands of relative operations must have same unit, left operand is ") +
                unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " +
                unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else {
            if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal())
                PARSE_WRN((yylsp[0]), "Right operand of '<=' comparison is not 'final', left operand is 'final' though.");
            else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal())
                PARSE_WRN((yylsp[-2]), "Left operand of '<=' comparison is not 'final', right operand is 'final' though.");
            (yyval.nExpression) = new Relation(lhs, Relation::LESS_OR_EQUAL, rhs);
        }
    }
#line 2930 "y.tab.c" /* yacc.c:1652  */
    break;

  case 83:
#line 1158 "parser.y" /* yacc.c:1652  */
    {
        ExpressionRef lhs = (yyvsp[-2].nExpression);
        ExpressionRef rhs = (yyvsp[0].nExpression);
        if (!isNumber(lhs->exprType())) {
            PARSE_ERR((yylsp[-2]), (String("Left operand of operator '>=' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (!isNumber(rhs->exprType())) {
            PARSE_ERR((yylsp[0]), (String("Right operand of operator '>=' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) {
            PARSE_ERR((yylsp[-1]), (String("Operands of relative operations must have same unit, left operand is ") +
                unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " +
                unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else {
            if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal())
                PARSE_WRN((yylsp[0]), "Right operand of '>=' comparison is not 'final', left operand is 'final' though.");
            else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal())
                PARSE_WRN((yylsp[-2]), "Left operand of '>=' comparison is not 'final', right operand is 'final' though.");
            (yyval.nExpression) = new Relation(lhs, Relation::GREATER_OR_EQUAL, rhs);
        }
    }
#line 2957 "y.tab.c" /* yacc.c:1652  */
    break;

  case 84:
#line 1180 "parser.y" /* yacc.c:1652  */
    {
        ExpressionRef lhs = (yyvsp[-2].nExpression);
        ExpressionRef rhs = (yyvsp[0].nExpression);
        if (!isNumber(lhs->exprType())) {
            PARSE_ERR((yylsp[-2]), (String("Left operand of operator '=' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (!isNumber(rhs->exprType())) {
            PARSE_ERR((yylsp[0]), (String("Right operand of operator '=' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) {
            PARSE_ERR((yylsp[-1]), (String("Operands of relative operations must have same unit, left operand is ") +
                unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " +
                unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else {
            if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal())
                PARSE_WRN((yylsp[0]), "Right operand of '=' comparison is not 'final', left operand is 'final' though.");
            else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal())
                PARSE_WRN((yylsp[-2]), "Left operand of '=' comparison is not 'final', right operand is 'final' though.");
            (yyval.nExpression) = new Relation(lhs, Relation::EQUAL, rhs);
        }
    }
#line 2984 "y.tab.c" /* yacc.c:1652  */
    break;

  case 85:
#line 1202 "parser.y" /* yacc.c:1652  */
    {
        ExpressionRef lhs = (yyvsp[-2].nExpression);
        ExpressionRef rhs = (yyvsp[0].nExpression);
        if (!isNumber(lhs->exprType())) {
            PARSE_ERR((yylsp[-2]), (String("Left operand of operator '#' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (!isNumber(rhs->exprType())) {
            PARSE_ERR((yylsp[0]), (String("Right operand of operator '#' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) {
            PARSE_ERR((yylsp[-1]), (String("Operands of relative operations must have same unit, left operand is ") +
                unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " +
                unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else {
            if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal())
                PARSE_WRN((yylsp[0]), "Right operand of '#' comparison is not 'final', left operand is 'final' though.");
            else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal())
                PARSE_WRN((yylsp[-2]), "Left operand of '#' comparison is not 'final', right operand is 'final' though.");
            (yyval.nExpression) = new Relation(lhs, Relation::NOT_EQUAL, rhs);
        }
    }
#line 3011 "y.tab.c" /* yacc.c:1652  */
    break;

  case 87:
#line 1227 "parser.y" /* yacc.c:1652  */
    {
        ExpressionRef lhs = (yyvsp[-2].nExpression);
        ExpressionRef rhs = (yyvsp[0].nExpression);
        if (!isNumber(lhs->exprType())) {
            PARSE_ERR((yylsp[-2]), (String("Left operand of operator '+' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (!isNumber(rhs->exprType())) {
            PARSE_ERR((yylsp[-2]), (String("Right operand of operator '+' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (lhs->exprType() != rhs->exprType()) {
            PARSE_ERR((yylsp[-1]), (String("Operands of operator '+' must have same type; left operand is ") +
                      typeStr(lhs->exprType()) + " and right operand is " + typeStr(rhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) {
            PARSE_ERR((yylsp[-1]), (String("Operands of '+' operations must have same unit, left operand is ") +
                unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " +
                unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else {
            if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal())
                PARSE_WRN((yylsp[0]), "Right operand of '+' operation is not 'final', result will be 'final' though since left operand is 'final'.");
            else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal())
                PARSE_WRN((yylsp[-2]), "Left operand of '+' operation is not 'final', result will be 'final' though since right operand is 'final'.");
            (yyval.nExpression) = new Add(lhs,rhs);
        }
    }
#line 3042 "y.tab.c" /* yacc.c:1652  */
    break;

  case 88:
#line 1253 "parser.y" /* yacc.c:1652  */
    {
        ExpressionRef lhs = (yyvsp[-2].nExpression);
        ExpressionRef rhs = (yyvsp[0].nExpression);
        if (!isNumber(lhs->exprType())) {
            PARSE_ERR((yylsp[-2]), (String("Left operand of operator '-' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (!isNumber(rhs->exprType())) {
            PARSE_ERR((yylsp[-2]), (String("Right operand of operator '-' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (lhs->exprType() != rhs->exprType()) {
            PARSE_ERR((yylsp[-1]), (String("Operands of operator '-' must have same type; left operand is ") +
                      typeStr(lhs->exprType()) + " and right operand is " + typeStr(rhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) {
            PARSE_ERR((yylsp[-1]), (String("Operands of '-' operations must have same unit, left operand is ") +
                unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " +
                unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else {
            if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal())
                PARSE_WRN((yylsp[0]), "Right operand of '-' operation is not 'final', result will be 'final' though since left operand is 'final'.");
            else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal())
                PARSE_WRN((yylsp[-2]), "Left operand of '-' operation is not 'final', result will be 'final' though since right operand is 'final'.");
            (yyval.nExpression) = new Sub(lhs,rhs);
        }
    }
#line 3073 "y.tab.c" /* yacc.c:1652  */
    break;

  case 90:
#line 1282 "parser.y" /* yacc.c:1652  */
    {
        ExpressionRef lhs = (yyvsp[-2].nExpression);
        ExpressionRef rhs = (yyvsp[0].nExpression);
        if (!isNumber(lhs->exprType())) {
            PARSE_ERR((yylsp[-2]), (String("Left operand of operator '*' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (!isNumber(rhs->exprType())) {
            PARSE_ERR((yylsp[-2]), (String("Right operand of operator '*' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (lhs->asNumber()->unitType() && rhs->asNumber()->unitType()) {
            PARSE_ERR((yylsp[-1]), (String("Only one operand of operator '*' may have a unit type, left operand is ") +
                unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " +
                unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (lhs->exprType() != rhs->exprType()) {
            PARSE_ERR((yylsp[-1]), (String("Operands of operator '*' must have same type; left operand is ") +
                      typeStr(lhs->exprType()) + " and right operand is " + typeStr(rhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else {
            if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal())
                PARSE_WRN((yylsp[0]), "Right operand of '*' operation is not 'final', result will be 'final' though since left operand is 'final'.");
            else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal())
                PARSE_WRN((yylsp[-2]), "Left operand of '*' operation is not 'final', result will be 'final' though since right operand is 'final'.");
            (yyval.nExpression) = new Mul(lhs,rhs);
        }
    }
#line 3104 "y.tab.c" /* yacc.c:1652  */
    break;

  case 91:
#line 1308 "parser.y" /* yacc.c:1652  */
    {
        ExpressionRef lhs = (yyvsp[-2].nExpression);
        ExpressionRef rhs = (yyvsp[0].nExpression);
        if (!isNumber(lhs->exprType())) {
            PARSE_ERR((yylsp[-2]), (String("Left operand of operator '/' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (!isNumber(rhs->exprType())) {
            PARSE_ERR((yylsp[-2]), (String("Right operand of operator '/' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (lhs->asNumber()->unitType() && rhs->asNumber()->unitType() &&
                   lhs->asNumber()->unitType() != rhs->asNumber()->unitType())
        {
            PARSE_ERR((yylsp[-1]), (String("Operands of operator '/' with two different unit types, left operand is ") +
                unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " +
                unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (!lhs->asNumber()->unitType() && rhs->asNumber()->unitType()) {
            PARSE_ERR((yylsp[0]), ("Dividing left operand without any unit type by right operand with unit type (" +
                unitTypeStr(rhs->asNumber()->unitType()) + ") is not possible.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (lhs->exprType() != rhs->exprType()) {
            PARSE_ERR((yylsp[-1]), (String("Operands of operator '/' must have same type; left operand is ") +
                      typeStr(lhs->exprType()) + " and right operand is " + typeStr(rhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else {
            if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal())
                PARSE_WRN((yylsp[0]), "Right operand of '/' operation is not 'final', result will be 'final' though since left operand is 'final'.");
            else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal())
                PARSE_WRN((yylsp[-2]), "Left operand of '/' operation is not 'final', result will be 'final' though since right operand is 'final'.");
            (yyval.nExpression) = new Div(lhs,rhs);
        }
    }
#line 3141 "y.tab.c" /* yacc.c:1652  */
    break;

  case 92:
#line 1340 "parser.y" /* yacc.c:1652  */
    {
        ExpressionRef lhs = (yyvsp[-2].nExpression);
        ExpressionRef rhs = (yyvsp[0].nExpression);
        if (lhs->exprType() != INT_EXPR) {
            PARSE_ERR((yylsp[-2]), (String("Left operand of modulo operator must be an integer expression, is ") + typeStr(lhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else if (rhs->exprType() != INT_EXPR) {
            PARSE_ERR((yylsp[0]), (String("Right operand of modulo operator must be an integer expression, is ") + typeStr(rhs->exprType()) + " though.").c_str());
            (yyval.nExpression) = new IntLiteral({ .value = 0 });
        } else {
            if (lhs->asInt()->unitType() || lhs->asInt()->hasUnitFactorEver())
                PARSE_ERR((yylsp[-2]), "Operands of modulo operator must not use any unit.");
            if (rhs->asInt()->unitType() || rhs->asInt()->hasUnitFactorEver())
                PARSE_ERR((yylsp[0]), "Operands of modulo operator must not use any unit.");
            if (lhs->asInt()->isFinal() && !rhs->asInt()->isFinal())
                PARSE_WRN((yylsp[0]), "Right operand of 'mod' operation is not 'final', result will be 'final' though since left operand is 'final'.");
            else if (!lhs->asInt()->isFinal() && rhs->asInt()->isFinal())
                PARSE_WRN((yylsp[-2]), "Left operand of 'mod' operation is not 'final', result will be 'final' though since right operand is 'final'.");
            (yyval.nExpression) = new Mod(lhs,rhs);
        }
    }
#line 3167 "y.tab.c" /* yacc.c:1652  */
    break;


#line 3171 "y.tab.c" /* yacc.c:1652  */
      default: break;
    }
  /* User semantic actions sometimes alter yychar, and that requires
     that yytoken be updated with the new translation.  We take the
     approach of translating immediately before every use of yytoken.
     One alternative is translating here after every semantic action,
     but that translation would be missed if the semantic action invokes
     YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
     if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
     incorrect destructor might then be invoked immediately.  In the
     case of YYERROR or YYBACKUP, subsequent parser actions might lead
     to an incorrect destructor call or verbose syntax error message
     before the lookahead is translated.  */
  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);

  YYPOPSTACK (yylen);
  yylen = 0;
  YY_STACK_PRINT (yyss, yyssp);

  *++yyvsp = yyval;
  *++yylsp = yyloc;

  /* Now 'shift' the result of the reduction.  Determine what state
     that goes to, based on the state we popped back to and the rule
     number reduced by.  */
  {
    const int yylhs = yyr1[yyn] - YYNTOKENS;
    const int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }

  goto yynewstate;


/*--------------------------------------.
| yyerrlab -- here on detecting error.  |
`--------------------------------------*/
yyerrlab:
  /* Make sure we have latest lookahead translation.  See comments at
     user semantic actions for why this is necessary.  */
  yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);

  /* If not already recovering from an error, report this error.  */
  if (!yyerrstatus)
    {
      ++yynerrs;
#if ! YYERROR_VERBOSE
      yyerror (&yylloc, context, YY_("syntax error"));
#else
# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
                                        yyssp, yytoken)
      {
        char const *yymsgp = YY_("syntax error");
        int yysyntax_error_status;
        yysyntax_error_status = YYSYNTAX_ERROR;
        if (yysyntax_error_status == 0)
          yymsgp = yymsg;
        else if (yysyntax_error_status == 1)
          {
            if (yymsg != yymsgbuf)
              YYSTACK_FREE (yymsg);
            yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
            if (!yymsg)
              {
                yymsg = yymsgbuf;
                yymsg_alloc = sizeof yymsgbuf;
                yysyntax_error_status = 2;
              }
            else
              {
                yysyntax_error_status = YYSYNTAX_ERROR;
                yymsgp = yymsg;
              }
          }
        yyerror (&yylloc, context, yymsgp);
        if (yysyntax_error_status == 2)
          goto yyexhaustedlab;
      }
# undef YYSYNTAX_ERROR
#endif
    }

  yyerror_range[1] = yylloc;

  if (yyerrstatus == 3)
    {
      /* If just tried and failed to reuse lookahead token after an
         error, discard it.  */

      if (yychar <= YYEOF)
        {
          /* Return failure if at end of input.  */
          if (yychar == YYEOF)
            YYABORT;
        }
      else
        {
          yydestruct ("Error: discarding",
                      yytoken, &yylval, &yylloc, context);
          yychar = YYEMPTY;
        }
    }

  /* Else will try to reuse lookahead token after shifting the error
     token.  */
  goto yyerrlab1;


/*---------------------------------------------------.
| yyerrorlab -- error raised explicitly by YYERROR.  |
`---------------------------------------------------*/
yyerrorlab:
  /* Pacify compilers when the user code never invokes YYERROR and the
     label yyerrorlab therefore never appears in user code.  */
  if (0)
    YYERROR;

  /* Do not reclaim the symbols of the rule whose action triggered
     this YYERROR.  */
  YYPOPSTACK (yylen);
  yylen = 0;
  YY_STACK_PRINT (yyss, yyssp);
  yystate = *yyssp;
  goto yyerrlab1;


/*-------------------------------------------------------------.
| yyerrlab1 -- common code for both syntax error and YYERROR.  |
`-------------------------------------------------------------*/
yyerrlab1:
  yyerrstatus = 3;      /* Each real token shifted decrements this.  */

  for (;;)
    {
      yyn = yypact[yystate];
      if (!yypact_value_is_default (yyn))
        {
          yyn += YYTERROR;
          if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
            {
              yyn = yytable[yyn];
              if (0 < yyn)
                break;
            }
        }

      /* Pop the current state because it cannot handle the error token.  */
      if (yyssp == yyss)
        YYABORT;

      yyerror_range[1] = *yylsp;
      yydestruct ("Error: popping",
                  yystos[yystate], yyvsp, yylsp, context);
      YYPOPSTACK (1);
      yystate = *yyssp;
      YY_STACK_PRINT (yyss, yyssp);
    }

  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  *++yyvsp = yylval;
  YY_IGNORE_MAYBE_UNINITIALIZED_END

  yyerror_range[2] = yylloc;
  /* Using YYLLOC is tempting, but would change the location of
     the lookahead.  YYLOC is available though.  */
  YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
  *++yylsp = yyloc;

  /* Shift the error token.  */
  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);

  yystate = yyn;
  goto yynewstate;


/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here.  |
`-------------------------------------*/
yyacceptlab:
  yyresult = 0;
  goto yyreturn;


/*-----------------------------------.
| yyabortlab -- YYABORT comes here.  |
`-----------------------------------*/
yyabortlab:
  yyresult = 1;
  goto yyreturn;


#if !defined yyoverflow || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here.  |
`-------------------------------------------------*/
yyexhaustedlab:
  yyerror (&yylloc, context, YY_("memory exhausted"));
  yyresult = 2;
  /* Fall through.  */
#endif


/*-----------------------------------------------------.
| yyreturn -- parsing is finished, return the result.  |
`-----------------------------------------------------*/
yyreturn:
  if (yychar != YYEMPTY)
    {
      /* Make sure we have latest lookahead translation.  See comments at
         user semantic actions for why this is necessary.  */
      yytoken = YYTRANSLATE (yychar);
      yydestruct ("Cleanup: discarding lookahead",
                  yytoken, &yylval, &yylloc, context);
    }
  /* Do not reclaim the symbols of the rule whose action triggered
     this YYABORT or YYACCEPT.  */
  YYPOPSTACK (yylen);
  YY_STACK_PRINT (yyss, yyssp);
  while (yyssp != yyss)
    {
      yydestruct ("Cleanup: popping",
                  yystos[*yyssp], yyvsp, yylsp, context);
      YYPOPSTACK (1);
    }
#ifndef yyoverflow
  if (yyss != yyssa)
    YYSTACK_FREE (yyss);
#endif
#if YYERROR_VERBOSE
  if (yymsg != yymsgbuf)
    YYSTACK_FREE (yymsg);
#endif
  return yyresult;
}
#line 1362 "parser.y" /* yacc.c:1918  */


void InstrScript_error(YYLTYPE* locp, LinuxSampler::ParserContext* context, const char* err) {
    //fprintf(stderr, "%d: %s\n", locp->first_line, err);
    context->addErr(locp->first_line, locp->last_line, locp->first_column+1,
                    locp->last_column+1, locp->first_byte, locp->length_bytes,
                    err);
}

void InstrScript_warning(YYLTYPE* locp, LinuxSampler::ParserContext* context, const char* txt) {
    //fprintf(stderr, "WRN %d: %s\n", locp->first_line, txt);
    context->addWrn(locp->first_line, locp->last_line, locp->first_column+1,
                    locp->last_column+1, locp->first_byte, locp->length_bytes,
                    txt);
}

/// Custom implementation of yytnamerr() to ensure quotation is always stripped from token names before printing them to error messages.
int InstrScript_tnamerr(char* yyres, const char* yystr) {
  if (*yystr == '"') {
      int yyn = 0;
      char const *yyp = yystr;
      for (;;)
        switch (*++yyp)
          {
/*
          case '\'':
          case ',':
            goto do_not_strip_quotes;

          case '\\':
            if (*++yyp != '\\')
              goto do_not_strip_quotes;
*/
            /* Fall through.  */
          default:
            if (yyres)
              yyres[yyn] = *yyp;
            yyn++;
            break;

          case '"':
            if (yyres)
              yyres[yyn] = '\0';
            return yyn;
          }
/*
    do_not_strip_quotes: ;
*/
    }

  if (! yyres)
    return (int) yystrlen (yystr);

  return int( yystpcpy (yyres, yystr) - yyres );
}
