Statistics
| Branch: | Tag: | Revision:

one / src / vm / vm_var_syntax.cc @ 4b66f92b

History | View | Annotate | Download (59.3 KB)

1
/* A Bison parser, made by GNU Bison 3.0.2.  */
2

    
3
/* Bison implementation for Yacc-like parsers in C
4

5
   Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
6

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

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

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

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

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

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

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

    
43
/* Identify Bison output.  */
44
#define YYBISON 1
45

    
46
/* Bison version.  */
47
#define YYBISON_VERSION "3.0.2"
48

    
49
/* Skeleton name.  */
50
#define YYSKELETON_NAME "yacc.c"
51

    
52
/* Pure parsers.  */
53
#define YYPURE 1
54

    
55
/* Push parsers.  */
56
#define YYPUSH 0
57

    
58
/* Pull parsers.  */
59
#define YYPULL 1
60

    
61

    
62
/* Substitute the variable and function names.  */
63
#define yyparse         vm_var__parse
64
#define yylex           vm_var__lex
65
#define yyerror         vm_var__error
66
#define yydebug         vm_var__debug
67
#define yynerrs         vm_var__nerrs
68

    
69

    
70
/* Copy the first part of user declarations.  */
71
#line 17 "vm_var_syntax.y" /* yacc.c:339  */
72

    
73
#include <iostream>
74
#include <sstream>
75
#include <string>
76
#include <map>
77
#include <algorithm>
78

    
79
#include <ctype.h>
80
#include <string.h>
81

    
82
#include "vm_var_syntax.h"
83
#include "VirtualMachinePool.h"
84
#include "VirtualMachine.h"
85
#include "Nebula.h"
86

    
87
#define vm_var__lex vm_var_lex
88

    
89
#define YYERROR_VERBOSE
90
#define VM_VAR_TO_UPPER(S) transform (S.begin(),S.end(),S.begin(), \
91
(int(*)(int))toupper)
92

    
93
extern "C"
94
{
95
    #include "mem_collector.h"
96

    
97
    void vm_var__error(
98
        YYLTYPE *        llocp,
99
        mem_collector *  mc,
100
        VirtualMachine * vm,
101
        ostringstream *  parsed,
102
        char **          errmsg,
103
        const char *     str);
104

    
105
    int vm_var__lex (YYSTYPE *lvalp, YYLTYPE *llocp, mem_collector * mc);
106

    
107
    int vm_var__parse (mem_collector *  mc,
108
                       VirtualMachine * vm,
109
                       ostringstream *  parsed,
110
                       char **          errmsg);
111

    
112
    int vm_var_parse (VirtualMachine * vm,
113
                      ostringstream *  parsed,
114
                      char **          errmsg)
115
    {
116
        mem_collector mc;
117
        int           rc;
118

    
119
        mem_collector_init(&mc);
120

    
121
        rc = vm_var__parse(&mc, vm, parsed, errmsg);
122

    
123
        mem_collector_cleanup(&mc);
124

    
125
        return rc;
126
    }
127
}
128

    
129
/* -------------------------------------------------------------------------- */
130
/* -------------------------------------------------------------------------- */
131

    
132
void get_image_attribute(VirtualMachine * vm,
133
                         const string&    attr_name,
134
                         const string&    img_name,
135
                         const string&    img_value,
136
                         string&          attr_value)
137
{
138
    Nebula& nd = Nebula::instance();
139

    
140
    ImagePool * ipool = nd.get_ipool();
141
    Image  *    img;
142
    int         iid = -1;
143

    
144
    int num;
145
    vector<const Attribute *> attrs;
146
    const VectorAttribute *   disk;
147

    
148
    attr_value.clear();
149

    
150
    if ( img_name.empty() || (img_name!="IMAGE" && img_name!="IMAGE_ID") )
151
    {
152
        return;
153
    }
154

    
155
    // ----------------------------------------------
156
    // Check that the image is in the template, so
157
    // are sure that we can access the image template
158
    // ----------------------------------------------
159
    num = vm->get_template_attribute("DISK",attrs);
160

    
161
    for (int i=0; i < num ;i++)
162
    {
163
        disk = dynamic_cast<const VectorAttribute *>(attrs[i]);
164

    
165
        if ( disk == 0 )
166
        {
167
            continue;
168
        }
169

    
170
        if ( disk->vector_value(img_name.c_str()) == img_value )
171
        {
172
            string        iid_str = disk->vector_value("IMAGE_ID");
173
            istringstream iss(iid_str);
174

    
175
            iss >> iid;
176

    
177
            if (iss.fail())
178
            {
179
                iid = -1;
180
            }
181

    
182
            break;
183
        }
184
    }
185

    
186
    if (iid == -1)
187
    {
188
        return;
189
    }
190

    
191
    // ----------------------------------------------
192
    // Get the attribute template from the image
193
    // ----------------------------------------------
194
    img = ipool->get(iid, true);
195

    
196
    if ( img == 0 )
197
    {
198
        return;
199
    }
200

    
201
    if (attr_name == "TEMPLATE")
202
    {
203
        attr_value = img->to_xml64(attr_value);
204
    }
205
    else
206
    {
207
        img->get_template_attribute(attr_name.c_str(),attr_value);
208
    }
209

    
210
    img->unlock();
211
}
212

    
213
/* -------------------------------------------------------------------------- */
214
/* -------------------------------------------------------------------------- */
215

    
216
void get_network_attribute(VirtualMachine * vm,
217
                           const string&    attr_name,
218
                           const string&    net_name,
219
                           const string&    net_value,
220
                           string&          attr_value)
221
{
222
    Nebula& nd = Nebula::instance();
223

    
224
    VirtualNetworkPool * vnpool = nd.get_vnpool();
225
    VirtualNetwork  *    vn;
226
    int                  ar_id, vnet_id = -1;
227

    
228
    int num;
229
    vector<const Attribute *> attrs;
230
    const VectorAttribute *   net;
231

    
232
    attr_value.clear();
233

    
234
    if ( net_name.empty() ||
235
        (net_name!="NETWORK" && net_name!="NETWORK_ID" && net_name!="NIC_ID"))
236
    {
237
        return;
238
    }
239

    
240
    // ----------------------------------------------
241
    // Check that the network is in the template, so
242
    // are sure that we can access its template
243
    // ----------------------------------------------
244
    num = vm->get_template_attribute("NIC",attrs);
245

    
246
    for (int i=0; i < num ;i++)
247
    {
248
        net = dynamic_cast<const VectorAttribute *>(attrs[i]);
249

    
250
        if ( net == 0 )
251
        {
252
            continue;
253
        }
254

    
255
        if ( net->vector_value(net_name.c_str()) == net_value )
256
        {
257
            if (net->vector_value("NETWORK_ID", vnet_id) != 0)
258
            {
259
                vnet_id = -1;
260
            }
261

    
262
            if (net->vector_value("AR_ID", ar_id) != 0)
263
            {
264
                vnet_id = -1;
265
            }
266

    
267
            break;
268
        }
269
    }
270

    
271
    if (vnet_id == -1)
272
    {
273
        return;
274
    }
275

    
276
    // ----------------------------------------------
277
    // Get the attribute template from the image
278
    // ----------------------------------------------
279
    vn = vnpool->get(vnet_id, true);
280

    
281
    if ( vn == 0 )
282
    {
283
        return;
284
    }
285

    
286
    if (attr_name == "TEMPLATE")
287
    {
288
        attr_value = vn->to_xml64(attr_value);
289
    }
290
    else
291
    {
292
        vn->get_template_attribute(attr_name.c_str(), attr_value, ar_id);
293
    }
294

    
295
    vn->unlock();
296
}
297

    
298
/* -------------------------------------------------------------------------- */
299
/* -------------------------------------------------------------------------- */
300

    
301
void get_user_attribute(VirtualMachine * vm,
302
                        const string&    attr_name,
303
                        string&          attr_value)
304
{
305
    Nebula& nd = Nebula::instance();
306

    
307
    UserPool * upool = nd.get_upool();
308
    User *     user;
309

    
310
    attr_value.clear();
311

    
312
    user = upool->get(vm->get_uid(), true);
313

    
314
    if ( user == 0 )
315
    {
316
        return;
317
    }
318

    
319
    if (attr_name == "TEMPLATE")
320
    {
321
        attr_value = user->to_xml64(attr_value);
322
    }
323
    else
324
    {
325
        user->get_template_attribute(attr_name.c_str(),attr_value);
326
    }
327

    
328
    user->unlock();
329
}
330

    
331
/* -------------------------------------------------------------------------- */
332
/* -------------------------------------------------------------------------- */
333

    
334
void insert_single(VirtualMachine * vm,
335
                   ostringstream&   parsed,
336
                   const string&    name)
337
{
338
    string value = "";
339

    
340
    if (name == "TEMPLATE")
341
    {
342
        vm->to_xml64(value);
343
    }
344
    else if (name == "UID")
345
    {
346
        parsed << vm->get_uid();
347
    }
348
    else if (name == "UNAME")
349
    {
350
        parsed << vm->get_uname();
351
    }
352
    else if (name == "GID")
353
    {
354
        parsed << vm->get_gid();
355
    }
356
    else if (name == "GNAME")
357
    {
358
        parsed << vm->get_gname();
359
    }
360
    else if (name == "NAME")
361
    {
362

    
363
        parsed << vm->get_name();
364
    }
365
    else
366
    {
367

    
368
        vm->get_template_attribute(name.c_str(),value);
369

    
370
        if (value.empty())
371
        {
372
            vm->get_user_template_attribute(name.c_str(),value);
373
        }
374
    }
375

    
376
    if (!value.empty())
377
    {
378
        parsed << value;
379
    }
380
}
381

    
382
/* -------------------------------------------------------------------------- */
383
/* -------------------------------------------------------------------------- */
384

    
385
void insert_vector(VirtualMachine * vm,
386
                   ostringstream&   parsed,
387
                   const string&    name,
388
                   const string&    vname,
389
                   const string&    vvar,
390
                   const string&    vval)
391

    
392
{
393
    vector<const Attribute*> values;
394
    const VectorAttribute *  vattr = 0;
395

    
396
    int    num;
397

    
398
    if (name == "NETWORK")
399
    {
400
        string value;
401

    
402
        get_network_attribute(vm,vname,vvar,vval,value);
403

    
404
        if (!value.empty())
405
        {
406
            parsed << value;
407
        }
408

    
409
        return;
410
    }
411
    else if (name == "IMAGE")
412
    {
413
        string value;
414

    
415
        get_image_attribute(vm,vname,vvar,vval,value);
416

    
417
        if (!value.empty())
418
        {
419
            parsed << value;
420
        }
421

    
422
        return;
423
    }
424
    else if (name == "USER")
425
    {
426
        string value;
427

    
428
        get_user_attribute(vm, vname, value);
429

    
430
        if (!value.empty())
431
        {
432
            parsed << value;
433
        }
434

    
435
        return;
436
    }
437
    else
438
    {
439
        if ( ( num = vm->get_template_attribute(name.c_str(),values) ) <= 0 )
440
        {
441
            return;
442
        }
443

    
444
        if ( vvar.empty() )
445
        {
446
            vattr = dynamic_cast<const VectorAttribute *>(values[0]);
447
        }
448
        else
449
        {
450
            const VectorAttribute * tmp = 0;
451

    
452
            for (int i=0 ; i < num ; i++)
453
            {
454
                tmp = dynamic_cast<const VectorAttribute *>(values[i]);
455

    
456
                if ( tmp && ( tmp->vector_value(vvar.c_str()) == vval ))
457
                {
458
                    vattr = tmp;
459
                    break;
460
                }
461
            }
462
        }
463

    
464
        if ( vattr != 0 )
465
        {
466
            parsed << vattr->vector_value(vname.c_str());
467
        }
468
    }
469
}
470

    
471
/* -------------------------------------------------------------------------- */
472
/* -------------------------------------------------------------------------- */
473

    
474

    
475
#line 475 "vm_var_syntax.cc" /* yacc.c:339  */
476

    
477
# ifndef YY_NULLPTR
478
#  if defined __cplusplus && 201103L <= __cplusplus
479
#   define YY_NULLPTR nullptr
480
#  else
481
#   define YY_NULLPTR 0
482
#  endif
483
# endif
484

    
485
/* Enabling verbose error messages.  */
486
#ifdef YYERROR_VERBOSE
487
# undef YYERROR_VERBOSE
488
# define YYERROR_VERBOSE 1
489
#else
490
# define YYERROR_VERBOSE 0
491
#endif
492

    
493
/* In a future release of Bison, this section will be replaced
494
   by #include "vm_var_syntax.hh".  */
495
#ifndef YY_VM_VAR_VM_VAR_SYNTAX_HH_INCLUDED
496
# define YY_VM_VAR_VM_VAR_SYNTAX_HH_INCLUDED
497
/* Debug traces.  */
498
#ifndef YYDEBUG
499
# define YYDEBUG 0
500
#endif
501
#if YYDEBUG
502
extern int vm_var__debug;
503
#endif
504

    
505
/* Token type.  */
506
#ifndef YYTOKENTYPE
507
# define YYTOKENTYPE
508
  enum yytokentype
509
  {
510
    EQUAL = 258,
511
    COMMA = 259,
512
    OBRACKET = 260,
513
    CBRACKET = 261,
514
    EOA = 262,
515
    STRING = 263,
516
    VARIABLE = 264,
517
    RSTRING = 265,
518
    INTEGER = 266
519
  };
520
#endif
521

    
522
/* Value type.  */
523
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
524
typedef union YYSTYPE YYSTYPE;
525
union YYSTYPE
526
{
527
#line 427 "vm_var_syntax.y" /* yacc.c:355  */
528

    
529
    char * val_str;
530
    int    val_int;
531
    char   val_char;
532

    
533
#line 533 "vm_var_syntax.cc" /* yacc.c:355  */
534
};
535
# define YYSTYPE_IS_TRIVIAL 1
536
# define YYSTYPE_IS_DECLARED 1
537
#endif
538

    
539
/* Location type.  */
540
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
541
typedef struct YYLTYPE YYLTYPE;
542
struct YYLTYPE
543
{
544
  int first_line;
545
  int first_column;
546
  int last_line;
547
  int last_column;
548
};
549
# define YYLTYPE_IS_DECLARED 1
550
# define YYLTYPE_IS_TRIVIAL 1
551
#endif
552

    
553

    
554

    
555
int vm_var__parse (mem_collector * mc, VirtualMachine * vm, ostringstream *  parsed, char **          errmsg);
556

    
557
#endif /* !YY_VM_VAR_VM_VAR_SYNTAX_HH_INCLUDED  */
558

    
559
/* Copy the second part of user declarations.  */
560

    
561
#line 561 "vm_var_syntax.cc" /* yacc.c:358  */
562

    
563
#ifdef short
564
# undef short
565
#endif
566

    
567
#ifdef YYTYPE_UINT8
568
typedef YYTYPE_UINT8 yytype_uint8;
569
#else
570
typedef unsigned char yytype_uint8;
571
#endif
572

    
573
#ifdef YYTYPE_INT8
574
typedef YYTYPE_INT8 yytype_int8;
575
#else
576
typedef signed char yytype_int8;
577
#endif
578

    
579
#ifdef YYTYPE_UINT16
580
typedef YYTYPE_UINT16 yytype_uint16;
581
#else
582
typedef unsigned short int yytype_uint16;
583
#endif
584

    
585
#ifdef YYTYPE_INT16
586
typedef YYTYPE_INT16 yytype_int16;
587
#else
588
typedef short int yytype_int16;
589
#endif
590

    
591
#ifndef YYSIZE_T
592
# ifdef __SIZE_TYPE__
593
#  define YYSIZE_T __SIZE_TYPE__
594
# elif defined size_t
595
#  define YYSIZE_T size_t
596
# elif ! defined YYSIZE_T
597
#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
598
#  define YYSIZE_T size_t
599
# else
600
#  define YYSIZE_T unsigned int
601
# endif
602
#endif
603

    
604
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
605

    
606
#ifndef YY_
607
# if defined YYENABLE_NLS && YYENABLE_NLS
608
#  if ENABLE_NLS
609
#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
610
#   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
611
#  endif
612
# endif
613
# ifndef YY_
614
#  define YY_(Msgid) Msgid
615
# endif
616
#endif
617

    
618
#ifndef YY_ATTRIBUTE
619
# if (defined __GNUC__                                               \
620
      && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__)))  \
621
     || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
622
#  define YY_ATTRIBUTE(Spec) __attribute__(Spec)
623
# else
624
#  define YY_ATTRIBUTE(Spec) /* empty */
625
# endif
626
#endif
627

    
628
#ifndef YY_ATTRIBUTE_PURE
629
# define YY_ATTRIBUTE_PURE   YY_ATTRIBUTE ((__pure__))
630
#endif
631

    
632
#ifndef YY_ATTRIBUTE_UNUSED
633
# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
634
#endif
635

    
636
#if !defined _Noreturn \
637
     && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
638
# if defined _MSC_VER && 1200 <= _MSC_VER
639
#  define _Noreturn __declspec (noreturn)
640
# else
641
#  define _Noreturn YY_ATTRIBUTE ((__noreturn__))
642
# endif
643
#endif
644

    
645
/* Suppress unused-variable warnings by "using" E.  */
646
#if ! defined lint || defined __GNUC__
647
# define YYUSE(E) ((void) (E))
648
#else
649
# define YYUSE(E) /* empty */
650
#endif
651

    
652
#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
653
/* Suppress an incorrect diagnostic about yylval being uninitialized.  */
654
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
655
    _Pragma ("GCC diagnostic push") \
656
    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
657
    _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
658
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
659
    _Pragma ("GCC diagnostic pop")
660
#else
661
# define YY_INITIAL_VALUE(Value) Value
662
#endif
663
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
664
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
665
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
666
#endif
667
#ifndef YY_INITIAL_VALUE
668
# define YY_INITIAL_VALUE(Value) /* Nothing. */
669
#endif
670

    
671

    
672
#if ! defined yyoverflow || YYERROR_VERBOSE
673

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

    
676
# ifdef YYSTACK_USE_ALLOCA
677
#  if YYSTACK_USE_ALLOCA
678
#   ifdef __GNUC__
679
#    define YYSTACK_ALLOC __builtin_alloca
680
#   elif defined __BUILTIN_VA_ARG_INCR
681
#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
682
#   elif defined _AIX
683
#    define YYSTACK_ALLOC __alloca
684
#   elif defined _MSC_VER
685
#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
686
#    define alloca _alloca
687
#   else
688
#    define YYSTACK_ALLOC alloca
689
#    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
690
#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
691
      /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
692
#     ifndef EXIT_SUCCESS
693
#      define EXIT_SUCCESS 0
694
#     endif
695
#    endif
696
#   endif
697
#  endif
698
# endif
699

    
700
# ifdef YYSTACK_ALLOC
701
   /* Pacify GCC's 'empty if-body' warning.  */
702
#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
703
#  ifndef YYSTACK_ALLOC_MAXIMUM
704
    /* The OS might guarantee only one guard page at the bottom of the stack,
705
       and a page size can be as small as 4096 bytes.  So we cannot safely
706
       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
707
       to allow for a few compiler-allocated temporary stack slots.  */
708
#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
709
#  endif
710
# else
711
#  define YYSTACK_ALLOC YYMALLOC
712
#  define YYSTACK_FREE YYFREE
713
#  ifndef YYSTACK_ALLOC_MAXIMUM
714
#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
715
#  endif
716
#  if (defined __cplusplus && ! defined EXIT_SUCCESS \
717
       && ! ((defined YYMALLOC || defined malloc) \
718
             && (defined YYFREE || defined free)))
719
#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
720
#   ifndef EXIT_SUCCESS
721
#    define EXIT_SUCCESS 0
722
#   endif
723
#  endif
724
#  ifndef YYMALLOC
725
#   define YYMALLOC malloc
726
#   if ! defined malloc && ! defined EXIT_SUCCESS
727
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
728
#   endif
729
#  endif
730
#  ifndef YYFREE
731
#   define YYFREE free
732
#   if ! defined free && ! defined EXIT_SUCCESS
733
void free (void *); /* INFRINGES ON USER NAME SPACE */
734
#   endif
735
#  endif
736
# endif
737
#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
738

    
739

    
740
#if (! defined yyoverflow \
741
     && (! defined __cplusplus \
742
         || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
743
             && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
744

    
745
/* A type that is properly aligned for any stack member.  */
746
union yyalloc
747
{
748
  yytype_int16 yyss_alloc;
749
  YYSTYPE yyvs_alloc;
750
  YYLTYPE yyls_alloc;
751
};
752

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

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

    
762
# define YYCOPY_NEEDED 1
763

    
764
/* Relocate STACK from its old location to the new one.  The
765
   local variables YYSIZE and YYSTACKSIZE give the old and new number of
766
   elements in the stack, and YYPTR gives the new location of the
767
   stack.  Advance YYPTR to a properly aligned location for the next
768
   stack.  */
769
# define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
770
    do                                                                  \
771
      {                                                                 \
772
        YYSIZE_T yynewbytes;                                            \
773
        YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
774
        Stack = &yyptr->Stack_alloc;                                    \
775
        yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
776
        yyptr += yynewbytes / sizeof (*yyptr);                          \
777
      }                                                                 \
778
    while (0)
779

    
780
#endif
781

    
782
#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
783
/* Copy COUNT objects from SRC to DST.  The source and destination do
784
   not overlap.  */
785
# ifndef YYCOPY
786
#  if defined __GNUC__ && 1 < __GNUC__
787
#   define YYCOPY(Dst, Src, Count) \
788
      __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
789
#  else
790
#   define YYCOPY(Dst, Src, Count)              \
791
      do                                        \
792
        {                                       \
793
          YYSIZE_T yyi;                         \
794
          for (yyi = 0; yyi < (Count); yyi++)   \
795
            (Dst)[yyi] = (Src)[yyi];            \
796
        }                                       \
797
      while (0)
798
#  endif
799
# endif
800
#endif /* !YYCOPY_NEEDED */
801

    
802
/* YYFINAL -- State number of the termination state.  */
803
#define YYFINAL  7
804
/* YYLAST -- Last index in YYTABLE.  */
805
#define YYLAST   18
806

    
807
/* YYNTOKENS -- Number of terminals.  */
808
#define YYNTOKENS  12
809
/* YYNNTS -- Number of nonterminals.  */
810
#define YYNNTS  3
811
/* YYNRULES -- Number of rules.  */
812
#define YYNRULES  7
813
/* YYNSTATES -- Number of states.  */
814
#define YYNSTATES  18
815

    
816
/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
817
   by yylex, with out-of-bounds checking.  */
818
#define YYUNDEFTOK  2
819
#define YYMAXUTOK   266
820

    
821
#define YYTRANSLATE(YYX)                                                \
822
  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
823

    
824
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
825
   as returned by yylex, without out-of-bounds checking.  */
826
static const yytype_uint8 yytranslate[] =
827
{
828
       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
829
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
830
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
831
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
832
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
833
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
834
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
835
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
836
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
837
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
838
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
839
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
840
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
841
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
842
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
843
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
844
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
845
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
846
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
847
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
848
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
849
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
850
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
851
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
852
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
853
       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
854
       5,     6,     7,     8,     9,    10,    11
855
};
856

    
857
#if YYDEBUG
858
  /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
859
static const yytype_uint16 yyrline[] =
860
{
861
       0,   451,   451,   452,   455,   459,   472,   487
862
};
863
#endif
864

    
865
#if YYDEBUG || YYERROR_VERBOSE || 0
866
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
867
   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
868
static const char *const yytname[] =
869
{
870
  "$end", "error", "$undefined", "EQUAL", "COMMA", "OBRACKET", "CBRACKET",
871
  "EOA", "STRING", "VARIABLE", "RSTRING", "INTEGER", "$accept",
872
  "vm_string", "vm_variable", YY_NULLPTR
873
};
874
#endif
875

    
876
# ifdef YYPRINT
877
/* YYTOKNUM[NUM] -- (External) token number corresponding to the
878
   (internal) symbol number NUM (which must be that of a token).  */
879
static const yytype_uint16 yytoknum[] =
880
{
881
       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
882
     265,   266
883
};
884
# endif
885

    
886
#define YYPACT_NINF -5
887

    
888
#define yypact_value_is_default(Yystate) \
889
  (!!((Yystate) == (-5)))
890

    
891
#define YYTABLE_NINF -1
892

    
893
#define yytable_value_is_error(Yytable_value) \
894
  0
895

    
896
  /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
897
     STATE-NUM.  */
898
static const yytype_int8 yypact[] =
899
{
900
      -3,    -4,    -5,     0,    -5,    -1,    -5,    -5,    -5,    -2,
901
       2,     5,    10,    -5,     6,     9,    11,    -5
902
};
903

    
904
  /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
905
     Performed when YYTABLE does not specify something else to do.  Zero
906
     means the default is an error.  */
907
static const yytype_uint8 yydefact[] =
908
{
909
       0,     0,     4,     0,     2,     0,     5,     1,     3,     0,
910
       0,     0,     0,     6,     0,     0,     0,     7
911
};
912

    
913
  /* YYPGOTO[NTERM-NUM].  */
914
static const yytype_int8 yypgoto[] =
915
{
916
      -5,    -5,    13
917
};
918

    
919
  /* YYDEFGOTO[NTERM-NUM].  */
920
static const yytype_int8 yydefgoto[] =
921
{
922
      -1,     3,     4
923
};
924

    
925
  /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
926
     positive, shift that token.  If negative, reduce the rule whose
927
     number is the opposite.  If YYTABLE_NINF, syntax error.  */
928
static const yytype_uint8 yytable[] =
929
{
930
       7,     5,    10,     6,    11,     0,     1,     2,     9,     1,
931
       2,    12,    13,    14,    15,    16,     8,     0,    17
932
};
933

    
934
static const yytype_int8 yycheck[] =
935
{
936
       0,     5,     4,     7,     6,    -1,     9,    10,     9,     9,
937
      10,     9,     7,     3,     8,     6,     3,    -1,     7
938
};
939

    
940
  /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
941
     symbol of state STATE-NUM.  */
942
static const yytype_uint8 yystos[] =
943
{
944
       0,     9,    10,    13,    14,     5,     7,     0,    14,     9,
945
       4,     6,     9,     7,     3,     8,     6,     7
946
};
947

    
948
  /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
949
static const yytype_uint8 yyr1[] =
950
{
951
       0,    12,    13,    13,    14,    14,    14,    14
952
};
953

    
954
  /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
955
static const yytype_uint8 yyr2[] =
956
{
957
       0,     2,     1,     2,     1,     2,     5,     9
958
};
959

    
960

    
961
#define yyerrok         (yyerrstatus = 0)
962
#define yyclearin       (yychar = YYEMPTY)
963
#define YYEMPTY         (-2)
964
#define YYEOF           0
965

    
966
#define YYACCEPT        goto yyacceptlab
967
#define YYABORT         goto yyabortlab
968
#define YYERROR         goto yyerrorlab
969

    
970

    
971
#define YYRECOVERING()  (!!yyerrstatus)
972

    
973
#define YYBACKUP(Token, Value)                                  \
974
do                                                              \
975
  if (yychar == YYEMPTY)                                        \
976
    {                                                           \
977
      yychar = (Token);                                         \
978
      yylval = (Value);                                         \
979
      YYPOPSTACK (yylen);                                       \
980
      yystate = *yyssp;                                         \
981
      goto yybackup;                                            \
982
    }                                                           \
983
  else                                                          \
984
    {                                                           \
985
      yyerror (&yylloc, mc, vm, parsed, errmsg, YY_("syntax error: cannot back up")); \
986
      YYERROR;                                                  \
987
    }                                                           \
988
while (0)
989

    
990
/* Error token number */
991
#define YYTERROR        1
992
#define YYERRCODE       256
993

    
994

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

    
999
#ifndef YYLLOC_DEFAULT
1000
# define YYLLOC_DEFAULT(Current, Rhs, N)                                \
1001
    do                                                                  \
1002
      if (N)                                                            \
1003
        {                                                               \
1004
          (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
1005
          (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
1006
          (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
1007
          (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
1008
        }                                                               \
1009
      else                                                              \
1010
        {                                                               \
1011
          (Current).first_line   = (Current).last_line   =              \
1012
            YYRHSLOC (Rhs, 0).last_line;                                \
1013
          (Current).first_column = (Current).last_column =              \
1014
            YYRHSLOC (Rhs, 0).last_column;                              \
1015
        }                                                               \
1016
    while (0)
1017
#endif
1018

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

    
1021

    
1022
/* Enable debugging if requested.  */
1023
#if YYDEBUG
1024

    
1025
# ifndef YYFPRINTF
1026
#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1027
#  define YYFPRINTF fprintf
1028
# endif
1029

    
1030
# define YYDPRINTF(Args)                        \
1031
do {                                            \
1032
  if (yydebug)                                  \
1033
    YYFPRINTF Args;                             \
1034
} while (0)
1035

    
1036

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

    
1041
#ifndef YY_LOCATION_PRINT
1042
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1043

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

    
1046
YY_ATTRIBUTE_UNUSED
1047
static unsigned
1048
yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
1049
{
1050
  unsigned res = 0;
1051
  int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
1052
  if (0 <= yylocp->first_line)
1053
    {
1054
      res += YYFPRINTF (yyo, "%d", yylocp->first_line);
1055
      if (0 <= yylocp->first_column)
1056
        res += YYFPRINTF (yyo, ".%d", yylocp->first_column);
1057
    }
1058
  if (0 <= yylocp->last_line)
1059
    {
1060
      if (yylocp->first_line < yylocp->last_line)
1061
        {
1062
          res += YYFPRINTF (yyo, "-%d", yylocp->last_line);
1063
          if (0 <= end_col)
1064
            res += YYFPRINTF (yyo, ".%d", end_col);
1065
        }
1066
      else if (0 <= end_col && yylocp->first_column < end_col)
1067
        res += YYFPRINTF (yyo, "-%d", end_col);
1068
    }
1069
  return res;
1070
 }
1071

    
1072
#  define YY_LOCATION_PRINT(File, Loc)          \
1073
  yy_location_print_ (File, &(Loc))
1074

    
1075
# else
1076
#  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1077
# endif
1078
#endif
1079

    
1080

    
1081
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
1082
do {                                                                      \
1083
  if (yydebug)                                                            \
1084
    {                                                                     \
1085
      YYFPRINTF (stderr, "%s ", Title);                                   \
1086
      yy_symbol_print (stderr,                                            \
1087
                  Type, Value, Location, mc, vm, parsed, errmsg); \
1088
      YYFPRINTF (stderr, "\n");                                           \
1089
    }                                                                     \
1090
} while (0)
1091

    
1092

    
1093
/*----------------------------------------.
1094
| Print this symbol's value on YYOUTPUT.  |
1095
`----------------------------------------*/
1096

    
1097
static void
1098
yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, mem_collector * mc, VirtualMachine * vm, ostringstream *  parsed, char **          errmsg)
1099
{
1100
  FILE *yyo = yyoutput;
1101
  YYUSE (yyo);
1102
  YYUSE (yylocationp);
1103
  YYUSE (mc);
1104
  YYUSE (vm);
1105
  YYUSE (parsed);
1106
  YYUSE (errmsg);
1107
  if (!yyvaluep)
1108
    return;
1109
# ifdef YYPRINT
1110
  if (yytype < YYNTOKENS)
1111
    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1112
# endif
1113
  YYUSE (yytype);
1114
}
1115

    
1116

    
1117
/*--------------------------------.
1118
| Print this symbol on YYOUTPUT.  |
1119
`--------------------------------*/
1120

    
1121
static void
1122
yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, mem_collector * mc, VirtualMachine * vm, ostringstream *  parsed, char **          errmsg)
1123
{
1124
  YYFPRINTF (yyoutput, "%s %s (",
1125
             yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
1126

    
1127
  YY_LOCATION_PRINT (yyoutput, *yylocationp);
1128
  YYFPRINTF (yyoutput, ": ");
1129
  yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, mc, vm, parsed, errmsg);
1130
  YYFPRINTF (yyoutput, ")");
1131
}
1132

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

    
1138
static void
1139
yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
1140
{
1141
  YYFPRINTF (stderr, "Stack now");
1142
  for (; yybottom <= yytop; yybottom++)
1143
    {
1144
      int yybot = *yybottom;
1145
      YYFPRINTF (stderr, " %d", yybot);
1146
    }
1147
  YYFPRINTF (stderr, "\n");
1148
}
1149

    
1150
# define YY_STACK_PRINT(Bottom, Top)                            \
1151
do {                                                            \
1152
  if (yydebug)                                                  \
1153
    yy_stack_print ((Bottom), (Top));                           \
1154
} while (0)
1155

    
1156

    
1157
/*------------------------------------------------.
1158
| Report that the YYRULE is going to be reduced.  |
1159
`------------------------------------------------*/
1160

    
1161
static void
1162
yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, mem_collector * mc, VirtualMachine * vm, ostringstream *  parsed, char **          errmsg)
1163
{
1164
  unsigned long int yylno = yyrline[yyrule];
1165
  int yynrhs = yyr2[yyrule];
1166
  int yyi;
1167
  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1168
             yyrule - 1, yylno);
1169
  /* The symbols being reduced.  */
1170
  for (yyi = 0; yyi < yynrhs; yyi++)
1171
    {
1172
      YYFPRINTF (stderr, "   $%d = ", yyi + 1);
1173
      yy_symbol_print (stderr,
1174
                       yystos[yyssp[yyi + 1 - yynrhs]],
1175
                       &(yyvsp[(yyi + 1) - (yynrhs)])
1176
                       , &(yylsp[(yyi + 1) - (yynrhs)])                       , mc, vm, parsed, errmsg);
1177
      YYFPRINTF (stderr, "\n");
1178
    }
1179
}
1180

    
1181
# define YY_REDUCE_PRINT(Rule)          \
1182
do {                                    \
1183
  if (yydebug)                          \
1184
    yy_reduce_print (yyssp, yyvsp, yylsp, Rule, mc, vm, parsed, errmsg); \
1185
} while (0)
1186

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

    
1197

    
1198
/* YYINITDEPTH -- initial size of the parser's stacks.  */
1199
#ifndef YYINITDEPTH
1200
# define YYINITDEPTH 200
1201
#endif
1202

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

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

    
1210
#ifndef YYMAXDEPTH
1211
# define YYMAXDEPTH 10000
1212
#endif
1213

    
1214

    
1215
#if YYERROR_VERBOSE
1216

    
1217
# ifndef yystrlen
1218
#  if defined __GLIBC__ && defined _STRING_H
1219
#   define yystrlen strlen
1220
#  else
1221
/* Return the length of YYSTR.  */
1222
static YYSIZE_T
1223
yystrlen (const char *yystr)
1224
{
1225
  YYSIZE_T yylen;
1226
  for (yylen = 0; yystr[yylen]; yylen++)
1227
    continue;
1228
  return yylen;
1229
}
1230
#  endif
1231
# endif
1232

    
1233
# ifndef yystpcpy
1234
#  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1235
#   define yystpcpy stpcpy
1236
#  else
1237
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1238
   YYDEST.  */
1239
static char *
1240
yystpcpy (char *yydest, const char *yysrc)
1241
{
1242
  char *yyd = yydest;
1243
  const char *yys = yysrc;
1244

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

    
1248
  return yyd - 1;
1249
}
1250
#  endif
1251
# endif
1252

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

    
1269
      for (;;)
1270
        switch (*++yyp)
1271
          {
1272
          case '\'':
1273
          case ',':
1274
            goto do_not_strip_quotes;
1275

    
1276
          case '\\':
1277
            if (*++yyp != '\\')
1278
              goto do_not_strip_quotes;
1279
            /* Fall through.  */
1280
          default:
1281
            if (yyres)
1282
              yyres[yyn] = *yyp;
1283
            yyn++;
1284
            break;
1285

    
1286
          case '"':
1287
            if (yyres)
1288
              yyres[yyn] = '\0';
1289
            return yyn;
1290
          }
1291
    do_not_strip_quotes: ;
1292
    }
1293

    
1294
  if (! yyres)
1295
    return yystrlen (yystr);
1296

    
1297
  return yystpcpy (yyres, yystr) - yyres;
1298
}
1299
# endif
1300

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

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

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

    
1362
          for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1363
            if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1364
                && !yytable_value_is_error (yytable[yyx + yyn]))
1365
              {
1366
                if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1367
                  {
1368
                    yycount = 1;
1369
                    yysize = yysize0;
1370
                    break;
1371
                  }
1372
                yyarg[yycount++] = yytname[yyx];
1373
                {
1374
                  YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
1375
                  if (! (yysize <= yysize1
1376
                         && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1377
                    return 2;
1378
                  yysize = yysize1;
1379
                }
1380
              }
1381
        }
1382
    }
1383

    
1384
  switch (yycount)
1385
    {
1386
# define YYCASE_(N, S)                      \
1387
      case N:                               \
1388
        yyformat = S;                       \
1389
      break
1390
      YYCASE_(0, YY_("syntax error"));
1391
      YYCASE_(1, YY_("syntax error, unexpected %s"));
1392
      YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1393
      YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1394
      YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1395
      YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1396
# undef YYCASE_
1397
    }
1398

    
1399
  {
1400
    YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1401
    if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1402
      return 2;
1403
    yysize = yysize1;
1404
  }
1405

    
1406
  if (*yymsg_alloc < yysize)
1407
    {
1408
      *yymsg_alloc = 2 * yysize;
1409
      if (! (yysize <= *yymsg_alloc
1410
             && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1411
        *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1412
      return 1;
1413
    }
1414

    
1415
  /* Avoid sprintf, as that infringes on the user's name space.
1416
     Don't have undefined behavior even if the translation
1417
     produced a string with the wrong number of "%s"s.  */
1418
  {
1419
    char *yyp = *yymsg;
1420
    int yyi = 0;
1421
    while ((*yyp = *yyformat) != '\0')
1422
      if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1423
        {
1424
          yyp += yytnamerr (yyp, yyarg[yyi++]);
1425
          yyformat += 2;
1426
        }
1427
      else
1428
        {
1429
          yyp++;
1430
          yyformat++;
1431
        }
1432
  }
1433
  return 0;
1434
}
1435
#endif /* YYERROR_VERBOSE */
1436

    
1437
/*-----------------------------------------------.
1438
| Release the memory associated to this symbol.  |
1439
`-----------------------------------------------*/
1440

    
1441
static void
1442
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, mem_collector * mc, VirtualMachine * vm, ostringstream *  parsed, char **          errmsg)
1443
{
1444
  YYUSE (yyvaluep);
1445
  YYUSE (yylocationp);
1446
  YYUSE (mc);
1447
  YYUSE (vm);
1448
  YYUSE (parsed);
1449
  YYUSE (errmsg);
1450
  if (!yymsg)
1451
    yymsg = "Deleting";
1452
  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1453

    
1454
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1455
  YYUSE (yytype);
1456
  YY_IGNORE_MAYBE_UNINITIALIZED_END
1457
}
1458

    
1459

    
1460

    
1461

    
1462
/*----------.
1463
| yyparse.  |
1464
`----------*/
1465

    
1466
int
1467
yyparse (mem_collector * mc, VirtualMachine * vm, ostringstream *  parsed, char **          errmsg)
1468
{
1469
/* The lookahead symbol.  */
1470
int yychar;
1471

    
1472

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

    
1479
/* Location data for the lookahead symbol.  */
1480
static YYLTYPE yyloc_default
1481
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1482
  = { 1, 1, 1, 1 }
1483
# endif
1484
;
1485
YYLTYPE yylloc = yyloc_default;
1486

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

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

    
1494
    /* The stacks and their tools:
1495
       'yyss': related to states.
1496
       'yyvs': related to semantic values.
1497
       'yyls': related to locations.
1498

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

    
1502
    /* The state stack.  */
1503
    yytype_int16 yyssa[YYINITDEPTH];
1504
    yytype_int16 *yyss;
1505
    yytype_int16 *yyssp;
1506

    
1507
    /* The semantic value stack.  */
1508
    YYSTYPE yyvsa[YYINITDEPTH];
1509
    YYSTYPE *yyvs;
1510
    YYSTYPE *yyvsp;
1511

    
1512
    /* The location stack.  */
1513
    YYLTYPE yylsa[YYINITDEPTH];
1514
    YYLTYPE *yyls;
1515
    YYLTYPE *yylsp;
1516

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

    
1520
    YYSIZE_T yystacksize;
1521

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

    
1531
#if YYERROR_VERBOSE
1532
  /* Buffer for error messages, and its allocated size.  */
1533
  char yymsgbuf[128];
1534
  char *yymsg = yymsgbuf;
1535
  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1536
#endif
1537

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

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

    
1544
  yyssp = yyss = yyssa;
1545
  yyvsp = yyvs = yyvsa;
1546
  yylsp = yyls = yylsa;
1547
  yystacksize = YYINITDEPTH;
1548

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

    
1551
  yystate = 0;
1552
  yyerrstatus = 0;
1553
  yynerrs = 0;
1554
  yychar = YYEMPTY; /* Cause a token to be read.  */
1555
  yylsp[0] = yylloc;
1556
  goto yysetstate;
1557

    
1558
/*------------------------------------------------------------.
1559
| yynewstate -- Push a new state, which is found in yystate.  |
1560
`------------------------------------------------------------*/
1561
 yynewstate:
1562
  /* In all cases, when you get here, the value and location stacks
1563
     have just been pushed.  So pushing a state here evens the stacks.  */
1564
  yyssp++;
1565

    
1566
 yysetstate:
1567
  *yyssp = yystate;
1568

    
1569
  if (yyss + yystacksize - 1 <= yyssp)
1570
    {
1571
      /* Get the current used size of the three stacks, in elements.  */
1572
      YYSIZE_T yysize = yyssp - yyss + 1;
1573

    
1574
#ifdef yyoverflow
1575
      {
1576
        /* Give user a chance to reallocate the stack.  Use copies of
1577
           these so that the &'s don't force the real ones into
1578
           memory.  */
1579
        YYSTYPE *yyvs1 = yyvs;
1580
        yytype_int16 *yyss1 = yyss;
1581
        YYLTYPE *yyls1 = yyls;
1582

    
1583
        /* Each stack pointer address is followed by the size of the
1584
           data in use in that stack, in bytes.  This used to be a
1585
           conditional around just the two extra args, but that might
1586
           be undefined if yyoverflow is a macro.  */
1587
        yyoverflow (YY_("memory exhausted"),
1588
                    &yyss1, yysize * sizeof (*yyssp),
1589
                    &yyvs1, yysize * sizeof (*yyvsp),
1590
                    &yyls1, yysize * sizeof (*yylsp),
1591
                    &yystacksize);
1592

    
1593
        yyls = yyls1;
1594
        yyss = yyss1;
1595
        yyvs = yyvs1;
1596
      }
1597
#else /* no yyoverflow */
1598
# ifndef YYSTACK_RELOCATE
1599
      goto yyexhaustedlab;
1600
# else
1601
      /* Extend the stack our own way.  */
1602
      if (YYMAXDEPTH <= yystacksize)
1603
        goto yyexhaustedlab;
1604
      yystacksize *= 2;
1605
      if (YYMAXDEPTH < yystacksize)
1606
        yystacksize = YYMAXDEPTH;
1607

    
1608
      {
1609
        yytype_int16 *yyss1 = yyss;
1610
        union yyalloc *yyptr =
1611
          (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1612
        if (! yyptr)
1613
          goto yyexhaustedlab;
1614
        YYSTACK_RELOCATE (yyss_alloc, yyss);
1615
        YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1616
        YYSTACK_RELOCATE (yyls_alloc, yyls);
1617
#  undef YYSTACK_RELOCATE
1618
        if (yyss1 != yyssa)
1619
          YYSTACK_FREE (yyss1);
1620
      }
1621
# endif
1622
#endif /* no yyoverflow */
1623

    
1624
      yyssp = yyss + yysize - 1;
1625
      yyvsp = yyvs + yysize - 1;
1626
      yylsp = yyls + yysize - 1;
1627

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

    
1631
      if (yyss + yystacksize - 1 <= yyssp)
1632
        YYABORT;
1633
    }
1634

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

    
1637
  if (yystate == YYFINAL)
1638
    YYACCEPT;
1639

    
1640
  goto yybackup;
1641

    
1642
/*-----------.
1643
| yybackup.  |
1644
`-----------*/
1645
yybackup:
1646

    
1647
  /* Do appropriate processing given the current state.  Read a
1648
     lookahead token if we need one and don't already have one.  */
1649

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

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

    
1657
  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1658
  if (yychar == YYEMPTY)
1659
    {
1660
      YYDPRINTF ((stderr, "Reading a token: "));
1661
      yychar = yylex (&yylval, &yylloc, mc);
1662
    }
1663

    
1664
  if (yychar <= YYEOF)
1665
    {
1666
      yychar = yytoken = YYEOF;
1667
      YYDPRINTF ((stderr, "Now at end of input.\n"));
1668
    }
1669
  else
1670
    {
1671
      yytoken = YYTRANSLATE (yychar);
1672
      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1673
    }
1674

    
1675
  /* If the proper action on seeing token YYTOKEN is to reduce or to
1676
     detect an error, take that action.  */
1677
  yyn += yytoken;
1678
  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1679
    goto yydefault;
1680
  yyn = yytable[yyn];
1681
  if (yyn <= 0)
1682
    {
1683
      if (yytable_value_is_error (yyn))
1684
        goto yyerrlab;
1685
      yyn = -yyn;
1686
      goto yyreduce;
1687
    }
1688

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

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

    
1697
  /* Discard the shifted token.  */
1698
  yychar = YYEMPTY;
1699

    
1700
  yystate = yyn;
1701
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1702
  *++yyvsp = yylval;
1703
  YY_IGNORE_MAYBE_UNINITIALIZED_END
1704
  *++yylsp = yylloc;
1705
  goto yynewstate;
1706

    
1707

    
1708
/*-----------------------------------------------------------.
1709
| yydefault -- do the default action for the current state.  |
1710
`-----------------------------------------------------------*/
1711
yydefault:
1712
  yyn = yydefact[yystate];
1713
  if (yyn == 0)
1714
    goto yyerrlab;
1715
  goto yyreduce;
1716

    
1717

    
1718
/*-----------------------------.
1719
| yyreduce -- Do a reduction.  |
1720
`-----------------------------*/
1721
yyreduce:
1722
  /* yyn is the number of a rule to reduce with.  */
1723
  yylen = yyr2[yyn];
1724

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

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

    
1735
  /* Default location.  */
1736
  YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1737
  YY_REDUCE_PRINT (yyn);
1738
  switch (yyn)
1739
    {
1740
        case 4:
1741
#line 456 "vm_var_syntax.y" /* yacc.c:1646  */
1742
    {
1743
        (*parsed) << (yyvsp[0].val_str);
1744
    }
1745
#line 1745 "vm_var_syntax.cc" /* yacc.c:1646  */
1746
    break;
1747

    
1748
  case 5:
1749
#line 460 "vm_var_syntax.y" /* yacc.c:1646  */
1750
    {
1751
        string name((yyvsp[-1].val_str));
1752

    
1753
        VM_VAR_TO_UPPER(name);
1754

    
1755
        insert_single(vm,*parsed,name);
1756

    
1757
        if ( (yyvsp[0].val_char) != '\0' )
1758
        {
1759
            (*parsed) << (yyvsp[0].val_char);
1760
        }
1761
    }
1762
#line 1762 "vm_var_syntax.cc" /* yacc.c:1646  */
1763
    break;
1764

    
1765
  case 6:
1766
#line 473 "vm_var_syntax.y" /* yacc.c:1646  */
1767
    {
1768
        string name((yyvsp[-4].val_str));
1769
        string vname((yyvsp[-2].val_str));
1770

    
1771
        VM_VAR_TO_UPPER(name);
1772
        VM_VAR_TO_UPPER(vname);
1773

    
1774
        insert_vector(vm,*parsed,name,vname,"","");
1775

    
1776
        if ( (yyvsp[0].val_char) != '\0' )
1777
        {
1778
            (*parsed) << (yyvsp[0].val_char);
1779
        }
1780
    }
1781
#line 1781 "vm_var_syntax.cc" /* yacc.c:1646  */
1782
    break;
1783

    
1784
  case 7:
1785
#line 488 "vm_var_syntax.y" /* yacc.c:1646  */
1786
    {
1787
        string name((yyvsp[-8].val_str));
1788
        string vname((yyvsp[-6].val_str));
1789
        string vvar((yyvsp[-4].val_str));
1790
        string vval((yyvsp[-2].val_str));
1791

    
1792
        VM_VAR_TO_UPPER(name);
1793
        VM_VAR_TO_UPPER(vname);
1794
        VM_VAR_TO_UPPER(vvar);
1795

    
1796
        insert_vector(vm,*parsed,name,vname,vvar,vval);
1797

    
1798
        if ( (yyvsp[0].val_char) != '\0' )
1799
        {
1800
            (*parsed) << (yyvsp[0].val_char);
1801
        }
1802
    }
1803
#line 1803 "vm_var_syntax.cc" /* yacc.c:1646  */
1804
    break;
1805

    
1806

    
1807
#line 1807 "vm_var_syntax.cc" /* yacc.c:1646  */
1808
      default: break;
1809
    }
1810
  /* User semantic actions sometimes alter yychar, and that requires
1811
     that yytoken be updated with the new translation.  We take the
1812
     approach of translating immediately before every use of yytoken.
1813
     One alternative is translating here after every semantic action,
1814
     but that translation would be missed if the semantic action invokes
1815
     YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1816
     if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
1817
     incorrect destructor might then be invoked immediately.  In the
1818
     case of YYERROR or YYBACKUP, subsequent parser actions might lead
1819
     to an incorrect destructor call or verbose syntax error message
1820
     before the lookahead is translated.  */
1821
  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1822

    
1823
  YYPOPSTACK (yylen);
1824
  yylen = 0;
1825
  YY_STACK_PRINT (yyss, yyssp);
1826

    
1827
  *++yyvsp = yyval;
1828
  *++yylsp = yyloc;
1829

    
1830
  /* Now 'shift' the result of the reduction.  Determine what state
1831
     that goes to, based on the state we popped back to and the rule
1832
     number reduced by.  */
1833

    
1834
  yyn = yyr1[yyn];
1835

    
1836
  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1837
  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1838
    yystate = yytable[yystate];
1839
  else
1840
    yystate = yydefgoto[yyn - YYNTOKENS];
1841

    
1842
  goto yynewstate;
1843

    
1844

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

    
1853
  /* If not already recovering from an error, report this error.  */
1854
  if (!yyerrstatus)
1855
    {
1856
      ++yynerrs;
1857
#if ! YYERROR_VERBOSE
1858
      yyerror (&yylloc, mc, vm, parsed, errmsg, YY_("syntax error"));
1859
#else
1860
# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1861
                                        yyssp, yytoken)
1862
      {
1863
        char const *yymsgp = YY_("syntax error");
1864
        int yysyntax_error_status;
1865
        yysyntax_error_status = YYSYNTAX_ERROR;
1866
        if (yysyntax_error_status == 0)
1867
          yymsgp = yymsg;
1868
        else if (yysyntax_error_status == 1)
1869
          {
1870
            if (yymsg != yymsgbuf)
1871
              YYSTACK_FREE (yymsg);
1872
            yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1873
            if (!yymsg)
1874
              {
1875
                yymsg = yymsgbuf;
1876
                yymsg_alloc = sizeof yymsgbuf;
1877
                yysyntax_error_status = 2;
1878
              }
1879
            else
1880
              {
1881
                yysyntax_error_status = YYSYNTAX_ERROR;
1882
                yymsgp = yymsg;
1883
              }
1884
          }
1885
        yyerror (&yylloc, mc, vm, parsed, errmsg, yymsgp);
1886
        if (yysyntax_error_status == 2)
1887
          goto yyexhaustedlab;
1888
      }
1889
# undef YYSYNTAX_ERROR
1890
#endif
1891
    }
1892

    
1893
  yyerror_range[1] = yylloc;
1894

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

    
1900
      if (yychar <= YYEOF)
1901
        {
1902
          /* Return failure if at end of input.  */
1903
          if (yychar == YYEOF)
1904
            YYABORT;
1905
        }
1906
      else
1907
        {
1908
          yydestruct ("Error: discarding",
1909
                      yytoken, &yylval, &yylloc, mc, vm, parsed, errmsg);
1910
          yychar = YYEMPTY;
1911
        }
1912
    }
1913

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

    
1918

    
1919
/*---------------------------------------------------.
1920
| yyerrorlab -- error raised explicitly by YYERROR.  |
1921
`---------------------------------------------------*/
1922
yyerrorlab:
1923

    
1924
  /* Pacify compilers like GCC when the user code never invokes
1925
     YYERROR and the label yyerrorlab therefore never appears in user
1926
     code.  */
1927
  if (/*CONSTCOND*/ 0)
1928
     goto yyerrorlab;
1929

    
1930
  yyerror_range[1] = yylsp[1-yylen];
1931
  /* Do not reclaim the symbols of the rule whose action triggered
1932
     this YYERROR.  */
1933
  YYPOPSTACK (yylen);
1934
  yylen = 0;
1935
  YY_STACK_PRINT (yyss, yyssp);
1936
  yystate = *yyssp;
1937
  goto yyerrlab1;
1938

    
1939

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

    
1946
  for (;;)
1947
    {
1948
      yyn = yypact[yystate];
1949
      if (!yypact_value_is_default (yyn))
1950
        {
1951
          yyn += YYTERROR;
1952
          if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1953
            {
1954
              yyn = yytable[yyn];
1955
              if (0 < yyn)
1956
                break;
1957
            }
1958
        }
1959

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

    
1964
      yyerror_range[1] = *yylsp;
1965
      yydestruct ("Error: popping",
1966
                  yystos[yystate], yyvsp, yylsp, mc, vm, parsed, errmsg);
1967
      YYPOPSTACK (1);
1968
      yystate = *yyssp;
1969
      YY_STACK_PRINT (yyss, yyssp);
1970
    }
1971

    
1972
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1973
  *++yyvsp = yylval;
1974
  YY_IGNORE_MAYBE_UNINITIALIZED_END
1975

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

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

    
1985
  yystate = yyn;
1986
  goto yynewstate;
1987

    
1988

    
1989
/*-------------------------------------.
1990
| yyacceptlab -- YYACCEPT comes here.  |
1991
`-------------------------------------*/
1992
yyacceptlab:
1993
  yyresult = 0;
1994
  goto yyreturn;
1995

    
1996
/*-----------------------------------.
1997
| yyabortlab -- YYABORT comes here.  |
1998
`-----------------------------------*/
1999
yyabortlab:
2000
  yyresult = 1;
2001
  goto yyreturn;
2002

    
2003
#if !defined yyoverflow || YYERROR_VERBOSE
2004
/*-------------------------------------------------.
2005
| yyexhaustedlab -- memory exhaustion comes here.  |
2006
`-------------------------------------------------*/
2007
yyexhaustedlab:
2008
  yyerror (&yylloc, mc, vm, parsed, errmsg, YY_("memory exhausted"));
2009
  yyresult = 2;
2010
  /* Fall through.  */
2011
#endif
2012

    
2013
yyreturn:
2014
  if (yychar != YYEMPTY)
2015
    {
2016
      /* Make sure we have latest lookahead translation.  See comments at
2017
         user semantic actions for why this is necessary.  */
2018
      yytoken = YYTRANSLATE (yychar);
2019
      yydestruct ("Cleanup: discarding lookahead",
2020
                  yytoken, &yylval, &yylloc, mc, vm, parsed, errmsg);
2021
    }
2022
  /* Do not reclaim the symbols of the rule whose action triggered
2023
     this YYABORT or YYACCEPT.  */
2024
  YYPOPSTACK (yylen);
2025
  YY_STACK_PRINT (yyss, yyssp);
2026
  while (yyssp != yyss)
2027
    {
2028
      yydestruct ("Cleanup: popping",
2029
                  yystos[*yyssp], yyvsp, yylsp, mc, vm, parsed, errmsg);
2030
      YYPOPSTACK (1);
2031
    }
2032
#ifndef yyoverflow
2033
  if (yyss != yyssa)
2034
    YYSTACK_FREE (yyss);
2035
#endif
2036
#if YYERROR_VERBOSE
2037
  if (yymsg != yymsgbuf)
2038
    YYSTACK_FREE (yymsg);
2039
#endif
2040
  return yyresult;
2041
}
2042
#line 506 "vm_var_syntax.y" /* yacc.c:1906  */
2043

    
2044

    
2045
extern "C" void vm_var__error(
2046
    YYLTYPE *        llocp,
2047
    mem_collector *  mc,
2048
    VirtualMachine * vm,
2049
    ostringstream *  parsed,
2050
    char **          error_msg,
2051
    const char *     str)
2052
{
2053
    int length;
2054

    
2055
    length = strlen(str)+ 64;
2056

    
2057
    *error_msg = (char *) malloc(sizeof(char)*length);
2058

    
2059
    if (*error_msg != 0)
2060
    {
2061
        snprintf(*error_msg,
2062
            length,
2063
            "%s at line %i, columns %i:%i",
2064
            str,
2065
            llocp->first_line,
2066
            llocp->first_column,
2067
            llocp->last_column);
2068
    }
2069
}