this repo has no description
1/* A Bison parser, made by GNU Bison 3.7.2. */
2
3/* Bison implementation for Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
6 Inc.
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20
21/* As a special exception, you may create a larger work that contains
22 part or all of the Bison parser skeleton and distribute that work
23 under terms of your choice, so long as that work isn't itself a
24 parser generator using the skeleton or a modified version thereof
25 as a parser skeleton. Alternatively, if you modify or redistribute
26 the parser skeleton itself, you may (at your option) remove this
27 special exception, which will cause the skeleton and the resulting
28 Bison output files to be licensed under the GNU General Public
29 License without this special exception.
30
31 This special exception was added by the Free Software Foundation in
32 version 2.2 of Bison. */
33
34/* C LALR(1) parser skeleton written by Richard Stallman, by
35 simplifying the original so-called "semantic" parser. */
36
37/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
38 especially those whose name start with YY_ or yy_. They are
39 private implementation details that can be changed or removed. */
40
41/* All symbols defined below should begin with yy or YY, to avoid
42 infringing on user name space. This should be done even for local
43 variables, as they might otherwise be expanded by user macros.
44 There are some unavoidable exceptions within include files to
45 define necessary library symbols; they are noted "INFRINGES ON
46 USER NAME SPACE" below. */
47
48/* Identify Bison output. */
49#define YYBISON 1
50
51/* Bison version. */
52#define YYBISON_VERSION "3.7.2"
53
54/* Skeleton name. */
55#define YYSKELETON_NAME "yacc.c"
56
57/* Pure parsers. */
58#define YYPURE 1
59
60/* Push parsers. */
61#define YYPUSH 0
62
63/* Pull parsers. */
64#define YYPULL 1
65
66
67
68
69/* First part of user prologue. */
70#line 37 "../gecode/flatzinc/parser.yxx"
71
72#define YYPARSE_PARAM parm
73#define YYLEX_PARAM static_cast<ParserState*>(parm)->yyscanner
74#include <gecode/flatzinc.hh>
75#include <gecode/flatzinc/parser.hh>
76#include <gecode/flatzinc/lastval.hh>
77#include <iostream>
78#include <fstream>
79
80#ifdef HAVE_MMAP
81#include <stdio.h>
82#include <stdlib.h>
83#include <fcntl.h>
84#include <unistd.h>
85#include <sys/types.h>
86#include <sys/mman.h>
87#include <sys/stat.h>
88#endif
89
90using namespace std;
91
92int yyparse(void*);
93int yylex(YYSTYPE*, void* scanner);
94int yylex_init (void** scanner);
95int yylex_destroy (void* scanner);
96int yyget_lineno (void* scanner);
97void yyset_extra (void* user_defined ,void* yyscanner );
98
99extern int yydebug;
100
101using namespace Gecode;
102using namespace Gecode::FlatZinc;
103
104void yyerror(void* parm, const char *str) {
105 ParserState* pp = static_cast<ParserState*>(parm);
106 pp->err << "Error: " << str
107 << " in line no. " << yyget_lineno(pp->yyscanner)
108 << std::endl;
109 pp->hadError = true;
110}
111
112void yyassert(ParserState* pp, bool cond, const char* str)
113{
114 if (!cond) {
115 pp->err << "Error: " << str
116 << " in line no. " << yyget_lineno(pp->yyscanner)
117 << std::endl;
118 pp->hadError = true;
119 }
120}
121
122/*
123 * The symbol tables
124 *
125 */
126
127AST::Node* getArrayElement(ParserState* pp, string id, int offset,
128 bool annotation) {
129 if (offset > 0) {
130 SymbolEntry e;
131 if (pp->symbols.get(id,e)) {
132 switch (e.t) {
133 case ST_INTVARARRAY:
134 if (offset > pp->arrays[e.i])
135 goto error;
136 {
137 std::string n;
138 if (annotation) {
139 std::ostringstream oss;
140 oss << id << "[" << offset << "]";
141 n = oss.str();
142 }
143 return new AST::IntVar(pp->arrays[e.i+offset],n);
144 }
145 case ST_BOOLVARARRAY:
146 if (offset > pp->arrays[e.i])
147 goto error;
148 {
149 std::string n;
150 if (annotation) {
151 std::ostringstream oss;
152 oss << id << "[" << offset << "]";
153 n = oss.str();
154 }
155 return new AST::BoolVar(pp->arrays[e.i+offset],n);
156 }
157 case ST_SETVARARRAY:
158 if (offset > pp->arrays[e.i])
159 goto error;
160 {
161 std::string n;
162 if (annotation) {
163 std::ostringstream oss;
164 oss << id << "[" << offset << "]";
165 n = oss.str();
166 }
167 return new AST::SetVar(pp->arrays[e.i+offset],n);
168 }
169 case ST_FLOATVARARRAY:
170 if (offset > pp->arrays[e.i])
171 goto error;
172 {
173 std::string n;
174 if (annotation) {
175 std::ostringstream oss;
176 oss << id << "[" << offset << "]";
177 n = oss.str();
178 }
179 return new AST::FloatVar(pp->arrays[e.i+offset],n);
180 }
181 case ST_INTVALARRAY:
182 if (offset > pp->arrays[e.i])
183 goto error;
184 return new AST::IntLit(pp->arrays[e.i+offset]);
185 case ST_SETVALARRAY:
186 if (offset > pp->arrays[e.i])
187 goto error;
188 return new AST::SetLit(pp->setvals[pp->arrays[e.i+1]+offset-1]);
189 case ST_FLOATVALARRAY:
190 if (offset > pp->arrays[e.i])
191 goto error;
192 return new AST::FloatLit(pp->floatvals[pp->arrays[e.i+1]+offset-1]);
193 default:
194 break;
195 }
196 }
197 }
198error:
199 pp->err << "Error: array access to " << id << " invalid"
200 << " in line no. "
201 << yyget_lineno(pp->yyscanner) << std::endl;
202 pp->hadError = true;
203 return new AST::IntVar(0); // keep things consistent
204}
205AST::Node* getVarRefArg(ParserState* pp, string id, bool annotation = false) {
206 SymbolEntry e;
207 string n;
208 if (annotation)
209 n = id;
210 if (pp->symbols.get(id, e)) {
211 switch (e.t) {
212 case ST_INTVAR: return new AST::IntVar(e.i,n);
213 case ST_BOOLVAR: return new AST::BoolVar(e.i,n);
214 case ST_SETVAR: return new AST::SetVar(e.i,n);
215 case ST_FLOATVAR: return new AST::FloatVar(e.i,n);
216 default: break;
217 }
218 }
219
220 if (annotation)
221 return new AST::Atom(id);
222 pp->err << "Error: undefined variable " << id
223 << " in line no. "
224 << yyget_lineno(pp->yyscanner) << std::endl;
225 pp->hadError = true;
226 return new AST::IntVar(0); // keep things consistent
227}
228
229void addDomainConstraint(ParserState* pp, std::string id, AST::Node* var,
230 Option<AST::SetLit* >& dom) {
231 if (!dom())
232 return;
233 AST::Array* args = new AST::Array(2);
234 args->a[0] = var;
235 args->a[1] = dom.some();
236 pp->domainConstraints.push_back(new ConExpr(id, args, NULL));
237}
238
239void addDomainConstraint(ParserState* pp, AST::Node* var,
240 Option<std::pair<double,double>* > dom) {
241 if (!dom())
242 return;
243 {
244 AST::Array* args = new AST::Array(2);
245 args->a[0] = new AST::FloatLit(dom.some()->first);
246 args->a[1] = var;
247 pp->domainConstraints.push_back(new ConExpr("float_le", args, NULL));
248 }
249 {
250 AST::Array* args = new AST::Array(2);
251 AST::FloatVar* fv = static_cast<AST::FloatVar*>(var);
252 args->a[0] = new AST::FloatVar(fv->i,fv->n);
253 args->a[1] = new AST::FloatLit(dom.some()->second);
254 pp->domainConstraints.push_back(new ConExpr("float_le", args, NULL));
255 }
256 delete dom.some();
257}
258
259int getBaseIntVar(ParserState* pp, int i) {
260 int base = i;
261 IntVarSpec* ivs = static_cast<IntVarSpec*>(pp->intvars[base].second);
262 while (ivs->alias) {
263 base = ivs->i;
264 ivs = static_cast<IntVarSpec*>(pp->intvars[base].second);
265 }
266 return base;
267}
268int getBaseBoolVar(ParserState* pp, int i) {
269 int base = i;
270 BoolVarSpec* ivs = static_cast<BoolVarSpec*>(pp->boolvars[base].second);
271 while (ivs->alias) {
272 base = ivs->i;
273 ivs = static_cast<BoolVarSpec*>(pp->boolvars[base].second);
274 }
275 return base;
276}
277int getBaseFloatVar(ParserState* pp, int i) {
278 int base = i;
279 FloatVarSpec* ivs = static_cast<FloatVarSpec*>(pp->floatvars[base].second);
280 while (ivs->alias) {
281 base = ivs->i;
282 ivs = static_cast<FloatVarSpec*>(pp->floatvars[base].second);
283 }
284 return base;
285}
286int getBaseSetVar(ParserState* pp, int i) {
287 int base = i;
288 SetVarSpec* ivs = static_cast<SetVarSpec*>(pp->setvars[base].second);
289 while (ivs->alias) {
290 base = ivs->i;
291 ivs = static_cast<SetVarSpec*>(pp->setvars[base].second);
292 }
293 return base;
294}
295
296/*
297 * Initialize the root gecode space
298 *
299 */
300
301void initfg(ParserState* pp) {
302 if (!pp->hadError)
303 pp->fg->init(pp->intvars.size(),
304 pp->boolvars.size(),
305 pp->setvars.size(),
306 pp->floatvars.size());
307
308 for (unsigned int i=0; i<pp->intvars.size(); i++) {
309 if (!pp->hadError) {
310 try {
311 pp->fg->newIntVar(static_cast<IntVarSpec*>(pp->intvars[i].second));
312 } catch (Gecode::FlatZinc::Error& e) {
313 yyerror(pp, e.toString().c_str());
314 }
315 }
316 delete pp->intvars[i].second;
317 pp->intvars[i].second = NULL;
318 }
319 for (unsigned int i=0; i<pp->boolvars.size(); i++) {
320 if (!pp->hadError) {
321 try {
322 pp->fg->newBoolVar(
323 static_cast<BoolVarSpec*>(pp->boolvars[i].second));
324 } catch (Gecode::FlatZinc::Error& e) {
325 yyerror(pp, e.toString().c_str());
326 }
327 }
328 delete pp->boolvars[i].second;
329 pp->boolvars[i].second = NULL;
330 }
331 for (unsigned int i=0; i<pp->setvars.size(); i++) {
332 if (!pp->hadError) {
333 try {
334 pp->fg->newSetVar(static_cast<SetVarSpec*>(pp->setvars[i].second));
335 } catch (Gecode::FlatZinc::Error& e) {
336 yyerror(pp, e.toString().c_str());
337 }
338 }
339 delete pp->setvars[i].second;
340 pp->setvars[i].second = NULL;
341 }
342 for (unsigned int i=0; i<pp->floatvars.size(); i++) {
343 if (!pp->hadError) {
344 try {
345 pp->fg->newFloatVar(
346 static_cast<FloatVarSpec*>(pp->floatvars[i].second));
347 } catch (Gecode::FlatZinc::Error& e) {
348 yyerror(pp, e.toString().c_str());
349 }
350 }
351 delete pp->floatvars[i].second;
352 pp->floatvars[i].second = NULL;
353 }
354 if (pp->status_idx >= 0) {
355 pp->fg->restart_status = IntVarArray(*(pp->fg), 1);
356 pp->fg->restart_status[0] = pp->fg->iv[pp->status_idx];
357 }
358 if (!(pp->int_uniform.empty())) {
359 pp->fg->int_uniform_var = IntVarArray(*(pp->fg), pp->int_uniform.size());
360 pp->fg->int_uniform_lb = new int[pp->int_uniform.size()];
361 pp->fg->int_uniform_ub = new int[pp->int_uniform.size()];
362 for (int i = 0; i < pp->int_uniform.size(); ++i) {
363 pp->fg->int_uniform_lb[i] = pp->int_uniform[i][0];
364 pp->fg->int_uniform_ub[i] = pp->int_uniform[i][1];
365 pp->fg->int_uniform_var[i] = pp->fg->iv[pp->int_uniform[i][2]];
366 }
367 }
368 if (!(pp->int_sol.empty())) {
369 pp->fg->int_sol_orig = IntVarArray(*(pp->fg), pp->int_sol.size());
370 pp->fg->int_sol_var = IntVarArray(*(pp->fg), pp->int_sol.size());
371 for (int i = 0; i < pp->int_sol.size(); ++i) {
372 pp->fg->int_sol_orig[i] = pp->fg->iv[(pp->int_sol[i][0])];
373 pp->fg->int_sol_var[i] = pp->fg->iv[(pp->int_sol[i][1])];
374 }
375 }
376 if (!(pp->int_lastval.empty())) {
377 pp->fg->int_lastval_var = IntVarArray(*(pp->fg), pp->int_lastval.size());
378 pp->fg->int_lastval_val = new std::shared_ptr<int>[pp->int_lastval.size()];
379 for (int i = 0; i < pp->int_lastval.size(); ++i) {
380 pp->fg->int_lastval_var[i] = pp->fg->iv[(pp->int_lastval[i][1])];
381 pp->fg->int_lastval_val[i] = std::make_shared<int>();
382 LastVal::post(*(pp->fg), pp->fg->iv[(pp->int_lastval[i][0])], pp->fg->int_lastval_val[i]);
383 }
384 }
385 if (!pp->hadError) {
386 pp->fg->postConstraints(pp->domainConstraints);
387 pp->fg->postConstraints(pp->constraints);
388 }
389}
390
391void fillPrinter(ParserState& pp, Gecode::FlatZinc::Printer& p) {
392 p.init(pp.getOutput());
393 for (unsigned int i=0; i<pp.intvars.size(); i++) {
394 if (!pp.hadError) {
395 p.addIntVarName(pp.intvars[i].first);
396 }
397 }
398 for (unsigned int i=0; i<pp.boolvars.size(); i++) {
399 if (!pp.hadError) {
400 p.addBoolVarName(pp.boolvars[i].first);
401 }
402 }
403#ifdef GECODE_HAS_FLOAT_VARS
404 for (unsigned int i=0; i<pp.floatvars.size(); i++) {
405 if (!pp.hadError) {
406 p.addFloatVarName(pp.floatvars[i].first);
407 }
408 }
409#endif
410#ifdef GECODE_HAS_SET_VARS
411 for (unsigned int i=0; i<pp.setvars.size(); i++) {
412 if (!pp.hadError) {
413 p.addSetVarName(pp.setvars[i].first);
414 }
415 }
416#endif
417}
418
419AST::Node* arrayOutput(AST::Call* ann) {
420 AST::Array* a = NULL;
421
422 if (ann->args->isArray()) {
423 a = ann->args->getArray();
424 } else {
425 a = new AST::Array(ann->args);
426 }
427
428 std::ostringstream oss;
429
430 oss << "array" << a->a.size() << "d(";
431 for (unsigned int i=0; i<a->a.size(); i++) {
432 AST::SetLit* s = a->a[i]->getSet();
433 if (s->empty())
434 oss << "{}, ";
435 else if (s->interval)
436 oss << s->min << ".." << s->max << ", ";
437 else {
438 oss << "{";
439 for (unsigned int j=0; j<s->s.size(); j++) {
440 oss << s->s[j];
441 if (j<s->s.size()-1)
442 oss << ",";
443 }
444 oss << "}, ";
445 }
446 }
447
448 if (!ann->args->isArray()) {
449 a->a[0] = NULL;
450 delete a;
451 }
452 return new AST::String(oss.str());
453}
454
455/*
456 * The main program
457 *
458 */
459
460namespace Gecode { namespace FlatZinc {
461
462 FlatZincSpace* parse(const std::string& filename, Printer& p, std::ostream& err,
463 FlatZincSpace* fzs, Rnd& rnd) {
464#ifdef HAVE_MMAP
465 int fd;
466 char* data;
467 struct stat sbuf;
468 fd = open(filename.c_str(), O_RDONLY);
469 if (fd == -1) {
470 err << "Cannot open file " << filename << endl;
471 return NULL;
472 }
473 if (stat(filename.c_str(), &sbuf) == -1) {
474 err << "Cannot stat file " << filename << endl;
475 return NULL;
476 }
477 data = (char*)mmap((caddr_t)0, sbuf.st_size, PROT_READ, MAP_SHARED, fd,0);
478 if (data == (caddr_t)(-1)) {
479 err << "Cannot mmap file " << filename << endl;
480 return NULL;
481 }
482
483 if (fzs == NULL) {
484 fzs = new FlatZincSpace(rnd);
485 }
486 ParserState pp(data, sbuf.st_size, err, fzs);
487#else
488 std::ifstream file;
489 file.open(filename.c_str());
490 if (!file.is_open()) {
491 err << "Cannot open file " << filename << endl;
492 return NULL;
493 }
494 std::string s = string(istreambuf_iterator<char>(file),
495 istreambuf_iterator<char>());
496 if (fzs == NULL) {
497 fzs = new FlatZincSpace(rnd);
498 }
499 ParserState pp(s, err, fzs);
500#endif
501 yylex_init(&pp.yyscanner);
502 yyset_extra(&pp, pp.yyscanner);
503 // yydebug = 1;
504 yyparse(&pp);
505 fillPrinter(pp, p);
506
507 if (pp.yyscanner)
508 yylex_destroy(pp.yyscanner);
509 return pp.hadError ? NULL : pp.fg;
510 }
511
512 FlatZincSpace* parse(std::istream& is, Printer& p, std::ostream& err,
513 FlatZincSpace* fzs, Rnd& rnd) {
514 std::string s = string(istreambuf_iterator<char>(is),
515 istreambuf_iterator<char>());
516
517 if (fzs == NULL) {
518 fzs = new FlatZincSpace(rnd);
519 }
520 ParserState pp(s, err, fzs);
521 yylex_init(&pp.yyscanner);
522 yyset_extra(&pp, pp.yyscanner);
523 // yydebug = 1;
524 yyparse(&pp);
525 fillPrinter(pp, p);
526
527 if (pp.yyscanner)
528 yylex_destroy(pp.yyscanner);
529 return pp.hadError ? NULL : pp.fg;
530 }
531
532}}
533
534
535#line 536 "gecode/flatzinc/parser.tab.cpp"
536
537# ifndef YY_CAST
538# ifdef __cplusplus
539# define YY_CAST(Type, Val) static_cast<Type> (Val)
540# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
541# else
542# define YY_CAST(Type, Val) ((Type) (Val))
543# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
544# endif
545# endif
546# ifndef YY_NULLPTR
547# if defined __cplusplus
548# if 201103L <= __cplusplus
549# define YY_NULLPTR nullptr
550# else
551# define YY_NULLPTR 0
552# endif
553# else
554# define YY_NULLPTR ((void*)0)
555# endif
556# endif
557
558#include "parser.tab.hpp"
559/* Symbol kind. */
560enum yysymbol_kind_t
561{
562 YYSYMBOL_YYEMPTY = -2,
563 YYSYMBOL_YYEOF = 0, /* "end of file" */
564 YYSYMBOL_YYerror = 1, /* error */
565 YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
566 YYSYMBOL_FZ_INT_LIT = 3, /* FZ_INT_LIT */
567 YYSYMBOL_FZ_BOOL_LIT = 4, /* FZ_BOOL_LIT */
568 YYSYMBOL_FZ_FLOAT_LIT = 5, /* FZ_FLOAT_LIT */
569 YYSYMBOL_FZ_ID = 6, /* FZ_ID */
570 YYSYMBOL_FZ_U_ID = 7, /* FZ_U_ID */
571 YYSYMBOL_FZ_STRING_LIT = 8, /* FZ_STRING_LIT */
572 YYSYMBOL_FZ_VAR = 9, /* FZ_VAR */
573 YYSYMBOL_FZ_PAR = 10, /* FZ_PAR */
574 YYSYMBOL_FZ_ANNOTATION = 11, /* FZ_ANNOTATION */
575 YYSYMBOL_FZ_ANY = 12, /* FZ_ANY */
576 YYSYMBOL_FZ_ARRAY = 13, /* FZ_ARRAY */
577 YYSYMBOL_FZ_BOOL = 14, /* FZ_BOOL */
578 YYSYMBOL_FZ_CASE = 15, /* FZ_CASE */
579 YYSYMBOL_FZ_COLONCOLON = 16, /* FZ_COLONCOLON */
580 YYSYMBOL_FZ_CONSTRAINT = 17, /* FZ_CONSTRAINT */
581 YYSYMBOL_FZ_DEFAULT = 18, /* FZ_DEFAULT */
582 YYSYMBOL_FZ_DOTDOT = 19, /* FZ_DOTDOT */
583 YYSYMBOL_FZ_ELSE = 20, /* FZ_ELSE */
584 YYSYMBOL_FZ_ELSEIF = 21, /* FZ_ELSEIF */
585 YYSYMBOL_FZ_ENDIF = 22, /* FZ_ENDIF */
586 YYSYMBOL_FZ_ENUM = 23, /* FZ_ENUM */
587 YYSYMBOL_FZ_FLOAT = 24, /* FZ_FLOAT */
588 YYSYMBOL_FZ_FUNCTION = 25, /* FZ_FUNCTION */
589 YYSYMBOL_FZ_IF = 26, /* FZ_IF */
590 YYSYMBOL_FZ_INCLUDE = 27, /* FZ_INCLUDE */
591 YYSYMBOL_FZ_INT = 28, /* FZ_INT */
592 YYSYMBOL_FZ_LET = 29, /* FZ_LET */
593 YYSYMBOL_FZ_MAXIMIZE = 30, /* FZ_MAXIMIZE */
594 YYSYMBOL_FZ_MINIMIZE = 31, /* FZ_MINIMIZE */
595 YYSYMBOL_FZ_OF = 32, /* FZ_OF */
596 YYSYMBOL_FZ_SATISFY = 33, /* FZ_SATISFY */
597 YYSYMBOL_FZ_OUTPUT = 34, /* FZ_OUTPUT */
598 YYSYMBOL_FZ_PREDICATE = 35, /* FZ_PREDICATE */
599 YYSYMBOL_FZ_RECORD = 36, /* FZ_RECORD */
600 YYSYMBOL_FZ_SET = 37, /* FZ_SET */
601 YYSYMBOL_FZ_SHOW = 38, /* FZ_SHOW */
602 YYSYMBOL_FZ_SHOWCOND = 39, /* FZ_SHOWCOND */
603 YYSYMBOL_FZ_SOLVE = 40, /* FZ_SOLVE */
604 YYSYMBOL_FZ_STRING = 41, /* FZ_STRING */
605 YYSYMBOL_FZ_TEST = 42, /* FZ_TEST */
606 YYSYMBOL_FZ_THEN = 43, /* FZ_THEN */
607 YYSYMBOL_FZ_TUPLE = 44, /* FZ_TUPLE */
608 YYSYMBOL_FZ_TYPE = 45, /* FZ_TYPE */
609 YYSYMBOL_FZ_VARIANT_RECORD = 46, /* FZ_VARIANT_RECORD */
610 YYSYMBOL_FZ_WHERE = 47, /* FZ_WHERE */
611 YYSYMBOL_48_ = 48, /* ';' */
612 YYSYMBOL_49_ = 49, /* '(' */
613 YYSYMBOL_50_ = 50, /* ')' */
614 YYSYMBOL_51_ = 51, /* ',' */
615 YYSYMBOL_52_ = 52, /* ':' */
616 YYSYMBOL_53_ = 53, /* '[' */
617 YYSYMBOL_54_ = 54, /* ']' */
618 YYSYMBOL_55_ = 55, /* '=' */
619 YYSYMBOL_56_ = 56, /* '{' */
620 YYSYMBOL_57_ = 57, /* '}' */
621 YYSYMBOL_YYACCEPT = 58, /* $accept */
622 YYSYMBOL_model = 59, /* model */
623 YYSYMBOL_preddecl_items = 60, /* preddecl_items */
624 YYSYMBOL_preddecl_items_head = 61, /* preddecl_items_head */
625 YYSYMBOL_vardecl_items = 62, /* vardecl_items */
626 YYSYMBOL_vardecl_items_head = 63, /* vardecl_items_head */
627 YYSYMBOL_constraint_items = 64, /* constraint_items */
628 YYSYMBOL_constraint_items_head = 65, /* constraint_items_head */
629 YYSYMBOL_preddecl_item = 66, /* preddecl_item */
630 YYSYMBOL_pred_arg_list = 67, /* pred_arg_list */
631 YYSYMBOL_pred_arg_list_head = 68, /* pred_arg_list_head */
632 YYSYMBOL_pred_arg = 69, /* pred_arg */
633 YYSYMBOL_pred_arg_type = 70, /* pred_arg_type */
634 YYSYMBOL_pred_arg_simple_type = 71, /* pred_arg_simple_type */
635 YYSYMBOL_pred_array_init = 72, /* pred_array_init */
636 YYSYMBOL_pred_array_init_arg = 73, /* pred_array_init_arg */
637 YYSYMBOL_var_par_id = 74, /* var_par_id */
638 YYSYMBOL_vardecl_item = 75, /* vardecl_item */
639 YYSYMBOL_int_init = 76, /* int_init */
640 YYSYMBOL_int_init_list = 77, /* int_init_list */
641 YYSYMBOL_int_init_list_head = 78, /* int_init_list_head */
642 YYSYMBOL_list_tail = 79, /* list_tail */
643 YYSYMBOL_int_var_array_literal = 80, /* int_var_array_literal */
644 YYSYMBOL_float_init = 81, /* float_init */
645 YYSYMBOL_float_init_list = 82, /* float_init_list */
646 YYSYMBOL_float_init_list_head = 83, /* float_init_list_head */
647 YYSYMBOL_float_var_array_literal = 84, /* float_var_array_literal */
648 YYSYMBOL_bool_init = 85, /* bool_init */
649 YYSYMBOL_bool_init_list = 86, /* bool_init_list */
650 YYSYMBOL_bool_init_list_head = 87, /* bool_init_list_head */
651 YYSYMBOL_bool_var_array_literal = 88, /* bool_var_array_literal */
652 YYSYMBOL_set_init = 89, /* set_init */
653 YYSYMBOL_set_init_list = 90, /* set_init_list */
654 YYSYMBOL_set_init_list_head = 91, /* set_init_list_head */
655 YYSYMBOL_set_var_array_literal = 92, /* set_var_array_literal */
656 YYSYMBOL_vardecl_int_var_array_init = 93, /* vardecl_int_var_array_init */
657 YYSYMBOL_vardecl_bool_var_array_init = 94, /* vardecl_bool_var_array_init */
658 YYSYMBOL_vardecl_float_var_array_init = 95, /* vardecl_float_var_array_init */
659 YYSYMBOL_vardecl_set_var_array_init = 96, /* vardecl_set_var_array_init */
660 YYSYMBOL_constraint_item = 97, /* constraint_item */
661 YYSYMBOL_solve_item = 98, /* solve_item */
662 YYSYMBOL_int_ti_expr_tail = 99, /* int_ti_expr_tail */
663 YYSYMBOL_bool_ti_expr_tail = 100, /* bool_ti_expr_tail */
664 YYSYMBOL_float_ti_expr_tail = 101, /* float_ti_expr_tail */
665 YYSYMBOL_set_literal = 102, /* set_literal */
666 YYSYMBOL_int_list = 103, /* int_list */
667 YYSYMBOL_int_list_head = 104, /* int_list_head */
668 YYSYMBOL_bool_list = 105, /* bool_list */
669 YYSYMBOL_bool_list_head = 106, /* bool_list_head */
670 YYSYMBOL_float_list = 107, /* float_list */
671 YYSYMBOL_float_list_head = 108, /* float_list_head */
672 YYSYMBOL_set_literal_list = 109, /* set_literal_list */
673 YYSYMBOL_set_literal_list_head = 110, /* set_literal_list_head */
674 YYSYMBOL_flat_expr_list = 111, /* flat_expr_list */
675 YYSYMBOL_flat_expr = 112, /* flat_expr */
676 YYSYMBOL_non_array_expr_opt = 113, /* non_array_expr_opt */
677 YYSYMBOL_non_array_expr = 114, /* non_array_expr */
678 YYSYMBOL_non_array_expr_list = 115, /* non_array_expr_list */
679 YYSYMBOL_non_array_expr_list_head = 116, /* non_array_expr_list_head */
680 YYSYMBOL_solve_expr = 117, /* solve_expr */
681 YYSYMBOL_minmax = 118, /* minmax */
682 YYSYMBOL_annotations = 119, /* annotations */
683 YYSYMBOL_annotations_head = 120, /* annotations_head */
684 YYSYMBOL_annotation = 121, /* annotation */
685 YYSYMBOL_annotation_list = 122, /* annotation_list */
686 YYSYMBOL_annotation_expr = 123, /* annotation_expr */
687 YYSYMBOL_annotation_list_tail = 124, /* annotation_list_tail */
688 YYSYMBOL_ann_non_array_expr = 125 /* ann_non_array_expr */
689};
690typedef enum yysymbol_kind_t yysymbol_kind_t;
691
692
693
694
695#ifdef short
696# undef short
697#endif
698
699/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
700 <limits.h> and (if available) <stdint.h> are included
701 so that the code can choose integer types of a good width. */
702
703#ifndef __PTRDIFF_MAX__
704# include <limits.h> /* INFRINGES ON USER NAME SPACE */
705# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
706# include <stdint.h> /* INFRINGES ON USER NAME SPACE */
707# define YY_STDINT_H
708# endif
709#endif
710
711/* Narrow types that promote to a signed type and that can represent a
712 signed or unsigned integer of at least N bits. In tables they can
713 save space and decrease cache pressure. Promoting to a signed type
714 helps avoid bugs in integer arithmetic. */
715
716#ifdef __INT_LEAST8_MAX__
717typedef __INT_LEAST8_TYPE__ yytype_int8;
718#elif defined YY_STDINT_H
719typedef int_least8_t yytype_int8;
720#else
721typedef signed char yytype_int8;
722#endif
723
724#ifdef __INT_LEAST16_MAX__
725typedef __INT_LEAST16_TYPE__ yytype_int16;
726#elif defined YY_STDINT_H
727typedef int_least16_t yytype_int16;
728#else
729typedef short yytype_int16;
730#endif
731
732#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
733typedef __UINT_LEAST8_TYPE__ yytype_uint8;
734#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
735 && UINT_LEAST8_MAX <= INT_MAX)
736typedef uint_least8_t yytype_uint8;
737#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
738typedef unsigned char yytype_uint8;
739#else
740typedef short yytype_uint8;
741#endif
742
743#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
744typedef __UINT_LEAST16_TYPE__ yytype_uint16;
745#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
746 && UINT_LEAST16_MAX <= INT_MAX)
747typedef uint_least16_t yytype_uint16;
748#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
749typedef unsigned short yytype_uint16;
750#else
751typedef int yytype_uint16;
752#endif
753
754#ifndef YYPTRDIFF_T
755# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
756# define YYPTRDIFF_T __PTRDIFF_TYPE__
757# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
758# elif defined PTRDIFF_MAX
759# ifndef ptrdiff_t
760# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
761# endif
762# define YYPTRDIFF_T ptrdiff_t
763# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
764# else
765# define YYPTRDIFF_T long
766# define YYPTRDIFF_MAXIMUM LONG_MAX
767# endif
768#endif
769
770#ifndef YYSIZE_T
771# ifdef __SIZE_TYPE__
772# define YYSIZE_T __SIZE_TYPE__
773# elif defined size_t
774# define YYSIZE_T size_t
775# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
776# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
777# define YYSIZE_T size_t
778# else
779# define YYSIZE_T unsigned
780# endif
781#endif
782
783#define YYSIZE_MAXIMUM \
784 YY_CAST (YYPTRDIFF_T, \
785 (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
786 ? YYPTRDIFF_MAXIMUM \
787 : YY_CAST (YYSIZE_T, -1)))
788
789#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
790
791
792/* Stored state numbers (used for stacks). */
793typedef yytype_int16 yy_state_t;
794
795/* State numbers in computations. */
796typedef int yy_state_fast_t;
797
798#ifndef YY_
799# if defined YYENABLE_NLS && YYENABLE_NLS
800# if ENABLE_NLS
801# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
802# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
803# endif
804# endif
805# ifndef YY_
806# define YY_(Msgid) Msgid
807# endif
808#endif
809
810
811#ifndef YY_ATTRIBUTE_PURE
812# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
813# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
814# else
815# define YY_ATTRIBUTE_PURE
816# endif
817#endif
818
819#ifndef YY_ATTRIBUTE_UNUSED
820# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
821# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
822# else
823# define YY_ATTRIBUTE_UNUSED
824# endif
825#endif
826
827/* Suppress unused-variable warnings by "using" E. */
828#if ! defined lint || defined __GNUC__
829# define YYUSE(E) ((void) (E))
830#else
831# define YYUSE(E) /* empty */
832#endif
833
834#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
835/* Suppress an incorrect diagnostic about yylval being uninitialized. */
836# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
837 _Pragma ("GCC diagnostic push") \
838 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
839 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
840# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
841 _Pragma ("GCC diagnostic pop")
842#else
843# define YY_INITIAL_VALUE(Value) Value
844#endif
845#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
846# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
847# define YY_IGNORE_MAYBE_UNINITIALIZED_END
848#endif
849#ifndef YY_INITIAL_VALUE
850# define YY_INITIAL_VALUE(Value) /* Nothing. */
851#endif
852
853#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
854# define YY_IGNORE_USELESS_CAST_BEGIN \
855 _Pragma ("GCC diagnostic push") \
856 _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
857# define YY_IGNORE_USELESS_CAST_END \
858 _Pragma ("GCC diagnostic pop")
859#endif
860#ifndef YY_IGNORE_USELESS_CAST_BEGIN
861# define YY_IGNORE_USELESS_CAST_BEGIN
862# define YY_IGNORE_USELESS_CAST_END
863#endif
864
865
866#define YY_ASSERT(E) ((void) (0 && (E)))
867
868#if 1
869
870/* The parser invokes alloca or malloc; define the necessary symbols. */
871
872# ifdef YYSTACK_USE_ALLOCA
873# if YYSTACK_USE_ALLOCA
874# ifdef __GNUC__
875# define YYSTACK_ALLOC __builtin_alloca
876# elif defined __BUILTIN_VA_ARG_INCR
877# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
878# elif defined _AIX
879# define YYSTACK_ALLOC __alloca
880# elif defined _MSC_VER
881# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
882# define alloca _alloca
883# else
884# define YYSTACK_ALLOC alloca
885# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
886# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
887 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
888# ifndef EXIT_SUCCESS
889# define EXIT_SUCCESS 0
890# endif
891# endif
892# endif
893# endif
894# endif
895
896# ifdef YYSTACK_ALLOC
897 /* Pacify GCC's 'empty if-body' warning. */
898# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
899# ifndef YYSTACK_ALLOC_MAXIMUM
900 /* The OS might guarantee only one guard page at the bottom of the stack,
901 and a page size can be as small as 4096 bytes. So we cannot safely
902 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
903 to allow for a few compiler-allocated temporary stack slots. */
904# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
905# endif
906# else
907# define YYSTACK_ALLOC YYMALLOC
908# define YYSTACK_FREE YYFREE
909# ifndef YYSTACK_ALLOC_MAXIMUM
910# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
911# endif
912# if (defined __cplusplus && ! defined EXIT_SUCCESS \
913 && ! ((defined YYMALLOC || defined malloc) \
914 && (defined YYFREE || defined free)))
915# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
916# ifndef EXIT_SUCCESS
917# define EXIT_SUCCESS 0
918# endif
919# endif
920# ifndef YYMALLOC
921# define YYMALLOC malloc
922# if ! defined malloc && ! defined EXIT_SUCCESS
923void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
924# endif
925# endif
926# ifndef YYFREE
927# define YYFREE free
928# if ! defined free && ! defined EXIT_SUCCESS
929void free (void *); /* INFRINGES ON USER NAME SPACE */
930# endif
931# endif
932# endif
933#endif /* 1 */
934
935#if (! defined yyoverflow \
936 && (! defined __cplusplus \
937 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
938
939/* A type that is properly aligned for any stack member. */
940union yyalloc
941{
942 yy_state_t yyss_alloc;
943 YYSTYPE yyvs_alloc;
944};
945
946/* The size of the maximum gap between one aligned stack and the next. */
947# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
948
949/* The size of an array large to enough to hold all stacks, each with
950 N elements. */
951# define YYSTACK_BYTES(N) \
952 ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
953 + YYSTACK_GAP_MAXIMUM)
954
955# define YYCOPY_NEEDED 1
956
957/* Relocate STACK from its old location to the new one. The
958 local variables YYSIZE and YYSTACKSIZE give the old and new number of
959 elements in the stack, and YYPTR gives the new location of the
960 stack. Advance YYPTR to a properly aligned location for the next
961 stack. */
962# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
963 do \
964 { \
965 YYPTRDIFF_T yynewbytes; \
966 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
967 Stack = &yyptr->Stack_alloc; \
968 yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
969 yyptr += yynewbytes / YYSIZEOF (*yyptr); \
970 } \
971 while (0)
972
973#endif
974
975#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
976/* Copy COUNT objects from SRC to DST. The source and destination do
977 not overlap. */
978# ifndef YYCOPY
979# if defined __GNUC__ && 1 < __GNUC__
980# define YYCOPY(Dst, Src, Count) \
981 __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
982# else
983# define YYCOPY(Dst, Src, Count) \
984 do \
985 { \
986 YYPTRDIFF_T yyi; \
987 for (yyi = 0; yyi < (Count); yyi++) \
988 (Dst)[yyi] = (Src)[yyi]; \
989 } \
990 while (0)
991# endif
992# endif
993#endif /* !YYCOPY_NEEDED */
994
995/* YYFINAL -- State number of the termination state. */
996#define YYFINAL 7
997/* YYLAST -- Last index in YYTABLE. */
998#define YYLAST 360
999
1000/* YYNTOKENS -- Number of terminals. */
1001#define YYNTOKENS 58
1002/* YYNNTS -- Number of nonterminals. */
1003#define YYNNTS 68
1004/* YYNRULES -- Number of rules. */
1005#define YYNRULES 162
1006/* YYNSTATES -- Number of states. */
1007#define YYNSTATES 347
1008
1009/* YYMAXUTOK -- Last valid token kind. */
1010#define YYMAXUTOK 302
1011
1012
1013/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
1014 as returned by yylex, with out-of-bounds checking. */
1015#define YYTRANSLATE(YYX) \
1016 (0 <= (YYX) && (YYX) <= YYMAXUTOK \
1017 ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
1018 : YYSYMBOL_YYUNDEF)
1019
1020/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
1021 as returned by yylex. */
1022static const yytype_int8 yytranslate[] =
1023{
1024 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1025 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1026 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1027 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1028 49, 50, 2, 2, 51, 2, 2, 2, 2, 2,
1029 2, 2, 2, 2, 2, 2, 2, 2, 52, 48,
1030 2, 55, 2, 2, 2, 2, 2, 2, 2, 2,
1031 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1032 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1033 2, 53, 2, 54, 2, 2, 2, 2, 2, 2,
1034 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1035 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1036 2, 2, 2, 56, 2, 57, 2, 2, 2, 2,
1037 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1038 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1039 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1040 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1041 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1042 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1043 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1044 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1045 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1046 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1047 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1048 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1049 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1050 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1051 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1052 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1053 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1054 45, 46, 47
1055};
1056
1057#if YYDEBUG
1058 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
1059static const yytype_int16 yyrline[] =
1060{
1061 0, 604, 604, 606, 608, 611, 612, 614, 616, 619,
1062 620, 622, 624, 627, 628, 635, 638, 640, 643, 644,
1063 647, 651, 652, 653, 654, 657, 659, 661, 662, 665,
1064 666, 669, 670, 676, 676, 679, 711, 743, 782, 815,
1065 824, 834, 843, 855, 925, 991, 1062, 1130, 1151, 1171,
1066 1191, 1214, 1218, 1233, 1257, 1258, 1262, 1264, 1267, 1267,
1067 1269, 1273, 1275, 1290, 1313, 1314, 1318, 1320, 1324, 1328,
1068 1330, 1345, 1368, 1369, 1373, 1375, 1378, 1381, 1383, 1398,
1069 1421, 1422, 1426, 1428, 1431, 1436, 1437, 1442, 1443, 1448,
1070 1449, 1454, 1455, 1459, 1583, 1597, 1622, 1624, 1626, 1632,
1071 1634, 1647, 1649, 1658, 1660, 1667, 1668, 1672, 1674, 1679,
1072 1680, 1684, 1686, 1691, 1692, 1696, 1698, 1703, 1704, 1708,
1073 1710, 1718, 1720, 1724, 1726, 1731, 1732, 1736, 1738, 1740,
1074 1742, 1744, 1840, 1855, 1856, 1860, 1862, 1870, 1904, 1911,
1075 1918, 1944, 1945, 1953, 1954, 1958, 1960, 1964, 1968, 1972,
1076 1974, 1978, 1980, 1982, 1985, 1985, 1988, 1990, 1992, 1994,
1077 1996, 2102, 2113
1078};
1079#endif
1080
1081/** Accessing symbol of state STATE. */
1082#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
1083
1084#if 1
1085/* The user-facing name of the symbol whose (internal) number is
1086 YYSYMBOL. No bounds checking. */
1087static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
1088
1089/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1090 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1091static const char *const yytname[] =
1092{
1093 "\"end of file\"", "error", "\"invalid token\"", "FZ_INT_LIT",
1094 "FZ_BOOL_LIT", "FZ_FLOAT_LIT", "FZ_ID", "FZ_U_ID", "FZ_STRING_LIT",
1095 "FZ_VAR", "FZ_PAR", "FZ_ANNOTATION", "FZ_ANY", "FZ_ARRAY", "FZ_BOOL",
1096 "FZ_CASE", "FZ_COLONCOLON", "FZ_CONSTRAINT", "FZ_DEFAULT", "FZ_DOTDOT",
1097 "FZ_ELSE", "FZ_ELSEIF", "FZ_ENDIF", "FZ_ENUM", "FZ_FLOAT", "FZ_FUNCTION",
1098 "FZ_IF", "FZ_INCLUDE", "FZ_INT", "FZ_LET", "FZ_MAXIMIZE", "FZ_MINIMIZE",
1099 "FZ_OF", "FZ_SATISFY", "FZ_OUTPUT", "FZ_PREDICATE", "FZ_RECORD",
1100 "FZ_SET", "FZ_SHOW", "FZ_SHOWCOND", "FZ_SOLVE", "FZ_STRING", "FZ_TEST",
1101 "FZ_THEN", "FZ_TUPLE", "FZ_TYPE", "FZ_VARIANT_RECORD", "FZ_WHERE", "';'",
1102 "'('", "')'", "','", "':'", "'['", "']'", "'='", "'{'", "'}'", "$accept",
1103 "model", "preddecl_items", "preddecl_items_head", "vardecl_items",
1104 "vardecl_items_head", "constraint_items", "constraint_items_head",
1105 "preddecl_item", "pred_arg_list", "pred_arg_list_head", "pred_arg",
1106 "pred_arg_type", "pred_arg_simple_type", "pred_array_init",
1107 "pred_array_init_arg", "var_par_id", "vardecl_item", "int_init",
1108 "int_init_list", "int_init_list_head", "list_tail",
1109 "int_var_array_literal", "float_init", "float_init_list",
1110 "float_init_list_head", "float_var_array_literal", "bool_init",
1111 "bool_init_list", "bool_init_list_head", "bool_var_array_literal",
1112 "set_init", "set_init_list", "set_init_list_head",
1113 "set_var_array_literal", "vardecl_int_var_array_init",
1114 "vardecl_bool_var_array_init", "vardecl_float_var_array_init",
1115 "vardecl_set_var_array_init", "constraint_item", "solve_item",
1116 "int_ti_expr_tail", "bool_ti_expr_tail", "float_ti_expr_tail",
1117 "set_literal", "int_list", "int_list_head", "bool_list",
1118 "bool_list_head", "float_list", "float_list_head", "set_literal_list",
1119 "set_literal_list_head", "flat_expr_list", "flat_expr",
1120 "non_array_expr_opt", "non_array_expr", "non_array_expr_list",
1121 "non_array_expr_list_head", "solve_expr", "minmax", "annotations",
1122 "annotations_head", "annotation", "annotation_list", "annotation_expr",
1123 "annotation_list_tail", "ann_non_array_expr", YY_NULLPTR
1124};
1125
1126static const char *
1127yysymbol_name (yysymbol_kind_t yysymbol)
1128{
1129 return yytname[yysymbol];
1130}
1131#endif
1132
1133#ifdef YYPRINT
1134/* YYTOKNUM[NUM] -- (External) token number corresponding to the
1135 (internal) symbol number NUM (which must be that of a token). */
1136static const yytype_int16 yytoknum[] =
1137{
1138 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1139 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1140 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1141 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1142 295, 296, 297, 298, 299, 300, 301, 302, 59, 40,
1143 41, 44, 58, 91, 93, 61, 123, 125
1144};
1145#endif
1146
1147#define YYPACT_NINF (-123)
1148
1149#define yypact_value_is_default(Yyn) \
1150 ((Yyn) == YYPACT_NINF)
1151
1152#define YYTABLE_NINF (-1)
1153
1154#define yytable_value_is_error(Yyn) \
1155 0
1156
1157 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1158 STATE-NUM. */
1159static const yytype_int16 yypact[] =
1160{
1161 -25, 13, 30, 253, -25, -20, -13, -123, 102, -7,
1162 6, 18, 38, 87, 108, 253, 79, 81, -123, 84,
1163 116, 118, -123, -123, -123, 113, 111, 91, 95, 101,
1164 161, 126, 126, 126, 149, 173, 140, 108, 137, 138,
1165 -123, -123, 217, 134, -123, -123, 157, 185, 142, 139,
1166 -123, 146, -123, -123, 188, 194, 78, -123, -123, 147,
1167 152, 154, 126, 126, 126, 189, -123, -123, 191, 191,
1168 191, 158, 160, 191, 163, 170, -123, -123, -123, 56,
1169 78, -123, 84, -123, 211, -123, -123, 171, -123, 218,
1170 -123, 220, 172, 191, 191, 191, 223, 35, 179, 216,
1171 181, 187, 126, 169, 119, -123, -123, 208, -123, 28,
1172 -123, -123, -123, -123, 126, -123, -123, -123, 192, 192,
1173 192, 186, 224, -123, -123, 197, -123, 46, 185, 196,
1174 -123, -123, -123, -123, 57, 35, 57, 57, 191, 224,
1175 -123, -123, 57, 200, -123, 106, -123, -123, -123, -123,
1176 -123, 156, 255, 56, 227, 191, 57, -123, -123, -123,
1177 228, 258, 35, -123, -123, 212, 214, 19, -123, -123,
1178 -123, -123, 210, -123, 221, 231, 57, 191, 169, -123,
1179 -123, 225, -123, -123, -123, 114, 192, -123, 20, -123,
1180 117, 35, 229, -123, 232, 57, -123, 57, -123, 233,
1181 -123, -123, 271, 217, -123, -123, 141, 236, 237, 239,
1182 247, -123, 35, -123, -123, -123, -123, -123, -123, 238,
1183 -123, 261, 242, 243, 244, 126, 126, 126, 257, -123,
1184 78, 126, 126, 126, 191, 191, 191, 245, 246, 191,
1185 191, 191, 248, 249, 250, 126, 126, 251, 254, 256,
1186 259, 260, 262, 191, 191, 263, -123, 264, -123, 265,
1187 -123, 295, 296, 185, 266, 267, 62, -123, 88, -123,
1188 177, -123, 269, 154, -123, 270, 268, 272, 274, 275,
1189 -123, -123, 276, -123, 277, 279, -123, 280, -123, 278,
1190 283, -123, 282, -123, 284, 285, -123, -123, -123, 297,
1191 -123, -123, 17, 11, -123, 305, -123, 62, -123, 307,
1192 -123, 88, -123, 311, -123, 177, -123, -123, 224, -123,
1193 286, 288, 289, -123, 287, 292, -123, 290, -123, 291,
1194 -123, 293, -123, -123, 17, -123, 317, -123, 11, -123,
1195 -123, -123, -123, -123, 294, -123, -123
1196};
1197
1198 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
1199 Performed when YYTABLE does not specify something else to do. Zero
1200 means the default is an error. */
1201static const yytype_uint8 yydefact[] =
1202{
1203 3, 0, 0, 7, 4, 0, 0, 1, 0, 0,
1204 0, 0, 0, 0, 11, 8, 0, 0, 5, 16,
1205 0, 0, 99, 101, 96, 0, 105, 0, 0, 0,
1206 0, 0, 0, 0, 0, 0, 0, 12, 0, 0,
1207 9, 6, 0, 0, 27, 28, 0, 105, 0, 58,
1208 18, 0, 24, 25, 0, 0, 0, 107, 111, 0,
1209 58, 58, 0, 0, 0, 0, 33, 34, 143, 143,
1210 143, 0, 0, 143, 0, 0, 13, 10, 23, 0,
1211 0, 15, 59, 17, 0, 98, 102, 0, 97, 59,
1212 106, 59, 0, 143, 143, 143, 0, 0, 0, 144,
1213 0, 0, 0, 0, 0, 2, 14, 0, 31, 0,
1214 29, 26, 19, 20, 0, 108, 112, 100, 125, 125,
1215 125, 0, 157, 156, 158, 33, 162, 0, 105, 160,
1216 159, 145, 148, 151, 0, 0, 0, 0, 143, 128,
1217 127, 129, 133, 131, 130, 0, 121, 123, 142, 141,
1218 94, 0, 0, 0, 0, 143, 0, 35, 36, 37,
1219 0, 0, 0, 152, 149, 154, 0, 0, 41, 146,
1220 40, 39, 0, 135, 0, 58, 0, 143, 0, 138,
1221 139, 137, 95, 32, 30, 0, 125, 126, 0, 104,
1222 0, 155, 0, 103, 0, 0, 124, 59, 134, 0,
1223 93, 122, 0, 0, 21, 38, 0, 0, 0, 0,
1224 0, 147, 0, 150, 153, 161, 42, 136, 132, 0,
1225 22, 0, 0, 0, 0, 0, 0, 0, 0, 140,
1226 0, 0, 0, 0, 143, 143, 143, 0, 0, 143,
1227 143, 143, 0, 0, 0, 0, 0, 85, 87, 89,
1228 0, 0, 0, 143, 143, 0, 43, 0, 44, 0,
1229 45, 109, 113, 105, 0, 91, 54, 86, 72, 88,
1230 64, 90, 0, 58, 115, 0, 58, 0, 0, 0,
1231 46, 51, 52, 56, 0, 58, 69, 70, 74, 0,
1232 58, 61, 62, 66, 0, 58, 48, 110, 49, 59,
1233 114, 47, 117, 80, 92, 0, 60, 59, 55, 0,
1234 76, 59, 73, 0, 68, 59, 65, 116, 0, 119,
1235 0, 58, 78, 82, 0, 58, 77, 0, 57, 0,
1236 75, 0, 67, 50, 59, 118, 0, 84, 59, 81,
1237 53, 71, 63, 120, 0, 83, 79
1238};
1239
1240 /* YYPGOTO[NTERM-NUM]. */
1241static const yytype_int16 yypgoto[] =
1242{
1243 -123, -123, -123, -123, -123, -123, -123, -123, 321, -123,
1244 -123, 273, -123, -37, -123, 184, -31, 331, 42, -123,
1245 -123, -57, -123, -15, -123, -123, -123, 39, -123, -123,
1246 -123, 14, -123, -123, -123, -123, -123, -123, -123, 314,
1247 -123, 0, 148, 150, -90, -122, -123, -123, 92, -123,
1248 -123, -123, -123, -123, 180, -108, -121, -123, -123, -123,
1249 -123, 16, -123, -88, 195, -123, -123, 193
1250};
1251
1252 /* YYDEFGOTO[NTERM-NUM]. */
1253static const yytype_int16 yydefgoto[] =
1254{
1255 -1, 2, 3, 4, 14, 15, 36, 37, 5, 48,
1256 49, 50, 51, 52, 109, 110, 143, 16, 283, 284,
1257 285, 83, 267, 293, 294, 295, 271, 288, 289, 290,
1258 269, 323, 324, 325, 304, 256, 258, 260, 280, 38,
1259 74, 53, 28, 29, 144, 59, 60, 272, 61, 275,
1260 276, 320, 321, 145, 146, 157, 147, 174, 175, 182,
1261 151, 98, 99, 164, 165, 132, 192, 133
1262};
1263
1264 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
1265 positive, shift that token. If negative, reduce the rule whose
1266 number is the opposite. If YYTABLE_NINF, syntax error. */
1267static const yytype_int16 yytable[] =
1268{
1269 68, 69, 70, 90, 92, 78, 166, 130, 27, 131,
1270 1, 158, 159, 168, 318, 170, 171, 66, 67, 6,
1271 318, 173, 122, 123, 124, 66, 67, 126, 18, 206,
1272 7, 93, 94, 95, 207, 187, 19, 130, 122, 123,
1273 124, 125, 67, 126, 208, 130, 30, 169, 209, 122,
1274 123, 124, 125, 67, 126, 199, 87, 210, 31, 107,
1275 139, 140, 141, 66, 67, 281, 129, 128, 66, 67,
1276 32, 138, 130, 128, 216, 128, 217, 130, 205, 153,
1277 111, 20, 154, 155, 108, 100, 101, 20, 127, 104,
1278 33, 128, 286, 42, 66, 67, 129, 43, 44, 127,
1279 163, 130, 128, 213, 129, 20, 24, 21, 45, 118,
1280 119, 120, 24, 128, 57, 58, 22, 20, 198, 34,
1281 181, 46, 130, 203, 213, 35, 23, 40, 44, 41,
1282 24, 129, 66, 67, 47, 54, 129, 55, 45, 25,
1283 47, 277, 24, 62, 20, 56, 21, 63, 204, 148,
1284 149, 46, 150, 64, 172, 22, 177, 178, 26, 179,
1285 129, 180, 66, 67, 65, 23, 220, 211, 212, 24,
1286 47, 186, 139, 140, 141, 66, 67, 71, 221, 72,
1287 73, 129, 291, 66, 67, 76, 77, 79, 57, 80,
1288 82, 85, 81, 200, 234, 235, 236, 26, 84, 86,
1289 239, 240, 241, 89, 88, 91, 222, 97, 96, 103,
1290 102, 105, 319, 326, 253, 254, 297, 113, 106, 300,
1291 20, 115, 142, 114, 116, 128, 121, 152, 308, 117,
1292 238, 44, 135, 312, 134, 282, 136, 287, 316, 292,
1293 160, 45, 137, 161, 343, 24, 162, 156, 326, 167,
1294 242, 243, 244, 176, 46, 247, 248, 249, 183, 185,
1295 188, 189, 8, 191, 335, 195, 9, 10, 339, 264,
1296 265, 193, 322, 47, 219, 196, 282, 11, 202, 228,
1297 287, 12, 197, 214, 292, 237, 215, 218, 225, 226,
1298 13, 227, 229, 230, 231, 232, 233, 245, 246, 58,
1299 332, 274, 317, 250, 251, 252, 255, 322, 327, 257,
1300 329, 259, 261, 262, 331, 263, 266, 268, 270, 299,
1301 344, 278, 279, 296, 298, 17, 301, 302, 303, 305,
1302 307, 306, 310, 309, 311, 313, 315, 184, 314, 334,
1303 333, 337, 336, 338, 340, 341, 39, 342, 346, 328,
1304 330, 75, 345, 273, 223, 112, 224, 190, 201, 0,
1305 194
1306};
1307
1308static const yytype_int16 yycheck[] =
1309{
1310 31, 32, 33, 60, 61, 42, 128, 97, 8, 97,
1311 35, 119, 120, 134, 3, 136, 137, 6, 7, 6,
1312 3, 142, 3, 4, 5, 6, 7, 8, 48, 9,
1313 0, 62, 63, 64, 14, 156, 49, 127, 3, 4,
1314 5, 6, 7, 8, 24, 135, 53, 135, 28, 3,
1315 4, 5, 6, 7, 8, 176, 56, 37, 52, 3,
1316 3, 4, 5, 6, 7, 3, 97, 56, 6, 7,
1317 52, 102, 162, 56, 195, 56, 197, 167, 186, 51,
1318 80, 3, 54, 114, 28, 69, 70, 3, 53, 73,
1319 52, 56, 4, 9, 6, 7, 127, 13, 14, 53,
1320 54, 191, 56, 191, 135, 3, 28, 5, 24, 93,
1321 94, 95, 28, 56, 3, 4, 14, 3, 175, 32,
1322 151, 37, 212, 9, 212, 17, 24, 48, 14, 48,
1323 28, 162, 6, 7, 56, 19, 167, 19, 24, 37,
1324 56, 263, 28, 52, 3, 32, 5, 52, 185, 30,
1325 31, 37, 33, 52, 138, 14, 50, 51, 56, 3,
1326 191, 5, 6, 7, 3, 24, 203, 50, 51, 28,
1327 56, 155, 3, 4, 5, 6, 7, 28, 37, 6,
1328 40, 212, 5, 6, 7, 48, 48, 53, 3, 32,
1329 51, 3, 50, 177, 225, 226, 227, 56, 52, 5,
1330 231, 232, 233, 51, 57, 51, 206, 16, 19, 49,
1331 52, 48, 302, 303, 245, 246, 273, 6, 48, 276,
1332 3, 3, 53, 52, 4, 56, 3, 19, 285, 57,
1333 230, 14, 16, 290, 55, 266, 55, 268, 295, 270,
1334 54, 24, 55, 19, 334, 28, 49, 55, 338, 53,
1335 234, 235, 236, 53, 37, 239, 240, 241, 3, 32,
1336 32, 3, 9, 51, 321, 55, 13, 14, 325, 253,
1337 254, 57, 303, 56, 3, 54, 307, 24, 53, 32,
1338 311, 28, 51, 54, 315, 28, 54, 54, 52, 52,
1339 37, 52, 54, 32, 52, 52, 52, 52, 52, 4,
1340 315, 5, 5, 55, 55, 55, 55, 338, 3, 55,
1341 3, 55, 53, 53, 3, 53, 53, 53, 53, 51,
1342 3, 55, 55, 54, 54, 4, 54, 53, 53, 53,
1343 51, 54, 54, 53, 51, 53, 51, 153, 54, 51,
1344 54, 54, 53, 51, 54, 54, 15, 54, 54, 307,
1345 311, 37, 338, 261, 206, 82, 206, 162, 178, -1,
1346 167
1347};
1348
1349 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
1350 symbol of state STATE-NUM. */
1351static const yytype_int8 yystos[] =
1352{
1353 0, 35, 59, 60, 61, 66, 6, 0, 9, 13,
1354 14, 24, 28, 37, 62, 63, 75, 66, 48, 49,
1355 3, 5, 14, 24, 28, 37, 56, 99, 100, 101,
1356 53, 52, 52, 52, 32, 17, 64, 65, 97, 75,
1357 48, 48, 9, 13, 14, 24, 37, 56, 67, 68,
1358 69, 70, 71, 99, 19, 19, 32, 3, 4, 103,
1359 104, 106, 52, 52, 52, 3, 6, 7, 74, 74,
1360 74, 28, 6, 40, 98, 97, 48, 48, 71, 53,
1361 32, 50, 51, 79, 52, 3, 5, 99, 57, 51,
1362 79, 51, 79, 74, 74, 74, 19, 16, 119, 120,
1363 119, 119, 52, 49, 119, 48, 48, 3, 28, 72,
1364 73, 99, 69, 6, 52, 3, 4, 57, 119, 119,
1365 119, 3, 3, 4, 5, 6, 8, 53, 56, 74,
1366 102, 121, 123, 125, 55, 16, 55, 55, 74, 3,
1367 4, 5, 53, 74, 102, 111, 112, 114, 30, 31,
1368 33, 118, 19, 51, 54, 74, 55, 113, 113, 113,
1369 54, 19, 49, 54, 121, 122, 103, 53, 114, 121,
1370 114, 114, 119, 114, 115, 116, 53, 50, 51, 3,
1371 5, 74, 117, 3, 73, 32, 119, 114, 32, 3,
1372 122, 51, 124, 57, 125, 55, 54, 51, 79, 114,
1373 119, 112, 53, 9, 71, 113, 9, 14, 24, 28,
1374 37, 50, 51, 121, 54, 54, 114, 114, 54, 3,
1375 71, 37, 99, 100, 101, 52, 52, 52, 32, 54,
1376 32, 52, 52, 52, 74, 74, 74, 28, 99, 74,
1377 74, 74, 119, 119, 119, 52, 52, 119, 119, 119,
1378 55, 55, 55, 74, 74, 55, 93, 55, 94, 55,
1379 95, 53, 53, 53, 119, 119, 53, 80, 53, 88,
1380 53, 84, 105, 106, 5, 107, 108, 103, 55, 55,
1381 96, 3, 74, 76, 77, 78, 4, 74, 85, 86,
1382 87, 5, 74, 81, 82, 83, 54, 79, 54, 51,
1383 79, 54, 53, 53, 92, 53, 54, 51, 79, 53,
1384 54, 51, 79, 53, 54, 51, 79, 5, 3, 102,
1385 109, 110, 74, 89, 90, 91, 102, 3, 76, 3,
1386 85, 3, 81, 54, 51, 79, 53, 54, 51, 79,
1387 54, 54, 54, 102, 3, 89, 54
1388};
1389
1390 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1391static const yytype_int8 yyr1[] =
1392{
1393 0, 58, 59, 60, 60, 61, 61, 62, 62, 63,
1394 63, 64, 64, 65, 65, 66, 67, 67, 68, 68,
1395 69, 70, 70, 70, 70, 71, 71, 71, 71, 72,
1396 72, 73, 73, 74, 74, 75, 75, 75, 75, 75,
1397 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
1398 75, 76, 76, 76, 77, 77, 78, 78, 79, 79,
1399 80, 81, 81, 81, 82, 82, 83, 83, 84, 85,
1400 85, 85, 86, 86, 87, 87, 88, 89, 89, 89,
1401 90, 90, 91, 91, 92, 93, 93, 94, 94, 95,
1402 95, 96, 96, 97, 98, 98, 99, 99, 99, 100,
1403 100, 101, 101, 102, 102, 103, 103, 104, 104, 105,
1404 105, 106, 106, 107, 107, 108, 108, 109, 109, 110,
1405 110, 111, 111, 112, 112, 113, 113, 114, 114, 114,
1406 114, 114, 114, 115, 115, 116, 116, 117, 117, 117,
1407 117, 118, 118, 119, 119, 120, 120, 121, 121, 122,
1408 122, 123, 123, 123, 124, 124, 125, 125, 125, 125,
1409 125, 125, 125
1410};
1411
1412 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
1413static const yytype_int8 yyr2[] =
1414{
1415 0, 2, 5, 0, 1, 2, 3, 0, 1, 2,
1416 3, 0, 1, 2, 3, 5, 0, 2, 1, 3,
1417 3, 6, 7, 2, 1, 1, 3, 1, 1, 1,
1418 3, 1, 3, 1, 1, 6, 6, 6, 8, 6,
1419 6, 6, 8, 13, 13, 13, 15, 15, 15, 15,
1420 17, 1, 1, 4, 0, 2, 1, 3, 0, 1,
1421 3, 1, 1, 4, 0, 2, 1, 3, 3, 1,
1422 1, 4, 0, 2, 1, 3, 3, 1, 1, 4,
1423 0, 2, 1, 3, 3, 0, 2, 0, 2, 0,
1424 2, 0, 2, 6, 3, 4, 1, 3, 3, 1,
1425 4, 1, 3, 3, 3, 0, 2, 1, 3, 0,
1426 2, 1, 3, 0, 2, 1, 3, 0, 2, 1,
1427 3, 1, 3, 1, 3, 0, 2, 1, 1, 1,
1428 1, 1, 4, 0, 2, 1, 3, 1, 1, 1,
1429 4, 1, 1, 0, 1, 2, 3, 4, 1, 1,
1430 3, 1, 2, 4, 0, 1, 1, 1, 1, 1,
1431 1, 4, 1
1432};
1433
1434
1435enum { YYENOMEM = -2 };
1436
1437#define yyerrok (yyerrstatus = 0)
1438#define yyclearin (yychar = YYEMPTY)
1439
1440#define YYACCEPT goto yyacceptlab
1441#define YYABORT goto yyabortlab
1442#define YYERROR goto yyerrorlab
1443
1444
1445#define YYRECOVERING() (!!yyerrstatus)
1446
1447#define YYBACKUP(Token, Value) \
1448 do \
1449 if (yychar == YYEMPTY) \
1450 { \
1451 yychar = (Token); \
1452 yylval = (Value); \
1453 YYPOPSTACK (yylen); \
1454 yystate = *yyssp; \
1455 goto yybackup; \
1456 } \
1457 else \
1458 { \
1459 yyerror (parm, YY_("syntax error: cannot back up")); \
1460 YYERROR; \
1461 } \
1462 while (0)
1463
1464/* Backward compatibility with an undocumented macro.
1465 Use YYerror or YYUNDEF. */
1466#define YYERRCODE YYUNDEF
1467
1468
1469/* Enable debugging if requested. */
1470#if YYDEBUG
1471
1472# ifndef YYFPRINTF
1473# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1474# define YYFPRINTF fprintf
1475# endif
1476
1477# define YYDPRINTF(Args) \
1478do { \
1479 if (yydebug) \
1480 YYFPRINTF Args; \
1481} while (0)
1482
1483/* This macro is provided for backward compatibility. */
1484# ifndef YY_LOCATION_PRINT
1485# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1486# endif
1487
1488
1489# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
1490do { \
1491 if (yydebug) \
1492 { \
1493 YYFPRINTF (stderr, "%s ", Title); \
1494 yy_symbol_print (stderr, \
1495 Kind, Value, parm); \
1496 YYFPRINTF (stderr, "\n"); \
1497 } \
1498} while (0)
1499
1500
1501/*-----------------------------------.
1502| Print this symbol's value on YYO. |
1503`-----------------------------------*/
1504
1505static void
1506yy_symbol_value_print (FILE *yyo,
1507 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, void *parm)
1508{
1509 FILE *yyoutput = yyo;
1510 YYUSE (yyoutput);
1511 YYUSE (parm);
1512 if (!yyvaluep)
1513 return;
1514# ifdef YYPRINT
1515 if (yykind < YYNTOKENS)
1516 YYPRINT (yyo, yytoknum[yykind], *yyvaluep);
1517# endif
1518 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1519 YYUSE (yykind);
1520 YY_IGNORE_MAYBE_UNINITIALIZED_END
1521}
1522
1523
1524/*---------------------------.
1525| Print this symbol on YYO. |
1526`---------------------------*/
1527
1528static void
1529yy_symbol_print (FILE *yyo,
1530 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, void *parm)
1531{
1532 YYFPRINTF (yyo, "%s %s (",
1533 yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
1534
1535 yy_symbol_value_print (yyo, yykind, yyvaluep, parm);
1536 YYFPRINTF (yyo, ")");
1537}
1538
1539/*------------------------------------------------------------------.
1540| yy_stack_print -- Print the state stack from its BOTTOM up to its |
1541| TOP (included). |
1542`------------------------------------------------------------------*/
1543
1544static void
1545yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
1546{
1547 YYFPRINTF (stderr, "Stack now");
1548 for (; yybottom <= yytop; yybottom++)
1549 {
1550 int yybot = *yybottom;
1551 YYFPRINTF (stderr, " %d", yybot);
1552 }
1553 YYFPRINTF (stderr, "\n");
1554}
1555
1556# define YY_STACK_PRINT(Bottom, Top) \
1557do { \
1558 if (yydebug) \
1559 yy_stack_print ((Bottom), (Top)); \
1560} while (0)
1561
1562
1563/*------------------------------------------------.
1564| Report that the YYRULE is going to be reduced. |
1565`------------------------------------------------*/
1566
1567static void
1568yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
1569 int yyrule, void *parm)
1570{
1571 int yylno = yyrline[yyrule];
1572 int yynrhs = yyr2[yyrule];
1573 int yyi;
1574 YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
1575 yyrule - 1, yylno);
1576 /* The symbols being reduced. */
1577 for (yyi = 0; yyi < yynrhs; yyi++)
1578 {
1579 YYFPRINTF (stderr, " $%d = ", yyi + 1);
1580 yy_symbol_print (stderr,
1581 YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
1582 &yyvsp[(yyi + 1) - (yynrhs)], parm);
1583 YYFPRINTF (stderr, "\n");
1584 }
1585}
1586
1587# define YY_REDUCE_PRINT(Rule) \
1588do { \
1589 if (yydebug) \
1590 yy_reduce_print (yyssp, yyvsp, Rule, parm); \
1591} while (0)
1592
1593/* Nonzero means print parse trace. It is left uninitialized so that
1594 multiple parsers can coexist. */
1595int yydebug;
1596#else /* !YYDEBUG */
1597# define YYDPRINTF(Args) ((void) 0)
1598# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
1599# define YY_STACK_PRINT(Bottom, Top)
1600# define YY_REDUCE_PRINT(Rule)
1601#endif /* !YYDEBUG */
1602
1603
1604/* YYINITDEPTH -- initial size of the parser's stacks. */
1605#ifndef YYINITDEPTH
1606# define YYINITDEPTH 200
1607#endif
1608
1609/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1610 if the built-in stack extension method is used).
1611
1612 Do not make this value too large; the results are undefined if
1613 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1614 evaluated with infinite-precision integer arithmetic. */
1615
1616#ifndef YYMAXDEPTH
1617# define YYMAXDEPTH 10000
1618#endif
1619
1620
1621/* Context of a parse error. */
1622typedef struct
1623{
1624 yy_state_t *yyssp;
1625 yysymbol_kind_t yytoken;
1626} yypcontext_t;
1627
1628/* Put in YYARG at most YYARGN of the expected tokens given the
1629 current YYCTX, and return the number of tokens stored in YYARG. If
1630 YYARG is null, return the number of expected tokens (guaranteed to
1631 be less than YYNTOKENS). Return YYENOMEM on memory exhaustion.
1632 Return 0 if there are more than YYARGN expected tokens, yet fill
1633 YYARG up to YYARGN. */
1634static int
1635yypcontext_expected_tokens (const yypcontext_t *yyctx,
1636 yysymbol_kind_t yyarg[], int yyargn)
1637{
1638 /* Actual size of YYARG. */
1639 int yycount = 0;
1640 int yyn = yypact[+*yyctx->yyssp];
1641 if (!yypact_value_is_default (yyn))
1642 {
1643 /* Start YYX at -YYN if negative to avoid negative indexes in
1644 YYCHECK. In other words, skip the first -YYN actions for
1645 this state because they are default actions. */
1646 int yyxbegin = yyn < 0 ? -yyn : 0;
1647 /* Stay within bounds of both yycheck and yytname. */
1648 int yychecklim = YYLAST - yyn + 1;
1649 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1650 int yyx;
1651 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1652 if (yycheck[yyx + yyn] == yyx && yyx != YYSYMBOL_YYerror
1653 && !yytable_value_is_error (yytable[yyx + yyn]))
1654 {
1655 if (!yyarg)
1656 ++yycount;
1657 else if (yycount == yyargn)
1658 return 0;
1659 else
1660 yyarg[yycount++] = YY_CAST (yysymbol_kind_t, yyx);
1661 }
1662 }
1663 if (yyarg && yycount == 0 && 0 < yyargn)
1664 yyarg[0] = YYSYMBOL_YYEMPTY;
1665 return yycount;
1666}
1667
1668
1669
1670
1671#ifndef yystrlen
1672# if defined __GLIBC__ && defined _STRING_H
1673# define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S)))
1674# else
1675/* Return the length of YYSTR. */
1676static YYPTRDIFF_T
1677yystrlen (const char *yystr)
1678{
1679 YYPTRDIFF_T yylen;
1680 for (yylen = 0; yystr[yylen]; yylen++)
1681 continue;
1682 return yylen;
1683}
1684# endif
1685#endif
1686
1687#ifndef yystpcpy
1688# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1689# define yystpcpy stpcpy
1690# else
1691/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1692 YYDEST. */
1693static char *
1694yystpcpy (char *yydest, const char *yysrc)
1695{
1696 char *yyd = yydest;
1697 const char *yys = yysrc;
1698
1699 while ((*yyd++ = *yys++) != '\0')
1700 continue;
1701
1702 return yyd - 1;
1703}
1704# endif
1705#endif
1706
1707#ifndef yytnamerr
1708/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1709 quotes and backslashes, so that it's suitable for yyerror. The
1710 heuristic is that double-quoting is unnecessary unless the string
1711 contains an apostrophe, a comma, or backslash (other than
1712 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1713 null, do not copy; instead, return the length of what the result
1714 would have been. */
1715static YYPTRDIFF_T
1716yytnamerr (char *yyres, const char *yystr)
1717{
1718 if (*yystr == '"')
1719 {
1720 YYPTRDIFF_T yyn = 0;
1721 char const *yyp = yystr;
1722 for (;;)
1723 switch (*++yyp)
1724 {
1725 case '\'':
1726 case ',':
1727 goto do_not_strip_quotes;
1728
1729 case '\\':
1730 if (*++yyp != '\\')
1731 goto do_not_strip_quotes;
1732 else
1733 goto append;
1734
1735 append:
1736 default:
1737 if (yyres)
1738 yyres[yyn] = *yyp;
1739 yyn++;
1740 break;
1741
1742 case '"':
1743 if (yyres)
1744 yyres[yyn] = '\0';
1745 return yyn;
1746 }
1747 do_not_strip_quotes: ;
1748 }
1749
1750 if (yyres)
1751 return yystpcpy (yyres, yystr) - yyres;
1752 else
1753 return yystrlen (yystr);
1754}
1755#endif
1756
1757
1758static int
1759yy_syntax_error_arguments (const yypcontext_t *yyctx,
1760 yysymbol_kind_t yyarg[], int yyargn)
1761{
1762 /* Actual size of YYARG. */
1763 int yycount = 0;
1764 /* There are many possibilities here to consider:
1765 - If this state is a consistent state with a default action, then
1766 the only way this function was invoked is if the default action
1767 is an error action. In that case, don't check for expected
1768 tokens because there are none.
1769 - The only way there can be no lookahead present (in yychar) is if
1770 this state is a consistent state with a default action. Thus,
1771 detecting the absence of a lookahead is sufficient to determine
1772 that there is no unexpected or expected token to report. In that
1773 case, just report a simple "syntax error".
1774 - Don't assume there isn't a lookahead just because this state is a
1775 consistent state with a default action. There might have been a
1776 previous inconsistent state, consistent state with a non-default
1777 action, or user semantic action that manipulated yychar.
1778 - Of course, the expected token list depends on states to have
1779 correct lookahead information, and it depends on the parser not
1780 to perform extra reductions after fetching a lookahead from the
1781 scanner and before detecting a syntax error. Thus, state merging
1782 (from LALR or IELR) and default reductions corrupt the expected
1783 token list. However, the list is correct for canonical LR with
1784 one exception: it will still contain any token that will not be
1785 accepted due to an error action in a later state.
1786 */
1787 if (yyctx->yytoken != YYSYMBOL_YYEMPTY)
1788 {
1789 int yyn;
1790 if (yyarg)
1791 yyarg[yycount] = yyctx->yytoken;
1792 ++yycount;
1793 yyn = yypcontext_expected_tokens (yyctx,
1794 yyarg ? yyarg + 1 : yyarg, yyargn - 1);
1795 if (yyn == YYENOMEM)
1796 return YYENOMEM;
1797 else
1798 yycount += yyn;
1799 }
1800 return yycount;
1801}
1802
1803/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1804 about the unexpected token YYTOKEN for the state stack whose top is
1805 YYSSP.
1806
1807 Return 0 if *YYMSG was successfully written. Return -1 if *YYMSG is
1808 not large enough to hold the message. In that case, also set
1809 *YYMSG_ALLOC to the required number of bytes. Return YYENOMEM if the
1810 required number of bytes is too large to store. */
1811static int
1812yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
1813 const yypcontext_t *yyctx)
1814{
1815 enum { YYARGS_MAX = 5 };
1816 /* Internationalized format string. */
1817 const char *yyformat = YY_NULLPTR;
1818 /* Arguments of yyformat: reported tokens (one for the "unexpected",
1819 one per "expected"). */
1820 yysymbol_kind_t yyarg[YYARGS_MAX];
1821 /* Cumulated lengths of YYARG. */
1822 YYPTRDIFF_T yysize = 0;
1823
1824 /* Actual size of YYARG. */
1825 int yycount = yy_syntax_error_arguments (yyctx, yyarg, YYARGS_MAX);
1826 if (yycount == YYENOMEM)
1827 return YYENOMEM;
1828
1829 switch (yycount)
1830 {
1831#define YYCASE_(N, S) \
1832 case N: \
1833 yyformat = S; \
1834 break
1835 default: /* Avoid compiler warnings. */
1836 YYCASE_(0, YY_("syntax error"));
1837 YYCASE_(1, YY_("syntax error, unexpected %s"));
1838 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1839 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1840 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1841 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1842#undef YYCASE_
1843 }
1844
1845 /* Compute error message size. Don't count the "%s"s, but reserve
1846 room for the terminator. */
1847 yysize = yystrlen (yyformat) - 2 * yycount + 1;
1848 {
1849 int yyi;
1850 for (yyi = 0; yyi < yycount; ++yyi)
1851 {
1852 YYPTRDIFF_T yysize1
1853 = yysize + yytnamerr (YY_NULLPTR, yytname[yyarg[yyi]]);
1854 if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1855 yysize = yysize1;
1856 else
1857 return YYENOMEM;
1858 }
1859 }
1860
1861 if (*yymsg_alloc < yysize)
1862 {
1863 *yymsg_alloc = 2 * yysize;
1864 if (! (yysize <= *yymsg_alloc
1865 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1866 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1867 return -1;
1868 }
1869
1870 /* Avoid sprintf, as that infringes on the user's name space.
1871 Don't have undefined behavior even if the translation
1872 produced a string with the wrong number of "%s"s. */
1873 {
1874 char *yyp = *yymsg;
1875 int yyi = 0;
1876 while ((*yyp = *yyformat) != '\0')
1877 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1878 {
1879 yyp += yytnamerr (yyp, yytname[yyarg[yyi++]]);
1880 yyformat += 2;
1881 }
1882 else
1883 {
1884 ++yyp;
1885 ++yyformat;
1886 }
1887 }
1888 return 0;
1889}
1890
1891
1892/*-----------------------------------------------.
1893| Release the memory associated to this symbol. |
1894`-----------------------------------------------*/
1895
1896static void
1897yydestruct (const char *yymsg,
1898 yysymbol_kind_t yykind, YYSTYPE *yyvaluep, void *parm)
1899{
1900 YYUSE (yyvaluep);
1901 YYUSE (parm);
1902 if (!yymsg)
1903 yymsg = "Deleting";
1904 YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
1905
1906 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1907 YYUSE (yykind);
1908 YY_IGNORE_MAYBE_UNINITIALIZED_END
1909}
1910
1911
1912
1913
1914
1915
1916/*----------.
1917| yyparse. |
1918`----------*/
1919
1920int
1921yyparse (void *parm)
1922{
1923/* Lookahead token kind. */
1924int yychar;
1925
1926
1927/* The semantic value of the lookahead symbol. */
1928/* Default value used for initialization, for pacifying older GCCs
1929 or non-GCC compilers. */
1930YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1931YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1932
1933 /* Number of syntax errors so far. */
1934 int yynerrs = 0;
1935
1936 yy_state_fast_t yystate = 0;
1937 /* Number of tokens to shift before error messages enabled. */
1938 int yyerrstatus = 0;
1939
1940 /* Refer to the stacks through separate pointers, to allow yyoverflow
1941 to reallocate them elsewhere. */
1942
1943 /* Their size. */
1944 YYPTRDIFF_T yystacksize = YYINITDEPTH;
1945
1946 /* The state stack: array, bottom, top. */
1947 yy_state_t yyssa[YYINITDEPTH];
1948 yy_state_t *yyss = yyssa;
1949 yy_state_t *yyssp = yyss;
1950
1951 /* The semantic value stack: array, bottom, top. */
1952 YYSTYPE yyvsa[YYINITDEPTH];
1953 YYSTYPE *yyvs = yyvsa;
1954 YYSTYPE *yyvsp = yyvs;
1955
1956 int yyn;
1957 /* The return value of yyparse. */
1958 int yyresult;
1959 /* Lookahead symbol kind. */
1960 yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
1961 /* The variables used to return semantic value and location from the
1962 action routines. */
1963 YYSTYPE yyval;
1964
1965 /* Buffer for error messages, and its allocated size. */
1966 char yymsgbuf[128];
1967 char *yymsg = yymsgbuf;
1968 YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf;
1969
1970#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1971
1972 /* The number of symbols on the RHS of the reduced rule.
1973 Keep to zero when no symbol should be popped. */
1974 int yylen = 0;
1975
1976 YYDPRINTF ((stderr, "Starting parse\n"));
1977
1978 yychar = YYEMPTY; /* Cause a token to be read. */
1979 goto yysetstate;
1980
1981
1982/*------------------------------------------------------------.
1983| yynewstate -- push a new state, which is found in yystate. |
1984`------------------------------------------------------------*/
1985yynewstate:
1986 /* In all cases, when you get here, the value and location stacks
1987 have just been pushed. So pushing a state here evens the stacks. */
1988 yyssp++;
1989
1990
1991/*--------------------------------------------------------------------.
1992| yysetstate -- set current state (the top of the stack) to yystate. |
1993`--------------------------------------------------------------------*/
1994yysetstate:
1995 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1996 YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1997 YY_IGNORE_USELESS_CAST_BEGIN
1998 *yyssp = YY_CAST (yy_state_t, yystate);
1999 YY_IGNORE_USELESS_CAST_END
2000 YY_STACK_PRINT (yyss, yyssp);
2001
2002 if (yyss + yystacksize - 1 <= yyssp)
2003#if !defined yyoverflow && !defined YYSTACK_RELOCATE
2004 goto yyexhaustedlab;
2005#else
2006 {
2007 /* Get the current used size of the three stacks, in elements. */
2008 YYPTRDIFF_T yysize = yyssp - yyss + 1;
2009
2010# if defined yyoverflow
2011 {
2012 /* Give user a chance to reallocate the stack. Use copies of
2013 these so that the &'s don't force the real ones into
2014 memory. */
2015 yy_state_t *yyss1 = yyss;
2016 YYSTYPE *yyvs1 = yyvs;
2017
2018 /* Each stack pointer address is followed by the size of the
2019 data in use in that stack, in bytes. This used to be a
2020 conditional around just the two extra args, but that might
2021 be undefined if yyoverflow is a macro. */
2022 yyoverflow (YY_("memory exhausted"),
2023 &yyss1, yysize * YYSIZEOF (*yyssp),
2024 &yyvs1, yysize * YYSIZEOF (*yyvsp),
2025 &yystacksize);
2026 yyss = yyss1;
2027 yyvs = yyvs1;
2028 }
2029# else /* defined YYSTACK_RELOCATE */
2030 /* Extend the stack our own way. */
2031 if (YYMAXDEPTH <= yystacksize)
2032 goto yyexhaustedlab;
2033 yystacksize *= 2;
2034 if (YYMAXDEPTH < yystacksize)
2035 yystacksize = YYMAXDEPTH;
2036
2037 {
2038 yy_state_t *yyss1 = yyss;
2039 union yyalloc *yyptr =
2040 YY_CAST (union yyalloc *,
2041 YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
2042 if (! yyptr)
2043 goto yyexhaustedlab;
2044 YYSTACK_RELOCATE (yyss_alloc, yyss);
2045 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
2046# undef YYSTACK_RELOCATE
2047 if (yyss1 != yyssa)
2048 YYSTACK_FREE (yyss1);
2049 }
2050# endif
2051
2052 yyssp = yyss + yysize - 1;
2053 yyvsp = yyvs + yysize - 1;
2054
2055 YY_IGNORE_USELESS_CAST_BEGIN
2056 YYDPRINTF ((stderr, "Stack size increased to %ld\n",
2057 YY_CAST (long, yystacksize)));
2058 YY_IGNORE_USELESS_CAST_END
2059
2060 if (yyss + yystacksize - 1 <= yyssp)
2061 YYABORT;
2062 }
2063#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
2064
2065 if (yystate == YYFINAL)
2066 YYACCEPT;
2067
2068 goto yybackup;
2069
2070
2071/*-----------.
2072| yybackup. |
2073`-----------*/
2074yybackup:
2075 /* Do appropriate processing given the current state. Read a
2076 lookahead token if we need one and don't already have one. */
2077
2078 /* First try to decide what to do without reference to lookahead token. */
2079 yyn = yypact[yystate];
2080 if (yypact_value_is_default (yyn))
2081 goto yydefault;
2082
2083 /* Not known => get a lookahead token if don't already have one. */
2084
2085 /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
2086 if (yychar == YYEMPTY)
2087 {
2088 YYDPRINTF ((stderr, "Reading a token\n"));
2089 yychar = yylex (&yylval, YYLEX_PARAM);
2090 }
2091
2092 if (yychar <= YYEOF)
2093 {
2094 yychar = YYEOF;
2095 yytoken = YYSYMBOL_YYEOF;
2096 YYDPRINTF ((stderr, "Now at end of input.\n"));
2097 }
2098 else if (yychar == YYerror)
2099 {
2100 /* The scanner already issued an error message, process directly
2101 to error recovery. But do not keep the error token as
2102 lookahead, it is too special and may lead us to an endless
2103 loop in error recovery. */
2104 yychar = YYUNDEF;
2105 yytoken = YYSYMBOL_YYerror;
2106 goto yyerrlab1;
2107 }
2108 else
2109 {
2110 yytoken = YYTRANSLATE (yychar);
2111 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
2112 }
2113
2114 /* If the proper action on seeing token YYTOKEN is to reduce or to
2115 detect an error, take that action. */
2116 yyn += yytoken;
2117 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
2118 goto yydefault;
2119 yyn = yytable[yyn];
2120 if (yyn <= 0)
2121 {
2122 if (yytable_value_is_error (yyn))
2123 goto yyerrlab;
2124 yyn = -yyn;
2125 goto yyreduce;
2126 }
2127
2128 /* Count tokens shifted since error; after three, turn off error
2129 status. */
2130 if (yyerrstatus)
2131 yyerrstatus--;
2132
2133 /* Shift the lookahead token. */
2134 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
2135 yystate = yyn;
2136 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2137 *++yyvsp = yylval;
2138 YY_IGNORE_MAYBE_UNINITIALIZED_END
2139
2140 /* Discard the shifted token. */
2141 yychar = YYEMPTY;
2142 goto yynewstate;
2143
2144
2145/*-----------------------------------------------------------.
2146| yydefault -- do the default action for the current state. |
2147`-----------------------------------------------------------*/
2148yydefault:
2149 yyn = yydefact[yystate];
2150 if (yyn == 0)
2151 goto yyerrlab;
2152 goto yyreduce;
2153
2154
2155/*-----------------------------.
2156| yyreduce -- do a reduction. |
2157`-----------------------------*/
2158yyreduce:
2159 /* yyn is the number of a rule to reduce with. */
2160 yylen = yyr2[yyn];
2161
2162 /* If YYLEN is nonzero, implement the default value of the action:
2163 '$$ = $1'.
2164
2165 Otherwise, the following line sets YYVAL to garbage.
2166 This behavior is undocumented and Bison
2167 users should not rely upon it. Assigning to YYVAL
2168 unconditionally makes the parser a bit smaller, and it avoids a
2169 GCC warning that YYVAL may be used uninitialized. */
2170 yyval = yyvsp[1-yylen];
2171
2172
2173 YY_REDUCE_PRINT (yyn);
2174 switch (yyn)
2175 {
2176 case 15: /* preddecl_item: FZ_PREDICATE FZ_ID '(' pred_arg_list ')' */
2177#line 636 "../gecode/flatzinc/parser.yxx"
2178 { free((yyvsp[-3].sValue)); }
2179#line 2180 "gecode/flatzinc/parser.tab.cpp"
2180 break;
2181
2182 case 20: /* pred_arg: pred_arg_type ':' FZ_ID */
2183#line 648 "../gecode/flatzinc/parser.yxx"
2184 { free((yyvsp[0].sValue)); }
2185#line 2186 "gecode/flatzinc/parser.tab.cpp"
2186 break;
2187
2188 case 25: /* pred_arg_simple_type: int_ti_expr_tail */
2189#line 658 "../gecode/flatzinc/parser.yxx"
2190 { if ((yyvsp[0].oSet)()) delete (yyvsp[0].oSet).some(); }
2191#line 2192 "gecode/flatzinc/parser.tab.cpp"
2192 break;
2193
2194 case 26: /* pred_arg_simple_type: FZ_SET FZ_OF int_ti_expr_tail */
2195#line 660 "../gecode/flatzinc/parser.yxx"
2196 { if ((yyvsp[0].oSet)()) delete (yyvsp[0].oSet).some(); }
2197#line 2198 "gecode/flatzinc/parser.tab.cpp"
2198 break;
2199
2200 case 35: /* vardecl_item: FZ_VAR int_ti_expr_tail ':' var_par_id annotations non_array_expr_opt */
2201#line 680 "../gecode/flatzinc/parser.yxx"
2202 {
2203 ParserState* pp = static_cast<ParserState*>(parm);
2204 bool print = (yyvsp[-1].argVec) != NULL && (yyvsp[-1].argVec)->hasAtom("output_var");
2205 bool funcDep = (yyvsp[-1].argVec) != NULL && (yyvsp[-1].argVec)->hasAtom("is_defined_var");
2206 yyassert(pp,
2207 pp->symbols.put((yyvsp[-2].sValue), se_iv(pp->intvars.size())),
2208 "Duplicate symbol");
2209 if (print) {
2210 pp->output(std::string((yyvsp[-2].sValue)), new AST::IntVar(pp->intvars.size()));
2211 }
2212 if ((yyvsp[0].oArg)()) {
2213 AST::Node* arg = (yyvsp[0].oArg).some();
2214 if (arg->isInt()) {
2215 pp->intvars.push_back(varspec((yyvsp[-2].sValue),
2216 new IntVarSpec(arg->getInt(),!print,funcDep)));
2217 } else if (arg->isIntVar()) {
2218 pp->intvars.push_back(varspec((yyvsp[-2].sValue),
2219 new IntVarSpec(Alias(arg->getIntVar()),!print,funcDep)));
2220 } else {
2221 yyassert(pp, false, "Invalid var int initializer");
2222 }
2223 if (!pp->hadError)
2224 addDomainConstraint(pp, "int_in",
2225 new AST::IntVar(pp->intvars.size()-1), (yyvsp[-4].oSet));
2226 delete arg;
2227 } else {
2228 pp->intvars.push_back(varspec((yyvsp[-2].sValue),
2229 new IntVarSpec((yyvsp[-4].oSet),!print,funcDep)));
2230 }
2231 delete (yyvsp[-1].argVec); free((yyvsp[-2].sValue));
2232 }
2233#line 2234 "gecode/flatzinc/parser.tab.cpp"
2234 break;
2235
2236 case 36: /* vardecl_item: FZ_VAR bool_ti_expr_tail ':' var_par_id annotations non_array_expr_opt */
2237#line 712 "../gecode/flatzinc/parser.yxx"
2238 {
2239 ParserState* pp = static_cast<ParserState*>(parm);
2240 bool print = (yyvsp[-1].argVec) != NULL && (yyvsp[-1].argVec)->hasAtom("output_var");
2241 bool funcDep = (yyvsp[-1].argVec) != NULL && (yyvsp[-1].argVec)->hasAtom("is_defined_var");
2242 yyassert(pp,
2243 pp->symbols.put((yyvsp[-2].sValue), se_bv(pp->boolvars.size())),
2244 "Duplicate symbol");
2245 if (print) {
2246 pp->output(std::string((yyvsp[-2].sValue)), new AST::BoolVar(pp->boolvars.size()));
2247 }
2248 if ((yyvsp[0].oArg)()) {
2249 AST::Node* arg = (yyvsp[0].oArg).some();
2250 if (arg->isBool()) {
2251 pp->boolvars.push_back(varspec((yyvsp[-2].sValue),
2252 new BoolVarSpec(arg->getBool(),!print,funcDep)));
2253 } else if (arg->isBoolVar()) {
2254 pp->boolvars.push_back(varspec((yyvsp[-2].sValue),
2255 new BoolVarSpec(Alias(arg->getBoolVar()),!print,funcDep)));
2256 } else {
2257 yyassert(pp, false, "Invalid var bool initializer");
2258 }
2259 if (!pp->hadError)
2260 addDomainConstraint(pp, "int_in",
2261 new AST::BoolVar(pp->boolvars.size()-1), (yyvsp[-4].oSet));
2262 delete arg;
2263 } else {
2264 pp->boolvars.push_back(varspec((yyvsp[-2].sValue),
2265 new BoolVarSpec((yyvsp[-4].oSet),!print,funcDep)));
2266 }
2267 delete (yyvsp[-1].argVec); free((yyvsp[-2].sValue));
2268 }
2269#line 2270 "gecode/flatzinc/parser.tab.cpp"
2270 break;
2271
2272 case 37: /* vardecl_item: FZ_VAR float_ti_expr_tail ':' var_par_id annotations non_array_expr_opt */
2273#line 744 "../gecode/flatzinc/parser.yxx"
2274 {
2275 ParserState* pp = static_cast<ParserState*>(parm);
2276 bool print = (yyvsp[-1].argVec) != NULL && (yyvsp[-1].argVec)->hasAtom("output_var");
2277 bool funcDep = (yyvsp[-1].argVec) != NULL && (yyvsp[-1].argVec)->hasAtom("is_defined_var");
2278 yyassert(pp,
2279 pp->symbols.put((yyvsp[-2].sValue), se_fv(pp->floatvars.size())),
2280 "Duplicate symbol");
2281 if (print) {
2282 pp->output(std::string((yyvsp[-2].sValue)),
2283 new AST::FloatVar(pp->floatvars.size()));
2284 }
2285 if ((yyvsp[0].oArg)()) {
2286 AST::Node* arg = (yyvsp[0].oArg).some();
2287 if (arg->isFloat()) {
2288 pp->floatvars.push_back(varspec((yyvsp[-2].sValue),
2289 new FloatVarSpec(arg->getFloat(),!print,funcDep)));
2290 } else if (arg->isFloatVar()) {
2291 pp->floatvars.push_back(varspec((yyvsp[-2].sValue),
2292 new FloatVarSpec(
2293 Alias(arg->getFloatVar()),!print,funcDep)));
2294 } else {
2295 yyassert(pp, false, "Invalid var float initializer");
2296 }
2297 if (!pp->hadError && (yyvsp[-4].oPFloat)()) {
2298 AST::FloatVar* fv = new AST::FloatVar(pp->floatvars.size()-1);
2299 addDomainConstraint(pp, fv, (yyvsp[-4].oPFloat));
2300 }
2301 delete arg;
2302 } else {
2303 Option<std::pair<double,double> > dom =
2304 (yyvsp[-4].oPFloat)() ? Option<std::pair<double,double> >::some(*(yyvsp[-4].oPFloat).some())
2305 : Option<std::pair<double,double> >::none();
2306 if ((yyvsp[-4].oPFloat)()) delete (yyvsp[-4].oPFloat).some();
2307 pp->floatvars.push_back(varspec((yyvsp[-2].sValue),
2308 new FloatVarSpec(dom,!print,funcDep)));
2309 }
2310 delete (yyvsp[-1].argVec); free((yyvsp[-2].sValue));
2311 }
2312#line 2313 "gecode/flatzinc/parser.tab.cpp"
2313 break;
2314
2315 case 38: /* vardecl_item: FZ_VAR FZ_SET FZ_OF int_ti_expr_tail ':' var_par_id annotations non_array_expr_opt */
2316#line 783 "../gecode/flatzinc/parser.yxx"
2317 {
2318 ParserState* pp = static_cast<ParserState*>(parm);
2319 bool print = (yyvsp[-1].argVec) != NULL && (yyvsp[-1].argVec)->hasAtom("output_var");
2320 bool funcDep = (yyvsp[-1].argVec) != NULL && (yyvsp[-1].argVec)->hasAtom("is_defined_var");
2321 yyassert(pp,
2322 pp->symbols.put((yyvsp[-2].sValue), se_sv(pp->setvars.size())),
2323 "Duplicate symbol");
2324 if (print) {
2325 pp->output(std::string((yyvsp[-2].sValue)), new AST::SetVar(pp->setvars.size()));
2326 }
2327 if ((yyvsp[0].oArg)()) {
2328 AST::Node* arg = (yyvsp[0].oArg).some();
2329 if (arg->isSet()) {
2330 pp->setvars.push_back(varspec((yyvsp[-2].sValue),
2331 new SetVarSpec(arg->getSet(),!print,funcDep)));
2332 } else if (arg->isSetVar()) {
2333 pp->setvars.push_back(varspec((yyvsp[-2].sValue),
2334 new SetVarSpec(Alias(arg->getSetVar()),!print,funcDep)));
2335 delete arg;
2336 } else {
2337 yyassert(pp, false, "Invalid var set initializer");
2338 delete arg;
2339 }
2340 if (!pp->hadError)
2341 addDomainConstraint(pp, "set_subset",
2342 new AST::SetVar(pp->setvars.size()-1), (yyvsp[-4].oSet));
2343 } else {
2344 pp->setvars.push_back(varspec((yyvsp[-2].sValue),
2345 new SetVarSpec((yyvsp[-4].oSet),!print,funcDep)));
2346 }
2347 delete (yyvsp[-1].argVec); free((yyvsp[-2].sValue));
2348 }
2349#line 2350 "gecode/flatzinc/parser.tab.cpp"
2350 break;
2351
2352 case 39: /* vardecl_item: FZ_INT ':' var_par_id annotations '=' non_array_expr */
2353#line 816 "../gecode/flatzinc/parser.yxx"
2354 {
2355 ParserState* pp = static_cast<ParserState*>(parm);
2356 yyassert(pp, (yyvsp[0].arg)->isInt(), "Invalid int initializer");
2357 yyassert(pp,
2358 pp->symbols.put((yyvsp[-3].sValue), se_i((yyvsp[0].arg)->getInt())),
2359 "Duplicate symbol");
2360 delete (yyvsp[-2].argVec); free((yyvsp[-3].sValue));
2361 }
2362#line 2363 "gecode/flatzinc/parser.tab.cpp"
2363 break;
2364
2365 case 40: /* vardecl_item: FZ_FLOAT ':' var_par_id annotations '=' non_array_expr */
2366#line 825 "../gecode/flatzinc/parser.yxx"
2367 {
2368 ParserState* pp = static_cast<ParserState*>(parm);
2369 yyassert(pp, (yyvsp[0].arg)->isFloat(), "Invalid float initializer");
2370 pp->floatvals.push_back((yyvsp[0].arg)->getFloat());
2371 yyassert(pp,
2372 pp->symbols.put((yyvsp[-3].sValue), se_f(pp->floatvals.size()-1)),
2373 "Duplicate symbol");
2374 delete (yyvsp[-2].argVec); free((yyvsp[-3].sValue));
2375 }
2376#line 2377 "gecode/flatzinc/parser.tab.cpp"
2377 break;
2378
2379 case 41: /* vardecl_item: FZ_BOOL ':' var_par_id annotations '=' non_array_expr */
2380#line 835 "../gecode/flatzinc/parser.yxx"
2381 {
2382 ParserState* pp = static_cast<ParserState*>(parm);
2383 yyassert(pp, (yyvsp[0].arg)->isBool(), "Invalid bool initializer");
2384 yyassert(pp,
2385 pp->symbols.put((yyvsp[-3].sValue), se_b((yyvsp[0].arg)->getBool())),
2386 "Duplicate symbol");
2387 delete (yyvsp[-2].argVec); free((yyvsp[-3].sValue));
2388 }
2389#line 2390 "gecode/flatzinc/parser.tab.cpp"
2390 break;
2391
2392 case 42: /* vardecl_item: FZ_SET FZ_OF FZ_INT ':' var_par_id annotations '=' non_array_expr */
2393#line 844 "../gecode/flatzinc/parser.yxx"
2394 {
2395 ParserState* pp = static_cast<ParserState*>(parm);
2396 yyassert(pp, (yyvsp[0].arg)->isSet(), "Invalid set initializer");
2397 AST::SetLit* set = (yyvsp[0].arg)->getSet();
2398 pp->setvals.push_back(*set);
2399 yyassert(pp,
2400 pp->symbols.put((yyvsp[-3].sValue), se_s(pp->setvals.size()-1)),
2401 "Duplicate symbol");
2402 delete set;
2403 delete (yyvsp[-2].argVec); free((yyvsp[-3].sValue));
2404 }
2405#line 2406 "gecode/flatzinc/parser.tab.cpp"
2406 break;
2407
2408 case 43: /* vardecl_item: FZ_ARRAY '[' FZ_INT_LIT FZ_DOTDOT FZ_INT_LIT ']' FZ_OF FZ_VAR int_ti_expr_tail ':' var_par_id annotations vardecl_int_var_array_init */
2409#line 857 "../gecode/flatzinc/parser.yxx"
2410 {
2411 ParserState* pp = static_cast<ParserState*>(parm);
2412 yyassert(pp, (yyvsp[-10].iValue)==1, "Arrays must start at 1");
2413 if (!pp->hadError) {
2414 bool print = (yyvsp[-1].argVec) != NULL && (yyvsp[-1].argVec)->hasCall("output_array");
2415 vector<int> vars((yyvsp[-8].iValue));
2416 if (!pp->hadError) {
2417 if ((yyvsp[0].oVarSpecVec)()) {
2418 vector<VarSpec*>* vsv = (yyvsp[0].oVarSpecVec).some();
2419 yyassert(pp, vsv->size() == static_cast<unsigned int>((yyvsp[-8].iValue)),
2420 "Initializer size does not match array dimension");
2421 if (!pp->hadError) {
2422 for (int i=0; i<(yyvsp[-8].iValue); i++) {
2423 IntVarSpec* ivsv = static_cast<IntVarSpec*>((*vsv)[i]);
2424 if (ivsv->alias) {
2425 if (print)
2426 static_cast<IntVarSpec*>(pp->intvars[ivsv->i].second)->introduced = false;
2427 vars[i] = ivsv->i;
2428 } else {
2429 if (print)
2430 ivsv->introduced = false;
2431 vars[i] = pp->intvars.size();
2432 pp->intvars.push_back(varspec((yyvsp[-2].sValue), ivsv));
2433 }
2434 if (!pp->hadError && (yyvsp[-4].oSet)()) {
2435 Option<AST::SetLit*> opt =
2436 Option<AST::SetLit*>::some(new AST::SetLit(*(yyvsp[-4].oSet).some()));
2437 addDomainConstraint(pp, "int_in",
2438 new AST::IntVar(vars[i]),
2439 opt);
2440 }
2441 }
2442 }
2443 delete vsv;
2444 } else {
2445 if ((yyvsp[-8].iValue)>0) {
2446 for (int i=0; i<(yyvsp[-8].iValue); i++) {
2447 Option<AST::SetLit*> dom =
2448 (yyvsp[-4].oSet)() ? Option<AST::SetLit*>::some(new AST::SetLit((yyvsp[-4].oSet).some()))
2449 : Option<AST::SetLit*>::none();
2450 IntVarSpec* ispec = new IntVarSpec(dom,!print,false);
2451 vars[i] = pp->intvars.size();
2452 pp->intvars.push_back(varspec((yyvsp[-2].sValue), ispec));
2453 }
2454 }
2455 if ((yyvsp[-4].oSet)()) delete (yyvsp[-4].oSet).some();
2456 }
2457 }
2458 if (print) {
2459 AST::Array* a = new AST::Array();
2460 a->a.push_back(arrayOutput((yyvsp[-1].argVec)->getCall("output_array")));
2461 AST::Array* output = new AST::Array();
2462 for (int i=0; i<(yyvsp[-8].iValue); i++)
2463 output->a.push_back(new AST::IntVar(vars[i]));
2464 a->a.push_back(output);
2465 a->a.push_back(new AST::String(")"));
2466 pp->output(std::string((yyvsp[-2].sValue)), a);
2467 }
2468 int iva = pp->arrays.size();
2469 pp->arrays.push_back(vars.size());
2470 for (unsigned int i=0; i<vars.size(); i++)
2471 pp->arrays.push_back(vars[i]);
2472 yyassert(pp,
2473 pp->symbols.put((yyvsp[-2].sValue), se_iva(iva)),
2474 "Duplicate symbol");
2475 }
2476 delete (yyvsp[-1].argVec); free((yyvsp[-2].sValue));
2477 }
2478#line 2479 "gecode/flatzinc/parser.tab.cpp"
2479 break;
2480
2481 case 44: /* vardecl_item: FZ_ARRAY '[' FZ_INT_LIT FZ_DOTDOT FZ_INT_LIT ']' FZ_OF FZ_VAR bool_ti_expr_tail ':' var_par_id annotations vardecl_bool_var_array_init */
2482#line 927 "../gecode/flatzinc/parser.yxx"
2483 {
2484 ParserState* pp = static_cast<ParserState*>(parm);
2485 bool print = (yyvsp[-1].argVec) != NULL && (yyvsp[-1].argVec)->hasCall("output_array");
2486 yyassert(pp, (yyvsp[-10].iValue)==1, "Arrays must start at 1");
2487 if (!pp->hadError) {
2488 vector<int> vars((yyvsp[-8].iValue));
2489 if ((yyvsp[0].oVarSpecVec)()) {
2490 vector<VarSpec*>* vsv = (yyvsp[0].oVarSpecVec).some();
2491 yyassert(pp, vsv->size() == static_cast<unsigned int>((yyvsp[-8].iValue)),
2492 "Initializer size does not match array dimension");
2493 if (!pp->hadError) {
2494 for (int i=0; i<(yyvsp[-8].iValue); i++) {
2495 BoolVarSpec* bvsv = static_cast<BoolVarSpec*>((*vsv)[i]);
2496 if (bvsv->alias) {
2497 if (print)
2498 static_cast<BoolVarSpec*>(pp->boolvars[bvsv->i].second)->introduced = false;
2499 vars[i] = bvsv->i;
2500 } else {
2501 if (print)
2502 bvsv->introduced = false;
2503 vars[i] = pp->boolvars.size();
2504 pp->boolvars.push_back(varspec((yyvsp[-2].sValue), (*vsv)[i]));
2505 }
2506 if (!pp->hadError && (yyvsp[-4].oSet)()) {
2507 Option<AST::SetLit*> opt =
2508 Option<AST::SetLit*>::some(new AST::SetLit(*(yyvsp[-4].oSet).some()));
2509 addDomainConstraint(pp, "int_in",
2510 new AST::BoolVar(vars[i]),
2511 opt);
2512 }
2513 }
2514 }
2515 delete vsv;
2516 } else {
2517 for (int i=0; i<(yyvsp[-8].iValue); i++) {
2518 Option<AST::SetLit*> dom =
2519 (yyvsp[-4].oSet)() ? Option<AST::SetLit*>::some(new AST::SetLit((yyvsp[-4].oSet).some()))
2520 : Option<AST::SetLit*>::none();
2521 vars[i] = pp->boolvars.size();
2522 pp->boolvars.push_back(varspec((yyvsp[-2].sValue),
2523 new BoolVarSpec(dom,!print,false)));
2524 }
2525 if ((yyvsp[-4].oSet)()) delete (yyvsp[-4].oSet).some();
2526 }
2527 if (print) {
2528 AST::Array* a = new AST::Array();
2529 a->a.push_back(arrayOutput((yyvsp[-1].argVec)->getCall("output_array")));
2530 AST::Array* output = new AST::Array();
2531 for (int i=0; i<(yyvsp[-8].iValue); i++)
2532 output->a.push_back(new AST::BoolVar(vars[i]));
2533 a->a.push_back(output);
2534 a->a.push_back(new AST::String(")"));
2535 pp->output(std::string((yyvsp[-2].sValue)), a);
2536 }
2537 int bva = pp->arrays.size();
2538 pp->arrays.push_back(vars.size());
2539 for (unsigned int i=0; i<vars.size(); i++)
2540 pp->arrays.push_back(vars[i]);
2541 yyassert(pp,
2542 pp->symbols.put((yyvsp[-2].sValue), se_bva(bva)),
2543 "Duplicate symbol");
2544 }
2545 delete (yyvsp[-1].argVec); free((yyvsp[-2].sValue));
2546 }
2547#line 2548 "gecode/flatzinc/parser.tab.cpp"
2548 break;
2549
2550 case 45: /* vardecl_item: FZ_ARRAY '[' FZ_INT_LIT FZ_DOTDOT FZ_INT_LIT ']' FZ_OF FZ_VAR float_ti_expr_tail ':' var_par_id annotations vardecl_float_var_array_init */
2551#line 994 "../gecode/flatzinc/parser.yxx"
2552 {
2553 ParserState* pp = static_cast<ParserState*>(parm);
2554 yyassert(pp, (yyvsp[-10].iValue)==1, "Arrays must start at 1");
2555 if (!pp->hadError) {
2556 bool print = (yyvsp[-1].argVec) != NULL && (yyvsp[-1].argVec)->hasCall("output_array");
2557 vector<int> vars((yyvsp[-8].iValue));
2558 if (!pp->hadError) {
2559 if ((yyvsp[0].oVarSpecVec)()) {
2560 vector<VarSpec*>* vsv = (yyvsp[0].oVarSpecVec).some();
2561 yyassert(pp, vsv->size() == static_cast<unsigned int>((yyvsp[-8].iValue)),
2562 "Initializer size does not match array dimension");
2563 if (!pp->hadError) {
2564 for (int i=0; i<(yyvsp[-8].iValue); i++) {
2565 FloatVarSpec* ivsv = static_cast<FloatVarSpec*>((*vsv)[i]);
2566 if (ivsv->alias) {
2567 if (print)
2568 static_cast<FloatVarSpec*>(pp->floatvars[ivsv->i].second)->introduced = false;
2569 vars[i] = ivsv->i;
2570 } else {
2571 if (print)
2572 ivsv->introduced = false;
2573 vars[i] = pp->floatvars.size();
2574 pp->floatvars.push_back(varspec((yyvsp[-2].sValue), ivsv));
2575 }
2576 if (!pp->hadError && (yyvsp[-4].oPFloat)()) {
2577 Option<std::pair<double,double>*> opt =
2578 Option<std::pair<double,double>*>::some(
2579 new std::pair<double,double>(*(yyvsp[-4].oPFloat).some()));
2580 addDomainConstraint(pp, new AST::FloatVar(vars[i]),
2581 opt);
2582 }
2583 }
2584 }
2585 delete vsv;
2586 } else {
2587 if ((yyvsp[-8].iValue)>0) {
2588 Option<std::pair<double,double> > dom =
2589 (yyvsp[-4].oPFloat)() ? Option<std::pair<double,double> >::some(*(yyvsp[-4].oPFloat).some())
2590 : Option<std::pair<double,double> >::none();
2591 for (int i=0; i<(yyvsp[-8].iValue); i++) {
2592 FloatVarSpec* ispec = new FloatVarSpec(dom,!print,false);
2593 vars[i] = pp->floatvars.size();
2594 pp->floatvars.push_back(varspec((yyvsp[-2].sValue), ispec));
2595 }
2596 }
2597 }
2598 }
2599 if (print) {
2600 AST::Array* a = new AST::Array();
2601 a->a.push_back(arrayOutput((yyvsp[-1].argVec)->getCall("output_array")));
2602 AST::Array* output = new AST::Array();
2603 for (int i=0; i<(yyvsp[-8].iValue); i++)
2604 output->a.push_back(new AST::FloatVar(vars[i]));
2605 a->a.push_back(output);
2606 a->a.push_back(new AST::String(")"));
2607 pp->output(std::string((yyvsp[-2].sValue)), a);
2608 }
2609 int fva = pp->arrays.size();
2610 pp->arrays.push_back(vars.size());
2611 for (unsigned int i=0; i<vars.size(); i++)
2612 pp->arrays.push_back(vars[i]);
2613 yyassert(pp,
2614 pp->symbols.put((yyvsp[-2].sValue), se_fva(fva)),
2615 "Duplicate symbol");
2616 }
2617 if ((yyvsp[-4].oPFloat)()) delete (yyvsp[-4].oPFloat).some();
2618 delete (yyvsp[-1].argVec); free((yyvsp[-2].sValue));
2619 }
2620#line 2621 "gecode/flatzinc/parser.tab.cpp"
2621 break;
2622
2623 case 46: /* vardecl_item: FZ_ARRAY '[' FZ_INT_LIT FZ_DOTDOT FZ_INT_LIT ']' FZ_OF FZ_VAR FZ_SET FZ_OF int_ti_expr_tail ':' var_par_id annotations vardecl_set_var_array_init */
2624#line 1064 "../gecode/flatzinc/parser.yxx"
2625 {
2626 ParserState* pp = static_cast<ParserState*>(parm);
2627 bool print = (yyvsp[-1].argVec) != NULL && (yyvsp[-1].argVec)->hasCall("output_array");
2628 yyassert(pp, (yyvsp[-12].iValue)==1, "Arrays must start at 1");
2629 if (!pp->hadError) {
2630 vector<int> vars((yyvsp[-10].iValue));
2631 if ((yyvsp[0].oVarSpecVec)()) {
2632 vector<VarSpec*>* vsv = (yyvsp[0].oVarSpecVec).some();
2633 yyassert(pp, vsv->size() == static_cast<unsigned int>((yyvsp[-10].iValue)),
2634 "Initializer size does not match array dimension");
2635 if (!pp->hadError) {
2636 for (int i=0; i<(yyvsp[-10].iValue); i++) {
2637 SetVarSpec* svsv = static_cast<SetVarSpec*>((*vsv)[i]);
2638 if (svsv->alias) {
2639 if (print)
2640 static_cast<SetVarSpec*>(pp->setvars[svsv->i].second)->introduced = false;
2641 vars[i] = svsv->i;
2642 } else {
2643 if (print)
2644 svsv->introduced = false;
2645 vars[i] = pp->setvars.size();
2646 pp->setvars.push_back(varspec((yyvsp[-2].sValue), (*vsv)[i]));
2647 }
2648 if (!pp->hadError && (yyvsp[-4].oSet)()) {
2649 Option<AST::SetLit*> opt =
2650 Option<AST::SetLit*>::some(new AST::SetLit(*(yyvsp[-4].oSet).some()));
2651 addDomainConstraint(pp, "set_subset",
2652 new AST::SetVar(vars[i]),
2653 opt);
2654 }
2655 }
2656 }
2657 delete vsv;
2658 } else {
2659 if ((yyvsp[-10].iValue)>0) {
2660 for (int i=0; i<(yyvsp[-10].iValue); i++) {
2661 Option<AST::SetLit*> dom =
2662 (yyvsp[-4].oSet)() ? Option<AST::SetLit*>::some(new AST::SetLit((yyvsp[-4].oSet).some()))
2663 : Option<AST::SetLit*>::none();
2664 SetVarSpec* ispec = new SetVarSpec(dom,!print,false);
2665 vars[i] = pp->setvars.size();
2666 pp->setvars.push_back(varspec((yyvsp[-2].sValue), ispec));
2667 }
2668 if ((yyvsp[-4].oSet)()) delete (yyvsp[-4].oSet).some();
2669 }
2670 }
2671 if (print) {
2672 AST::Array* a = new AST::Array();
2673 a->a.push_back(arrayOutput((yyvsp[-1].argVec)->getCall("output_array")));
2674 AST::Array* output = new AST::Array();
2675 for (int i=0; i<(yyvsp[-10].iValue); i++)
2676 output->a.push_back(new AST::SetVar(vars[i]));
2677 a->a.push_back(output);
2678 a->a.push_back(new AST::String(")"));
2679 pp->output(std::string((yyvsp[-2].sValue)), a);
2680 }
2681 int sva = pp->arrays.size();
2682 pp->arrays.push_back(vars.size());
2683 for (unsigned int i=0; i<vars.size(); i++)
2684 pp->arrays.push_back(vars[i]);
2685 yyassert(pp,
2686 pp->symbols.put((yyvsp[-2].sValue), se_sva(sva)),
2687 "Duplicate symbol");
2688 }
2689 delete (yyvsp[-1].argVec); free((yyvsp[-2].sValue));
2690 }
2691#line 2692 "gecode/flatzinc/parser.tab.cpp"
2692 break;
2693
2694 case 47: /* vardecl_item: FZ_ARRAY '[' FZ_INT_LIT FZ_DOTDOT FZ_INT_LIT ']' FZ_OF FZ_INT ':' var_par_id annotations '=' '[' int_list ']' */
2695#line 1132 "../gecode/flatzinc/parser.yxx"
2696 {
2697 ParserState* pp = static_cast<ParserState*>(parm);
2698 yyassert(pp, (yyvsp[-12].iValue)==1, "Arrays must start at 1");
2699 yyassert(pp, (yyvsp[-1].setValue)->size() == static_cast<unsigned int>((yyvsp[-10].iValue)),
2700 "Initializer size does not match array dimension");
2701
2702 if (!pp->hadError) {
2703 int ia = pp->arrays.size();
2704 pp->arrays.push_back((yyvsp[-1].setValue)->size());
2705 for (unsigned int i=0; i<(yyvsp[-1].setValue)->size(); i++)
2706 pp->arrays.push_back((*(yyvsp[-1].setValue))[i]);
2707 yyassert(pp,
2708 pp->symbols.put((yyvsp[-5].sValue), se_ia(ia)),
2709 "Duplicate symbol");
2710 }
2711 delete (yyvsp[-1].setValue);
2712 free((yyvsp[-5].sValue));
2713 delete (yyvsp[-4].argVec);
2714 }
2715#line 2716 "gecode/flatzinc/parser.tab.cpp"
2716 break;
2717
2718 case 48: /* vardecl_item: FZ_ARRAY '[' FZ_INT_LIT FZ_DOTDOT FZ_INT_LIT ']' FZ_OF FZ_BOOL ':' var_par_id annotations '=' '[' bool_list ']' */
2719#line 1153 "../gecode/flatzinc/parser.yxx"
2720 {
2721 ParserState* pp = static_cast<ParserState*>(parm);
2722 yyassert(pp, (yyvsp[-12].iValue)==1, "Arrays must start at 1");
2723 yyassert(pp, (yyvsp[-1].setValue)->size() == static_cast<unsigned int>((yyvsp[-10].iValue)),
2724 "Initializer size does not match array dimension");
2725 if (!pp->hadError) {
2726 int ia = pp->arrays.size();
2727 pp->arrays.push_back((yyvsp[-1].setValue)->size());
2728 for (unsigned int i=0; i<(yyvsp[-1].setValue)->size(); i++)
2729 pp->arrays.push_back((*(yyvsp[-1].setValue))[i]);
2730 yyassert(pp,
2731 pp->symbols.put((yyvsp[-5].sValue), se_ba(ia)),
2732 "Duplicate symbol");
2733 }
2734 delete (yyvsp[-1].setValue);
2735 free((yyvsp[-5].sValue));
2736 delete (yyvsp[-4].argVec);
2737 }
2738#line 2739 "gecode/flatzinc/parser.tab.cpp"
2739 break;
2740
2741 case 49: /* vardecl_item: FZ_ARRAY '[' FZ_INT_LIT FZ_DOTDOT FZ_INT_LIT ']' FZ_OF FZ_FLOAT ':' var_par_id annotations '=' '[' float_list ']' */
2742#line 1173 "../gecode/flatzinc/parser.yxx"
2743 {
2744 ParserState* pp = static_cast<ParserState*>(parm);
2745 yyassert(pp, (yyvsp[-12].iValue)==1, "Arrays must start at 1");
2746 yyassert(pp, (yyvsp[-1].floatSetValue)->size() == static_cast<unsigned int>((yyvsp[-10].iValue)),
2747 "Initializer size does not match array dimension");
2748 if (!pp->hadError) {
2749 int fa = pp->arrays.size();
2750 pp->arrays.push_back((yyvsp[-1].floatSetValue)->size());
2751 pp->arrays.push_back(pp->floatvals.size());
2752 for (unsigned int i=0; i<(yyvsp[-1].floatSetValue)->size(); i++)
2753 pp->floatvals.push_back((*(yyvsp[-1].floatSetValue))[i]);
2754 yyassert(pp,
2755 pp->symbols.put((yyvsp[-5].sValue), se_fa(fa)),
2756 "Duplicate symbol");
2757 }
2758 delete (yyvsp[-1].floatSetValue);
2759 delete (yyvsp[-4].argVec); free((yyvsp[-5].sValue));
2760 }
2761#line 2762 "gecode/flatzinc/parser.tab.cpp"
2762 break;
2763
2764 case 50: /* vardecl_item: FZ_ARRAY '[' FZ_INT_LIT FZ_DOTDOT FZ_INT_LIT ']' FZ_OF FZ_SET FZ_OF FZ_INT ':' var_par_id annotations '=' '[' set_literal_list ']' */
2765#line 1193 "../gecode/flatzinc/parser.yxx"
2766 {
2767 ParserState* pp = static_cast<ParserState*>(parm);
2768 yyassert(pp, (yyvsp[-14].iValue)==1, "Arrays must start at 1");
2769 yyassert(pp, (yyvsp[-1].setValueList)->size() == static_cast<unsigned int>((yyvsp[-12].iValue)),
2770 "Initializer size does not match array dimension");
2771 if (!pp->hadError) {
2772 int sa = pp->arrays.size();
2773 pp->arrays.push_back((yyvsp[-1].setValueList)->size());
2774 pp->arrays.push_back(pp->setvals.size());
2775 for (unsigned int i=0; i<(yyvsp[-1].setValueList)->size(); i++)
2776 pp->setvals.push_back((*(yyvsp[-1].setValueList))[i]);
2777 yyassert(pp,
2778 pp->symbols.put((yyvsp[-5].sValue), se_sa(sa)),
2779 "Duplicate symbol");
2780 }
2781
2782 delete (yyvsp[-1].setValueList);
2783 delete (yyvsp[-4].argVec); free((yyvsp[-5].sValue));
2784 }
2785#line 2786 "gecode/flatzinc/parser.tab.cpp"
2786 break;
2787
2788 case 51: /* int_init: FZ_INT_LIT */
2789#line 1215 "../gecode/flatzinc/parser.yxx"
2790 {
2791 (yyval.varSpec) = new IntVarSpec((yyvsp[0].iValue),false,false);
2792 }
2793#line 2794 "gecode/flatzinc/parser.tab.cpp"
2794 break;
2795
2796 case 52: /* int_init: var_par_id */
2797#line 1219 "../gecode/flatzinc/parser.yxx"
2798 {
2799 SymbolEntry e;
2800 ParserState* pp = static_cast<ParserState*>(parm);
2801 if (pp->symbols.get((yyvsp[0].sValue), e) && e.t == ST_INTVAR)
2802 (yyval.varSpec) = new IntVarSpec(Alias(e.i),false,false);
2803 else {
2804 pp->err << "Error: undefined identifier for type int " << (yyvsp[0].sValue)
2805 << " in line no. "
2806 << yyget_lineno(pp->yyscanner) << std::endl;
2807 pp->hadError = true;
2808 (yyval.varSpec) = new IntVarSpec(0,false,false); // keep things consistent
2809 }
2810 free((yyvsp[0].sValue));
2811 }
2812#line 2813 "gecode/flatzinc/parser.tab.cpp"
2813 break;
2814
2815 case 53: /* int_init: var_par_id '[' FZ_INT_LIT ']' */
2816#line 1234 "../gecode/flatzinc/parser.yxx"
2817 {
2818 vector<int> v;
2819 SymbolEntry e;
2820 ParserState* pp = static_cast<ParserState*>(parm);
2821 if (pp->symbols.get((yyvsp[-3].sValue), e) && e.t == ST_INTVARARRAY) {
2822 yyassert(pp,(yyvsp[-1].iValue) > 0 && (yyvsp[-1].iValue) <= pp->arrays[e.i],
2823 "array access out of bounds");
2824 if (!pp->hadError)
2825 (yyval.varSpec) = new IntVarSpec(Alias(pp->arrays[e.i+(yyvsp[-1].iValue)]),false,false);
2826 else
2827 (yyval.varSpec) = new IntVarSpec(0,false,false); // keep things consistent
2828 } else {
2829 pp->err << "Error: undefined array identifier for type int " << (yyvsp[-3].sValue)
2830 << " in line no. "
2831 << yyget_lineno(pp->yyscanner) << std::endl;
2832 pp->hadError = true;
2833 (yyval.varSpec) = new IntVarSpec(0,false,false); // keep things consistent
2834 }
2835 free((yyvsp[-3].sValue));
2836 }
2837#line 2838 "gecode/flatzinc/parser.tab.cpp"
2838 break;
2839
2840 case 54: /* int_init_list: %empty */
2841#line 1257 "../gecode/flatzinc/parser.yxx"
2842 { (yyval.varSpecVec) = new vector<VarSpec*>(0); }
2843#line 2844 "gecode/flatzinc/parser.tab.cpp"
2844 break;
2845
2846 case 55: /* int_init_list: int_init_list_head list_tail */
2847#line 1259 "../gecode/flatzinc/parser.yxx"
2848 { (yyval.varSpecVec) = (yyvsp[-1].varSpecVec); }
2849#line 2850 "gecode/flatzinc/parser.tab.cpp"
2850 break;
2851
2852 case 56: /* int_init_list_head: int_init */
2853#line 1263 "../gecode/flatzinc/parser.yxx"
2854 { (yyval.varSpecVec) = new vector<VarSpec*>(1); (*(yyval.varSpecVec))[0] = (yyvsp[0].varSpec); }
2855#line 2856 "gecode/flatzinc/parser.tab.cpp"
2856 break;
2857
2858 case 57: /* int_init_list_head: int_init_list_head ',' int_init */
2859#line 1265 "../gecode/flatzinc/parser.yxx"
2860 { (yyval.varSpecVec) = (yyvsp[-2].varSpecVec); (yyval.varSpecVec)->push_back((yyvsp[0].varSpec)); }
2861#line 2862 "gecode/flatzinc/parser.tab.cpp"
2862 break;
2863
2864 case 60: /* int_var_array_literal: '[' int_init_list ']' */
2865#line 1270 "../gecode/flatzinc/parser.yxx"
2866 { (yyval.varSpecVec) = (yyvsp[-1].varSpecVec); }
2867#line 2868 "gecode/flatzinc/parser.tab.cpp"
2868 break;
2869
2870 case 61: /* float_init: FZ_FLOAT_LIT */
2871#line 1274 "../gecode/flatzinc/parser.yxx"
2872 { (yyval.varSpec) = new FloatVarSpec((yyvsp[0].dValue),false,false); }
2873#line 2874 "gecode/flatzinc/parser.tab.cpp"
2874 break;
2875
2876 case 62: /* float_init: var_par_id */
2877#line 1276 "../gecode/flatzinc/parser.yxx"
2878 {
2879 SymbolEntry e;
2880 ParserState* pp = static_cast<ParserState*>(parm);
2881 if (pp->symbols.get((yyvsp[0].sValue), e) && e.t == ST_FLOATVAR)
2882 (yyval.varSpec) = new FloatVarSpec(Alias(e.i),false,false);
2883 else {
2884 pp->err << "Error: undefined identifier for type float " << (yyvsp[0].sValue)
2885 << " in line no. "
2886 << yyget_lineno(pp->yyscanner) << std::endl;
2887 pp->hadError = true;
2888 (yyval.varSpec) = new FloatVarSpec(0.0,false,false);
2889 }
2890 free((yyvsp[0].sValue));
2891 }
2892#line 2893 "gecode/flatzinc/parser.tab.cpp"
2893 break;
2894
2895 case 63: /* float_init: var_par_id '[' FZ_INT_LIT ']' */
2896#line 1291 "../gecode/flatzinc/parser.yxx"
2897 {
2898 SymbolEntry e;
2899 ParserState* pp = static_cast<ParserState*>(parm);
2900 if (pp->symbols.get((yyvsp[-3].sValue), e) && e.t == ST_FLOATVARARRAY) {
2901 yyassert(pp,(yyvsp[-1].iValue) > 0 && (yyvsp[-1].iValue) <= pp->arrays[e.i],
2902 "array access out of bounds");
2903 if (!pp->hadError)
2904 (yyval.varSpec) = new FloatVarSpec(Alias(pp->arrays[e.i+(yyvsp[-1].iValue)]),false,false);
2905 else
2906 (yyval.varSpec) = new FloatVarSpec(0.0,false,false);
2907 } else {
2908 pp->err << "Error: undefined array identifier for type float " << (yyvsp[-3].sValue)
2909 << " in line no. "
2910 << yyget_lineno(pp->yyscanner) << std::endl;
2911 pp->hadError = true;
2912 (yyval.varSpec) = new FloatVarSpec(0.0,false,false);
2913 }
2914 free((yyvsp[-3].sValue));
2915 }
2916#line 2917 "gecode/flatzinc/parser.tab.cpp"
2917 break;
2918
2919 case 64: /* float_init_list: %empty */
2920#line 1313 "../gecode/flatzinc/parser.yxx"
2921 { (yyval.varSpecVec) = new vector<VarSpec*>(0); }
2922#line 2923 "gecode/flatzinc/parser.tab.cpp"
2923 break;
2924
2925 case 65: /* float_init_list: float_init_list_head list_tail */
2926#line 1315 "../gecode/flatzinc/parser.yxx"
2927 { (yyval.varSpecVec) = (yyvsp[-1].varSpecVec); }
2928#line 2929 "gecode/flatzinc/parser.tab.cpp"
2929 break;
2930
2931 case 66: /* float_init_list_head: float_init */
2932#line 1319 "../gecode/flatzinc/parser.yxx"
2933 { (yyval.varSpecVec) = new vector<VarSpec*>(1); (*(yyval.varSpecVec))[0] = (yyvsp[0].varSpec); }
2934#line 2935 "gecode/flatzinc/parser.tab.cpp"
2935 break;
2936
2937 case 67: /* float_init_list_head: float_init_list_head ',' float_init */
2938#line 1321 "../gecode/flatzinc/parser.yxx"
2939 { (yyval.varSpecVec) = (yyvsp[-2].varSpecVec); (yyval.varSpecVec)->push_back((yyvsp[0].varSpec)); }
2940#line 2941 "gecode/flatzinc/parser.tab.cpp"
2941 break;
2942
2943 case 68: /* float_var_array_literal: '[' float_init_list ']' */
2944#line 1325 "../gecode/flatzinc/parser.yxx"
2945 { (yyval.varSpecVec) = (yyvsp[-1].varSpecVec); }
2946#line 2947 "gecode/flatzinc/parser.tab.cpp"
2947 break;
2948
2949 case 69: /* bool_init: FZ_BOOL_LIT */
2950#line 1329 "../gecode/flatzinc/parser.yxx"
2951 { (yyval.varSpec) = new BoolVarSpec((yyvsp[0].iValue),false,false); }
2952#line 2953 "gecode/flatzinc/parser.tab.cpp"
2953 break;
2954
2955 case 70: /* bool_init: var_par_id */
2956#line 1331 "../gecode/flatzinc/parser.yxx"
2957 {
2958 SymbolEntry e;
2959 ParserState* pp = static_cast<ParserState*>(parm);
2960 if (pp->symbols.get((yyvsp[0].sValue), e) && e.t == ST_BOOLVAR)
2961 (yyval.varSpec) = new BoolVarSpec(Alias(e.i),false,false);
2962 else {
2963 pp->err << "Error: undefined identifier for type bool " << (yyvsp[0].sValue)
2964 << " in line no. "
2965 << yyget_lineno(pp->yyscanner) << std::endl;
2966 pp->hadError = true;
2967 (yyval.varSpec) = new BoolVarSpec(false,false,false);
2968 }
2969 free((yyvsp[0].sValue));
2970 }
2971#line 2972 "gecode/flatzinc/parser.tab.cpp"
2972 break;
2973
2974 case 71: /* bool_init: var_par_id '[' FZ_INT_LIT ']' */
2975#line 1346 "../gecode/flatzinc/parser.yxx"
2976 {
2977 SymbolEntry e;
2978 ParserState* pp = static_cast<ParserState*>(parm);
2979 if (pp->symbols.get((yyvsp[-3].sValue), e) && e.t == ST_BOOLVARARRAY) {
2980 yyassert(pp,(yyvsp[-1].iValue) > 0 && (yyvsp[-1].iValue) <= pp->arrays[e.i],
2981 "array access out of bounds");
2982 if (!pp->hadError)
2983 (yyval.varSpec) = new BoolVarSpec(Alias(pp->arrays[e.i+(yyvsp[-1].iValue)]),false,false);
2984 else
2985 (yyval.varSpec) = new BoolVarSpec(false,false,false);
2986 } else {
2987 pp->err << "Error: undefined array identifier for type bool " << (yyvsp[-3].sValue)
2988 << " in line no. "
2989 << yyget_lineno(pp->yyscanner) << std::endl;
2990 pp->hadError = true;
2991 (yyval.varSpec) = new BoolVarSpec(false,false,false);
2992 }
2993 free((yyvsp[-3].sValue));
2994 }
2995#line 2996 "gecode/flatzinc/parser.tab.cpp"
2996 break;
2997
2998 case 72: /* bool_init_list: %empty */
2999#line 1368 "../gecode/flatzinc/parser.yxx"
3000 { (yyval.varSpecVec) = new vector<VarSpec*>(0); }
3001#line 3002 "gecode/flatzinc/parser.tab.cpp"
3002 break;
3003
3004 case 73: /* bool_init_list: bool_init_list_head list_tail */
3005#line 1370 "../gecode/flatzinc/parser.yxx"
3006 { (yyval.varSpecVec) = (yyvsp[-1].varSpecVec); }
3007#line 3008 "gecode/flatzinc/parser.tab.cpp"
3008 break;
3009
3010 case 74: /* bool_init_list_head: bool_init */
3011#line 1374 "../gecode/flatzinc/parser.yxx"
3012 { (yyval.varSpecVec) = new vector<VarSpec*>(1); (*(yyval.varSpecVec))[0] = (yyvsp[0].varSpec); }
3013#line 3014 "gecode/flatzinc/parser.tab.cpp"
3014 break;
3015
3016 case 75: /* bool_init_list_head: bool_init_list_head ',' bool_init */
3017#line 1376 "../gecode/flatzinc/parser.yxx"
3018 { (yyval.varSpecVec) = (yyvsp[-2].varSpecVec); (yyval.varSpecVec)->push_back((yyvsp[0].varSpec)); }
3019#line 3020 "gecode/flatzinc/parser.tab.cpp"
3020 break;
3021
3022 case 76: /* bool_var_array_literal: '[' bool_init_list ']' */
3023#line 1378 "../gecode/flatzinc/parser.yxx"
3024 { (yyval.varSpecVec) = (yyvsp[-1].varSpecVec); }
3025#line 3026 "gecode/flatzinc/parser.tab.cpp"
3026 break;
3027
3028 case 77: /* set_init: set_literal */
3029#line 1382 "../gecode/flatzinc/parser.yxx"
3030 { (yyval.varSpec) = new SetVarSpec((yyvsp[0].setLit),false,false); }
3031#line 3032 "gecode/flatzinc/parser.tab.cpp"
3032 break;
3033
3034 case 78: /* set_init: var_par_id */
3035#line 1384 "../gecode/flatzinc/parser.yxx"
3036 {
3037 ParserState* pp = static_cast<ParserState*>(parm);
3038 SymbolEntry e;
3039 if (pp->symbols.get((yyvsp[0].sValue), e) && e.t == ST_SETVAR)
3040 (yyval.varSpec) = new SetVarSpec(Alias(e.i),false,false);
3041 else {
3042 pp->err << "Error: undefined identifier for type set " << (yyvsp[0].sValue)
3043 << " in line no. "
3044 << yyget_lineno(pp->yyscanner) << std::endl;
3045 pp->hadError = true;
3046 (yyval.varSpec) = new SetVarSpec(Alias(0),false,false);
3047 }
3048 free((yyvsp[0].sValue));
3049 }
3050#line 3051 "gecode/flatzinc/parser.tab.cpp"
3051 break;
3052
3053 case 79: /* set_init: var_par_id '[' FZ_INT_LIT ']' */
3054#line 1399 "../gecode/flatzinc/parser.yxx"
3055 {
3056 SymbolEntry e;
3057 ParserState* pp = static_cast<ParserState*>(parm);
3058 if (pp->symbols.get((yyvsp[-3].sValue), e) && e.t == ST_SETVARARRAY) {
3059 yyassert(pp,(yyvsp[-1].iValue) > 0 && (yyvsp[-1].iValue) <= pp->arrays[e.i],
3060 "array access out of bounds");
3061 if (!pp->hadError)
3062 (yyval.varSpec) = new SetVarSpec(Alias(pp->arrays[e.i+(yyvsp[-1].iValue)]),false,false);
3063 else
3064 (yyval.varSpec) = new SetVarSpec(Alias(0),false,false);
3065 } else {
3066 pp->err << "Error: undefined array identifier for type set " << (yyvsp[-3].sValue)
3067 << " in line no. "
3068 << yyget_lineno(pp->yyscanner) << std::endl;
3069 pp->hadError = true;
3070 (yyval.varSpec) = new SetVarSpec(Alias(0),false,false);
3071 }
3072 free((yyvsp[-3].sValue));
3073 }
3074#line 3075 "gecode/flatzinc/parser.tab.cpp"
3075 break;
3076
3077 case 80: /* set_init_list: %empty */
3078#line 1421 "../gecode/flatzinc/parser.yxx"
3079 { (yyval.varSpecVec) = new vector<VarSpec*>(0); }
3080#line 3081 "gecode/flatzinc/parser.tab.cpp"
3081 break;
3082
3083 case 81: /* set_init_list: set_init_list_head list_tail */
3084#line 1423 "../gecode/flatzinc/parser.yxx"
3085 { (yyval.varSpecVec) = (yyvsp[-1].varSpecVec); }
3086#line 3087 "gecode/flatzinc/parser.tab.cpp"
3087 break;
3088
3089 case 82: /* set_init_list_head: set_init */
3090#line 1427 "../gecode/flatzinc/parser.yxx"
3091 { (yyval.varSpecVec) = new vector<VarSpec*>(1); (*(yyval.varSpecVec))[0] = (yyvsp[0].varSpec); }
3092#line 3093 "gecode/flatzinc/parser.tab.cpp"
3093 break;
3094
3095 case 83: /* set_init_list_head: set_init_list_head ',' set_init */
3096#line 1429 "../gecode/flatzinc/parser.yxx"
3097 { (yyval.varSpecVec) = (yyvsp[-2].varSpecVec); (yyval.varSpecVec)->push_back((yyvsp[0].varSpec)); }
3098#line 3099 "gecode/flatzinc/parser.tab.cpp"
3099 break;
3100
3101 case 84: /* set_var_array_literal: '[' set_init_list ']' */
3102#line 1432 "../gecode/flatzinc/parser.yxx"
3103 { (yyval.varSpecVec) = (yyvsp[-1].varSpecVec); }
3104#line 3105 "gecode/flatzinc/parser.tab.cpp"
3105 break;
3106
3107 case 85: /* vardecl_int_var_array_init: %empty */
3108#line 1436 "../gecode/flatzinc/parser.yxx"
3109 { (yyval.oVarSpecVec) = Option<vector<VarSpec*>* >::none(); }
3110#line 3111 "gecode/flatzinc/parser.tab.cpp"
3111 break;
3112
3113 case 86: /* vardecl_int_var_array_init: '=' int_var_array_literal */
3114#line 1438 "../gecode/flatzinc/parser.yxx"
3115 { (yyval.oVarSpecVec) = Option<vector<VarSpec*>* >::some((yyvsp[0].varSpecVec)); }
3116#line 3117 "gecode/flatzinc/parser.tab.cpp"
3117 break;
3118
3119 case 87: /* vardecl_bool_var_array_init: %empty */
3120#line 1442 "../gecode/flatzinc/parser.yxx"
3121 { (yyval.oVarSpecVec) = Option<vector<VarSpec*>* >::none(); }
3122#line 3123 "gecode/flatzinc/parser.tab.cpp"
3123 break;
3124
3125 case 88: /* vardecl_bool_var_array_init: '=' bool_var_array_literal */
3126#line 1444 "../gecode/flatzinc/parser.yxx"
3127 { (yyval.oVarSpecVec) = Option<vector<VarSpec*>* >::some((yyvsp[0].varSpecVec)); }
3128#line 3129 "gecode/flatzinc/parser.tab.cpp"
3129 break;
3130
3131 case 89: /* vardecl_float_var_array_init: %empty */
3132#line 1448 "../gecode/flatzinc/parser.yxx"
3133 { (yyval.oVarSpecVec) = Option<vector<VarSpec*>* >::none(); }
3134#line 3135 "gecode/flatzinc/parser.tab.cpp"
3135 break;
3136
3137 case 90: /* vardecl_float_var_array_init: '=' float_var_array_literal */
3138#line 1450 "../gecode/flatzinc/parser.yxx"
3139 { (yyval.oVarSpecVec) = Option<vector<VarSpec*>* >::some((yyvsp[0].varSpecVec)); }
3140#line 3141 "gecode/flatzinc/parser.tab.cpp"
3141 break;
3142
3143 case 91: /* vardecl_set_var_array_init: %empty */
3144#line 1454 "../gecode/flatzinc/parser.yxx"
3145 { (yyval.oVarSpecVec) = Option<vector<VarSpec*>* >::none(); }
3146#line 3147 "gecode/flatzinc/parser.tab.cpp"
3147 break;
3148
3149 case 92: /* vardecl_set_var_array_init: '=' set_var_array_literal */
3150#line 1456 "../gecode/flatzinc/parser.yxx"
3151 { (yyval.oVarSpecVec) = Option<vector<VarSpec*>* >::some((yyvsp[0].varSpecVec)); }
3152#line 3153 "gecode/flatzinc/parser.tab.cpp"
3153 break;
3154
3155 case 93: /* constraint_item: FZ_CONSTRAINT FZ_ID '(' flat_expr_list ')' annotations */
3156#line 1460 "../gecode/flatzinc/parser.yxx"
3157 {
3158 ParserState *pp = static_cast<ParserState*>(parm);
3159 if (!pp->hadError) {
3160 std::string cid((yyvsp[-4].sValue));
3161 if (cid=="status" && (yyvsp[-2].argVec)->a[0]->isIntVar()) {
3162 pp->status_idx = (yyvsp[-2].argVec)->a[0]->getIntVar();
3163 } else if (cid=="int_lastval" && (yyvsp[-2].argVec)->a[0]->isIntVar() && (yyvsp[-2].argVec)->a[1]->isIntVar()) {
3164 int base0 = getBaseIntVar(pp,(yyvsp[-2].argVec)->a[0]->getIntVar());
3165 int base1 = getBaseIntVar(pp,(yyvsp[-2].argVec)->a[1]->getIntVar());
3166 pp->int_lastval.emplace_back(std::array<int, 2>{ base0, base1 });
3167 } else if (cid=="int_uniform" && (yyvsp[-2].argVec)->a[0]->isInt() && (yyvsp[-2].argVec)->a[1]->isInt() && (yyvsp[-2].argVec)->a[2]->isIntVar()) {
3168 int base = getBaseIntVar(pp,(yyvsp[-2].argVec)->a[2]->getIntVar());
3169 pp->int_uniform.emplace_back(std::array<int, 3>{ (yyvsp[-2].argVec)->a[0]->getInt(), (yyvsp[-2].argVec)->a[1]->getInt(), base });
3170 } else if (cid=="int_sol" && (yyvsp[-2].argVec)->a[0]->isIntVar() && (yyvsp[-2].argVec)->a[1]->isIntVar()) {
3171 int base0 = getBaseIntVar(pp,(yyvsp[-2].argVec)->a[0]->getIntVar());
3172 int base1 = getBaseIntVar(pp,(yyvsp[-2].argVec)->a[1]->getIntVar());
3173 pp->int_sol.emplace_back(std::array<int, 2>{ base0, base1 });
3174 } else if (cid=="int_eq" && (yyvsp[-2].argVec)->a[0]->isIntVar() && (yyvsp[-2].argVec)->a[1]->isIntVar()) {
3175 int base0 = getBaseIntVar(pp,(yyvsp[-2].argVec)->a[0]->getIntVar());
3176 int base1 = getBaseIntVar(pp,(yyvsp[-2].argVec)->a[1]->getIntVar());
3177 if (base0 > base1) {
3178 std::swap(base0, base1);
3179 }
3180 if (base0==base1) {
3181 // do nothing, already aliased
3182 } else {
3183 IntVarSpec* ivs1 = static_cast<IntVarSpec*>(pp->intvars[base1].second);
3184 AST::SetLit* sl = NULL;
3185 if (ivs1->assigned) {
3186 sl = new AST::SetLit(ivs1->i,ivs1->i);
3187 } else if (ivs1->domain()) {
3188 sl = new AST::SetLit(ivs1->domain.some()->getSet());
3189 }
3190 if (sl) {
3191 Option<AST::SetLit*> newdom = Option<AST::SetLit*>::some(sl);
3192 addDomainConstraint(pp, "int_in",
3193 new AST::IntVar(base0), newdom);
3194 ivs1->domain = Option<AST::SetLit*>::none();
3195 }
3196 ivs1->alias = true;
3197 ivs1->i = base0;
3198 }
3199 } else if (cid=="bool_eq" && (yyvsp[-2].argVec)->a[0]->isBoolVar() && (yyvsp[-2].argVec)->a[1]->isBoolVar()) {
3200 int base0 = getBaseBoolVar(pp,(yyvsp[-2].argVec)->a[0]->getBoolVar());
3201 int base1 = getBaseBoolVar(pp,(yyvsp[-2].argVec)->a[1]->getBoolVar());
3202 if (base0 > base1) {
3203 std::swap(base0, base1);
3204 }
3205 if (base0==base1) {
3206 // do nothing, already aliased
3207 } else {
3208 BoolVarSpec* ivs1 = static_cast<BoolVarSpec*>(pp->boolvars[base1].second);
3209 AST::SetLit* sl = NULL;
3210 if (ivs1->assigned) {
3211 sl = new AST::SetLit(ivs1->i,ivs1->i);
3212 } else if (ivs1->domain()) {
3213 sl = new AST::SetLit(ivs1->domain.some()->getSet());
3214 }
3215 if (sl) {
3216 Option<AST::SetLit*> newdom = Option<AST::SetLit*>::some(sl);
3217 addDomainConstraint(pp, "int_in",
3218 new AST::BoolVar(base0), newdom);
3219 ivs1->domain = Option<AST::SetLit*>::none();
3220 }
3221 ivs1->alias = true;
3222 ivs1->i = base0;
3223 }
3224 } else if (cid=="float_eq" && (yyvsp[-2].argVec)->a[0]->isFloatVar() && (yyvsp[-2].argVec)->a[1]->isFloatVar()) {
3225 int base0 = getBaseFloatVar(pp,(yyvsp[-2].argVec)->a[0]->getFloatVar());
3226 int base1 = getBaseFloatVar(pp,(yyvsp[-2].argVec)->a[1]->getFloatVar());
3227 if (base0 > base1) {
3228 std::swap(base0, base1);
3229 }
3230 if (base0==base1) {
3231 // do nothing, already aliased
3232 } else {
3233 FloatVarSpec* ivs1 = static_cast<FloatVarSpec*>(pp->floatvars[base1].second);
3234 ivs1->alias = true;
3235 ivs1->i = base0;
3236 if (ivs1->domain()) {
3237 std::pair<double,double>* dom = new std::pair<double,double>(ivs1->domain.some());
3238 addDomainConstraint(pp, new AST::FloatVar(base0), Option<std::pair<double,double>* >::some(dom));
3239 ivs1->domain = Option<std::pair<double,double> >::none();
3240 }
3241 }
3242 } else if (cid=="set_eq" && (yyvsp[-2].argVec)->a[0]->isSetVar() && (yyvsp[-2].argVec)->a[1]->isSetVar()) {
3243 int base0 = getBaseSetVar(pp,(yyvsp[-2].argVec)->a[0]->getSetVar());
3244 int base1 = getBaseSetVar(pp,(yyvsp[-2].argVec)->a[1]->getSetVar());
3245 if (base0 > base1) {
3246 std::swap(base0, base1);
3247 }
3248 if (base0==base1) {
3249 // do nothing, already aliased
3250 } else {
3251 SetVarSpec* ivs1 = static_cast<SetVarSpec*>(pp->setvars[base1].second);
3252 ivs1->alias = true;
3253 ivs1->i = base0;
3254 if (ivs1->upperBound()) {
3255 AST::SetLit* sl = new AST::SetLit(ivs1->upperBound.some()->getSet());
3256 Option<AST::SetLit*> newdom = Option<AST::SetLit*>::some(sl);
3257 if (ivs1->assigned) {
3258 addDomainConstraint(pp, "set_eq",
3259 new AST::SetVar(base0), newdom);
3260 } else {
3261 addDomainConstraint(pp, "set_subset",
3262 new AST::SetVar(base0), newdom);
3263 }
3264 ivs1->upperBound = Option<AST::SetLit*>::none();
3265 }
3266 }
3267 } else if ( (cid=="int_le" || cid=="int_lt" || cid=="int_ge" || cid=="int_gt" ||
3268 cid=="int_eq" || cid=="int_ne") &&
3269 ((yyvsp[-2].argVec)->a[0]->isInt() || (yyvsp[-2].argVec)->a[1]->isInt()) ) {
3270 pp->domainConstraints.push_back(new ConExpr((yyvsp[-4].sValue), (yyvsp[-2].argVec), (yyvsp[0].argVec)));
3271 } else if ( cid=="set_in" && ((yyvsp[-2].argVec)->a[0]->isSet() || (yyvsp[-2].argVec)->a[1]->isSet()) ) {
3272 pp->domainConstraints.push_back(new ConExpr((yyvsp[-4].sValue), (yyvsp[-2].argVec), (yyvsp[0].argVec)));
3273 } else {
3274 pp->constraints.push_back(new ConExpr((yyvsp[-4].sValue), (yyvsp[-2].argVec), (yyvsp[0].argVec)));
3275 }
3276 }
3277 free((yyvsp[-4].sValue));
3278 }
3279#line 3280 "gecode/flatzinc/parser.tab.cpp"
3280 break;
3281
3282 case 94: /* solve_item: FZ_SOLVE annotations FZ_SATISFY */
3283#line 1584 "../gecode/flatzinc/parser.yxx"
3284 {
3285 ParserState *pp = static_cast<ParserState*>(parm);
3286 initfg(pp);
3287 if (!pp->hadError) {
3288 try {
3289 pp->fg->solve((yyvsp[-1].argVec));
3290 } catch (Gecode::FlatZinc::Error& e) {
3291 yyerror(pp, e.toString().c_str());
3292 }
3293 } else {
3294 delete (yyvsp[-1].argVec);
3295 }
3296 }
3297#line 3298 "gecode/flatzinc/parser.tab.cpp"
3298 break;
3299
3300 case 95: /* solve_item: FZ_SOLVE annotations minmax solve_expr */
3301#line 1598 "../gecode/flatzinc/parser.yxx"
3302 {
3303 ParserState *pp = static_cast<ParserState*>(parm);
3304 initfg(pp);
3305 if (!pp->hadError) {
3306 try {
3307 int v = (yyvsp[0].iValue) < 0 ? (-(yyvsp[0].iValue)-1) : (yyvsp[0].iValue);
3308 bool vi = (yyvsp[0].iValue) >= 0;
3309 if ((yyvsp[-1].bValue))
3310 pp->fg->minimize(v,vi,(yyvsp[-2].argVec));
3311 else
3312 pp->fg->maximize(v,vi,(yyvsp[-2].argVec));
3313 } catch (Gecode::FlatZinc::Error& e) {
3314 yyerror(pp, e.toString().c_str());
3315 }
3316 } else {
3317 delete (yyvsp[-2].argVec);
3318 }
3319 }
3320#line 3321 "gecode/flatzinc/parser.tab.cpp"
3321 break;
3322
3323 case 96: /* int_ti_expr_tail: FZ_INT */
3324#line 1623 "../gecode/flatzinc/parser.yxx"
3325 { (yyval.oSet) = Option<AST::SetLit* >::none(); }
3326#line 3327 "gecode/flatzinc/parser.tab.cpp"
3327 break;
3328
3329 case 97: /* int_ti_expr_tail: '{' int_list '}' */
3330#line 1625 "../gecode/flatzinc/parser.yxx"
3331 { (yyval.oSet) = Option<AST::SetLit* >::some(new AST::SetLit(*(yyvsp[-1].setValue))); }
3332#line 3333 "gecode/flatzinc/parser.tab.cpp"
3333 break;
3334
3335 case 98: /* int_ti_expr_tail: FZ_INT_LIT FZ_DOTDOT FZ_INT_LIT */
3336#line 1627 "../gecode/flatzinc/parser.yxx"
3337 {
3338 (yyval.oSet) = Option<AST::SetLit* >::some(new AST::SetLit((yyvsp[-2].iValue), (yyvsp[0].iValue)));
3339 }
3340#line 3341 "gecode/flatzinc/parser.tab.cpp"
3341 break;
3342
3343 case 99: /* bool_ti_expr_tail: FZ_BOOL */
3344#line 1633 "../gecode/flatzinc/parser.yxx"
3345 { (yyval.oSet) = Option<AST::SetLit* >::none(); }
3346#line 3347 "gecode/flatzinc/parser.tab.cpp"
3347 break;
3348
3349 case 100: /* bool_ti_expr_tail: '{' bool_list_head list_tail '}' */
3350#line 1635 "../gecode/flatzinc/parser.yxx"
3351 { bool haveTrue = false;
3352 bool haveFalse = false;
3353 for (int i=(yyvsp[-2].setValue)->size(); i--;) {
3354 haveTrue |= ((*(yyvsp[-2].setValue))[i] == 1);
3355 haveFalse |= ((*(yyvsp[-2].setValue))[i] == 0);
3356 }
3357 delete (yyvsp[-2].setValue);
3358 (yyval.oSet) = Option<AST::SetLit* >::some(
3359 new AST::SetLit(!haveFalse,haveTrue));
3360 }
3361#line 3362 "gecode/flatzinc/parser.tab.cpp"
3362 break;
3363
3364 case 101: /* float_ti_expr_tail: FZ_FLOAT */
3365#line 1648 "../gecode/flatzinc/parser.yxx"
3366 { (yyval.oPFloat) = Option<std::pair<double,double>* >::none(); }
3367#line 3368 "gecode/flatzinc/parser.tab.cpp"
3368 break;
3369
3370 case 102: /* float_ti_expr_tail: FZ_FLOAT_LIT FZ_DOTDOT FZ_FLOAT_LIT */
3371#line 1650 "../gecode/flatzinc/parser.yxx"
3372 { std::pair<double,double>* dom = new std::pair<double,double>((yyvsp[-2].dValue),(yyvsp[0].dValue));
3373 (yyval.oPFloat) = Option<std::pair<double,double>* >::some(dom); }
3374#line 3375 "gecode/flatzinc/parser.tab.cpp"
3375 break;
3376
3377 case 103: /* set_literal: '{' int_list '}' */
3378#line 1659 "../gecode/flatzinc/parser.yxx"
3379 { (yyval.setLit) = new AST::SetLit(*(yyvsp[-1].setValue)); }
3380#line 3381 "gecode/flatzinc/parser.tab.cpp"
3381 break;
3382
3383 case 104: /* set_literal: FZ_INT_LIT FZ_DOTDOT FZ_INT_LIT */
3384#line 1661 "../gecode/flatzinc/parser.yxx"
3385 { (yyval.setLit) = new AST::SetLit((yyvsp[-2].iValue), (yyvsp[0].iValue)); }
3386#line 3387 "gecode/flatzinc/parser.tab.cpp"
3387 break;
3388
3389 case 105: /* int_list: %empty */
3390#line 1667 "../gecode/flatzinc/parser.yxx"
3391 { (yyval.setValue) = new vector<int>(0); }
3392#line 3393 "gecode/flatzinc/parser.tab.cpp"
3393 break;
3394
3395 case 106: /* int_list: int_list_head list_tail */
3396#line 1669 "../gecode/flatzinc/parser.yxx"
3397 { (yyval.setValue) = (yyvsp[-1].setValue); }
3398#line 3399 "gecode/flatzinc/parser.tab.cpp"
3399 break;
3400
3401 case 107: /* int_list_head: FZ_INT_LIT */
3402#line 1673 "../gecode/flatzinc/parser.yxx"
3403 { (yyval.setValue) = new vector<int>(1); (*(yyval.setValue))[0] = (yyvsp[0].iValue); }
3404#line 3405 "gecode/flatzinc/parser.tab.cpp"
3405 break;
3406
3407 case 108: /* int_list_head: int_list_head ',' FZ_INT_LIT */
3408#line 1675 "../gecode/flatzinc/parser.yxx"
3409 { (yyval.setValue) = (yyvsp[-2].setValue); (yyval.setValue)->push_back((yyvsp[0].iValue)); }
3410#line 3411 "gecode/flatzinc/parser.tab.cpp"
3411 break;
3412
3413 case 109: /* bool_list: %empty */
3414#line 1679 "../gecode/flatzinc/parser.yxx"
3415 { (yyval.setValue) = new vector<int>(0); }
3416#line 3417 "gecode/flatzinc/parser.tab.cpp"
3417 break;
3418
3419 case 110: /* bool_list: bool_list_head list_tail */
3420#line 1681 "../gecode/flatzinc/parser.yxx"
3421 { (yyval.setValue) = (yyvsp[-1].setValue); }
3422#line 3423 "gecode/flatzinc/parser.tab.cpp"
3423 break;
3424
3425 case 111: /* bool_list_head: FZ_BOOL_LIT */
3426#line 1685 "../gecode/flatzinc/parser.yxx"
3427 { (yyval.setValue) = new vector<int>(1); (*(yyval.setValue))[0] = (yyvsp[0].iValue); }
3428#line 3429 "gecode/flatzinc/parser.tab.cpp"
3429 break;
3430
3431 case 112: /* bool_list_head: bool_list_head ',' FZ_BOOL_LIT */
3432#line 1687 "../gecode/flatzinc/parser.yxx"
3433 { (yyval.setValue) = (yyvsp[-2].setValue); (yyval.setValue)->push_back((yyvsp[0].iValue)); }
3434#line 3435 "gecode/flatzinc/parser.tab.cpp"
3435 break;
3436
3437 case 113: /* float_list: %empty */
3438#line 1691 "../gecode/flatzinc/parser.yxx"
3439 { (yyval.floatSetValue) = new vector<double>(0); }
3440#line 3441 "gecode/flatzinc/parser.tab.cpp"
3441 break;
3442
3443 case 114: /* float_list: float_list_head list_tail */
3444#line 1693 "../gecode/flatzinc/parser.yxx"
3445 { (yyval.floatSetValue) = (yyvsp[-1].floatSetValue); }
3446#line 3447 "gecode/flatzinc/parser.tab.cpp"
3447 break;
3448
3449 case 115: /* float_list_head: FZ_FLOAT_LIT */
3450#line 1697 "../gecode/flatzinc/parser.yxx"
3451 { (yyval.floatSetValue) = new vector<double>(1); (*(yyval.floatSetValue))[0] = (yyvsp[0].dValue); }
3452#line 3453 "gecode/flatzinc/parser.tab.cpp"
3453 break;
3454
3455 case 116: /* float_list_head: float_list_head ',' FZ_FLOAT_LIT */
3456#line 1699 "../gecode/flatzinc/parser.yxx"
3457 { (yyval.floatSetValue) = (yyvsp[-2].floatSetValue); (yyval.floatSetValue)->push_back((yyvsp[0].dValue)); }
3458#line 3459 "gecode/flatzinc/parser.tab.cpp"
3459 break;
3460
3461 case 117: /* set_literal_list: %empty */
3462#line 1703 "../gecode/flatzinc/parser.yxx"
3463 { (yyval.setValueList) = new vector<AST::SetLit>(0); }
3464#line 3465 "gecode/flatzinc/parser.tab.cpp"
3465 break;
3466
3467 case 118: /* set_literal_list: set_literal_list_head list_tail */
3468#line 1705 "../gecode/flatzinc/parser.yxx"
3469 { (yyval.setValueList) = (yyvsp[-1].setValueList); }
3470#line 3471 "gecode/flatzinc/parser.tab.cpp"
3471 break;
3472
3473 case 119: /* set_literal_list_head: set_literal */
3474#line 1709 "../gecode/flatzinc/parser.yxx"
3475 { (yyval.setValueList) = new vector<AST::SetLit>(1); (*(yyval.setValueList))[0] = *(yyvsp[0].setLit); delete (yyvsp[0].setLit); }
3476#line 3477 "gecode/flatzinc/parser.tab.cpp"
3477 break;
3478
3479 case 120: /* set_literal_list_head: set_literal_list_head ',' set_literal */
3480#line 1711 "../gecode/flatzinc/parser.yxx"
3481 { (yyval.setValueList) = (yyvsp[-2].setValueList); (yyval.setValueList)->push_back(*(yyvsp[0].setLit)); delete (yyvsp[0].setLit); }
3482#line 3483 "gecode/flatzinc/parser.tab.cpp"
3483 break;
3484
3485 case 121: /* flat_expr_list: flat_expr */
3486#line 1719 "../gecode/flatzinc/parser.yxx"
3487 { (yyval.argVec) = new AST::Array((yyvsp[0].arg)); }
3488#line 3489 "gecode/flatzinc/parser.tab.cpp"
3489 break;
3490
3491 case 122: /* flat_expr_list: flat_expr_list ',' flat_expr */
3492#line 1721 "../gecode/flatzinc/parser.yxx"
3493 { (yyval.argVec) = (yyvsp[-2].argVec); (yyval.argVec)->append((yyvsp[0].arg)); }
3494#line 3495 "gecode/flatzinc/parser.tab.cpp"
3495 break;
3496
3497 case 123: /* flat_expr: non_array_expr */
3498#line 1725 "../gecode/flatzinc/parser.yxx"
3499 { (yyval.arg) = (yyvsp[0].arg); }
3500#line 3501 "gecode/flatzinc/parser.tab.cpp"
3501 break;
3502
3503 case 124: /* flat_expr: '[' non_array_expr_list ']' */
3504#line 1727 "../gecode/flatzinc/parser.yxx"
3505 { (yyval.arg) = (yyvsp[-1].argVec); }
3506#line 3507 "gecode/flatzinc/parser.tab.cpp"
3507 break;
3508
3509 case 125: /* non_array_expr_opt: %empty */
3510#line 1731 "../gecode/flatzinc/parser.yxx"
3511 { (yyval.oArg) = Option<AST::Node*>::none(); }
3512#line 3513 "gecode/flatzinc/parser.tab.cpp"
3513 break;
3514
3515 case 126: /* non_array_expr_opt: '=' non_array_expr */
3516#line 1733 "../gecode/flatzinc/parser.yxx"
3517 { (yyval.oArg) = Option<AST::Node*>::some((yyvsp[0].arg)); }
3518#line 3519 "gecode/flatzinc/parser.tab.cpp"
3519 break;
3520
3521 case 127: /* non_array_expr: FZ_BOOL_LIT */
3522#line 1737 "../gecode/flatzinc/parser.yxx"
3523 { (yyval.arg) = new AST::BoolLit((yyvsp[0].iValue)); }
3524#line 3525 "gecode/flatzinc/parser.tab.cpp"
3525 break;
3526
3527 case 128: /* non_array_expr: FZ_INT_LIT */
3528#line 1739 "../gecode/flatzinc/parser.yxx"
3529 { (yyval.arg) = new AST::IntLit((yyvsp[0].iValue)); }
3530#line 3531 "gecode/flatzinc/parser.tab.cpp"
3531 break;
3532
3533 case 129: /* non_array_expr: FZ_FLOAT_LIT */
3534#line 1741 "../gecode/flatzinc/parser.yxx"
3535 { (yyval.arg) = new AST::FloatLit((yyvsp[0].dValue)); }
3536#line 3537 "gecode/flatzinc/parser.tab.cpp"
3537 break;
3538
3539 case 130: /* non_array_expr: set_literal */
3540#line 1743 "../gecode/flatzinc/parser.yxx"
3541 { (yyval.arg) = (yyvsp[0].setLit); }
3542#line 3543 "gecode/flatzinc/parser.tab.cpp"
3543 break;
3544
3545 case 131: /* non_array_expr: var_par_id */
3546#line 1745 "../gecode/flatzinc/parser.yxx"
3547 {
3548 ParserState* pp = static_cast<ParserState*>(parm);
3549 SymbolEntry e;
3550 if (pp->symbols.get((yyvsp[0].sValue), e)) {
3551 switch (e.t) {
3552 case ST_INTVARARRAY:
3553 {
3554 AST::Array *v = new AST::Array(pp->arrays[e.i]);
3555 for (int i=pp->arrays[e.i]; i--;)
3556 v->a[i] = new AST::IntVar(pp->arrays[e.i+i+1]);
3557 (yyval.arg) = v;
3558 }
3559 break;
3560 case ST_BOOLVARARRAY:
3561 {
3562 AST::Array *v = new AST::Array(pp->arrays[e.i]);
3563 for (int i=pp->arrays[e.i]; i--;)
3564 v->a[i] = new AST::BoolVar(pp->arrays[e.i+i+1]);
3565 (yyval.arg) = v;
3566 }
3567 break;
3568 case ST_FLOATVARARRAY:
3569 {
3570 AST::Array *v = new AST::Array(pp->arrays[e.i]);
3571 for (int i=pp->arrays[e.i]; i--;)
3572 v->a[i] = new AST::FloatVar(pp->arrays[e.i+i+1]);
3573 (yyval.arg) = v;
3574 }
3575 break;
3576 case ST_SETVARARRAY:
3577 {
3578 AST::Array *v = new AST::Array(pp->arrays[e.i]);
3579 for (int i=pp->arrays[e.i]; i--;)
3580 v->a[i] = new AST::SetVar(pp->arrays[e.i+i+1]);
3581 (yyval.arg) = v;
3582 }
3583 break;
3584 case ST_INTVALARRAY:
3585 {
3586 AST::Array *v = new AST::Array(pp->arrays[e.i]);
3587 for (int i=pp->arrays[e.i]; i--;)
3588 v->a[i] = new AST::IntLit(pp->arrays[e.i+i+1]);
3589 (yyval.arg) = v;
3590 }
3591 break;
3592 case ST_BOOLVALARRAY:
3593 {
3594 AST::Array *v = new AST::Array(pp->arrays[e.i]);
3595 for (int i=pp->arrays[e.i]; i--;)
3596 v->a[i] = new AST::BoolLit(pp->arrays[e.i+i+1]);
3597 (yyval.arg) = v;
3598 }
3599 break;
3600 case ST_SETVALARRAY:
3601 {
3602 AST::Array *v = new AST::Array(pp->arrays[e.i]);
3603 int idx = pp->arrays[e.i+1];
3604 for (int i=pp->arrays[e.i]; i--;)
3605 v->a[i] = new AST::SetLit(pp->setvals[idx+i]);
3606 (yyval.arg) = v;
3607 }
3608 break;
3609 case ST_FLOATVALARRAY:
3610 {
3611 AST::Array *v = new AST::Array(pp->arrays[e.i]);
3612 int idx = pp->arrays[e.i+1];
3613 for (int i=pp->arrays[e.i]; i--;)
3614 v->a[i] = new AST::FloatLit(pp->floatvals[idx+i]);
3615 (yyval.arg) = v;
3616 }
3617 break;
3618 case ST_INT:
3619 (yyval.arg) = new AST::IntLit(e.i);
3620 break;
3621 case ST_BOOL:
3622 (yyval.arg) = new AST::BoolLit(e.i);
3623 break;
3624 case ST_FLOAT:
3625 (yyval.arg) = new AST::FloatLit(pp->floatvals[e.i]);
3626 break;
3627 case ST_SET:
3628 (yyval.arg) = new AST::SetLit(pp->setvals[e.i]);
3629 break;
3630 default:
3631 (yyval.arg) = getVarRefArg(pp,(yyvsp[0].sValue));
3632 }
3633 } else {
3634 pp->err << "Error: undefined identifier " << (yyvsp[0].sValue)
3635 << " in line no. "
3636 << yyget_lineno(pp->yyscanner) << std::endl;
3637 pp->hadError = true;
3638 (yyval.arg) = NULL;
3639 }
3640 free((yyvsp[0].sValue));
3641 }
3642#line 3643 "gecode/flatzinc/parser.tab.cpp"
3643 break;
3644
3645 case 132: /* non_array_expr: var_par_id '[' non_array_expr ']' */
3646#line 1841 "../gecode/flatzinc/parser.yxx"
3647 {
3648 ParserState* pp = static_cast<ParserState*>(parm);
3649 int i = -1;
3650 yyassert(pp, (yyvsp[-1].arg)->isInt(i), "Non-integer array index");
3651 if (!pp->hadError)
3652 (yyval.arg) = getArrayElement(static_cast<ParserState*>(parm),(yyvsp[-3].sValue),i,false);
3653 else
3654 (yyval.arg) = new AST::IntLit(0); // keep things consistent
3655 delete (yyvsp[-1].arg);
3656 free((yyvsp[-3].sValue));
3657 }
3658#line 3659 "gecode/flatzinc/parser.tab.cpp"
3659 break;
3660
3661 case 133: /* non_array_expr_list: %empty */
3662#line 1855 "../gecode/flatzinc/parser.yxx"
3663 { (yyval.argVec) = new AST::Array(0); }
3664#line 3665 "gecode/flatzinc/parser.tab.cpp"
3665 break;
3666
3667 case 134: /* non_array_expr_list: non_array_expr_list_head list_tail */
3668#line 1857 "../gecode/flatzinc/parser.yxx"
3669 { (yyval.argVec) = (yyvsp[-1].argVec); }
3670#line 3671 "gecode/flatzinc/parser.tab.cpp"
3671 break;
3672
3673 case 135: /* non_array_expr_list_head: non_array_expr */
3674#line 1861 "../gecode/flatzinc/parser.yxx"
3675 { (yyval.argVec) = new AST::Array((yyvsp[0].arg)); }
3676#line 3677 "gecode/flatzinc/parser.tab.cpp"
3677 break;
3678
3679 case 136: /* non_array_expr_list_head: non_array_expr_list_head ',' non_array_expr */
3680#line 1863 "../gecode/flatzinc/parser.yxx"
3681 { (yyval.argVec) = (yyvsp[-2].argVec); (yyval.argVec)->append((yyvsp[0].arg)); }
3682#line 3683 "gecode/flatzinc/parser.tab.cpp"
3683 break;
3684
3685 case 137: /* solve_expr: var_par_id */
3686#line 1871 "../gecode/flatzinc/parser.yxx"
3687 {
3688 ParserState *pp = static_cast<ParserState*>(parm);
3689 SymbolEntry e;
3690 bool haveSym = pp->symbols.get((yyvsp[0].sValue),e);
3691 if (haveSym) {
3692 switch (e.t) {
3693 case ST_INTVAR:
3694 (yyval.iValue) = e.i;
3695 break;
3696 case ST_FLOATVAR:
3697 (yyval.iValue) = -e.i-1;
3698 break;
3699 case ST_INT:
3700 case ST_FLOAT:
3701 pp->intvars.push_back(varspec("OBJ_CONST_INTRODUCED",
3702 new IntVarSpec(0,true,false)));
3703 (yyval.iValue) = pp->intvars.size()-1;
3704 break;
3705 default:
3706 pp->err << "Error: unknown int or float variable " << (yyvsp[0].sValue)
3707 << " in line no. "
3708 << yyget_lineno(pp->yyscanner) << std::endl;
3709 pp->hadError = true;
3710 break;
3711 }
3712 } else {
3713 pp->err << "Error: unknown int or float variable " << (yyvsp[0].sValue)
3714 << " in line no. "
3715 << yyget_lineno(pp->yyscanner) << std::endl;
3716 pp->hadError = true;
3717 }
3718 free((yyvsp[0].sValue));
3719 }
3720#line 3721 "gecode/flatzinc/parser.tab.cpp"
3721 break;
3722
3723 case 138: /* solve_expr: FZ_INT_LIT */
3724#line 1905 "../gecode/flatzinc/parser.yxx"
3725 {
3726 ParserState *pp = static_cast<ParserState*>(parm);
3727 pp->intvars.push_back(varspec("OBJ_CONST_INTRODUCED",
3728 new IntVarSpec(0,true,false)));
3729 (yyval.iValue) = pp->intvars.size()-1;
3730 }
3731#line 3732 "gecode/flatzinc/parser.tab.cpp"
3732 break;
3733
3734 case 139: /* solve_expr: FZ_FLOAT_LIT */
3735#line 1912 "../gecode/flatzinc/parser.yxx"
3736 {
3737 ParserState *pp = static_cast<ParserState*>(parm);
3738 pp->intvars.push_back(varspec("OBJ_CONST_INTRODUCED",
3739 new IntVarSpec(0,true,false)));
3740 (yyval.iValue) = pp->intvars.size()-1;
3741 }
3742#line 3743 "gecode/flatzinc/parser.tab.cpp"
3743 break;
3744
3745 case 140: /* solve_expr: var_par_id '[' FZ_INT_LIT ']' */
3746#line 1919 "../gecode/flatzinc/parser.yxx"
3747 {
3748 SymbolEntry e;
3749 ParserState *pp = static_cast<ParserState*>(parm);
3750 if ( (!pp->symbols.get((yyvsp[-3].sValue), e)) ||
3751 (e.t != ST_INTVARARRAY && e.t != ST_FLOATVARARRAY)) {
3752 pp->err << "Error: unknown int or float variable array " << (yyvsp[-3].sValue)
3753 << " in line no. "
3754 << yyget_lineno(pp->yyscanner) << std::endl;
3755 pp->hadError = true;
3756 }
3757 if ((yyvsp[-1].iValue) == 0 || (yyvsp[-1].iValue) > pp->arrays[e.i]) {
3758 pp->err << "Error: array index out of bounds for array " << (yyvsp[-3].sValue)
3759 << " in line no. "
3760 << yyget_lineno(pp->yyscanner) << std::endl;
3761 pp->hadError = true;
3762 } else {
3763 if (e.t == ST_INTVARARRAY)
3764 (yyval.iValue) = pp->arrays[e.i+(yyvsp[-1].iValue)];
3765 else
3766 (yyval.iValue) = -pp->arrays[e.i+(yyvsp[-1].iValue)]-1;
3767 }
3768 free((yyvsp[-3].sValue));
3769 }
3770#line 3771 "gecode/flatzinc/parser.tab.cpp"
3771 break;
3772
3773 case 143: /* annotations: %empty */
3774#line 1953 "../gecode/flatzinc/parser.yxx"
3775 { (yyval.argVec) = NULL; }
3776#line 3777 "gecode/flatzinc/parser.tab.cpp"
3777 break;
3778
3779 case 144: /* annotations: annotations_head */
3780#line 1955 "../gecode/flatzinc/parser.yxx"
3781 { (yyval.argVec) = (yyvsp[0].argVec); }
3782#line 3783 "gecode/flatzinc/parser.tab.cpp"
3783 break;
3784
3785 case 145: /* annotations_head: FZ_COLONCOLON annotation */
3786#line 1959 "../gecode/flatzinc/parser.yxx"
3787 { (yyval.argVec) = new AST::Array((yyvsp[0].arg)); }
3788#line 3789 "gecode/flatzinc/parser.tab.cpp"
3789 break;
3790
3791 case 146: /* annotations_head: annotations_head FZ_COLONCOLON annotation */
3792#line 1961 "../gecode/flatzinc/parser.yxx"
3793 { (yyval.argVec) = (yyvsp[-2].argVec); (yyval.argVec)->append((yyvsp[0].arg)); }
3794#line 3795 "gecode/flatzinc/parser.tab.cpp"
3795 break;
3796
3797 case 147: /* annotation: FZ_ID '(' annotation_list ')' */
3798#line 1965 "../gecode/flatzinc/parser.yxx"
3799 {
3800 (yyval.arg) = new AST::Call((yyvsp[-3].sValue), AST::extractSingleton((yyvsp[-1].arg))); free((yyvsp[-3].sValue));
3801 }
3802#line 3803 "gecode/flatzinc/parser.tab.cpp"
3803 break;
3804
3805 case 148: /* annotation: annotation_expr */
3806#line 1969 "../gecode/flatzinc/parser.yxx"
3807 { (yyval.arg) = (yyvsp[0].arg); }
3808#line 3809 "gecode/flatzinc/parser.tab.cpp"
3809 break;
3810
3811 case 149: /* annotation_list: annotation */
3812#line 1973 "../gecode/flatzinc/parser.yxx"
3813 { (yyval.arg) = new AST::Array((yyvsp[0].arg)); }
3814#line 3815 "gecode/flatzinc/parser.tab.cpp"
3815 break;
3816
3817 case 150: /* annotation_list: annotation_list ',' annotation */
3818#line 1975 "../gecode/flatzinc/parser.yxx"
3819 { (yyval.arg) = (yyvsp[-2].arg); (yyval.arg)->append((yyvsp[0].arg)); }
3820#line 3821 "gecode/flatzinc/parser.tab.cpp"
3821 break;
3822
3823 case 151: /* annotation_expr: ann_non_array_expr */
3824#line 1979 "../gecode/flatzinc/parser.yxx"
3825 { (yyval.arg) = (yyvsp[0].arg); }
3826#line 3827 "gecode/flatzinc/parser.tab.cpp"
3827 break;
3828
3829 case 152: /* annotation_expr: '[' ']' */
3830#line 1981 "../gecode/flatzinc/parser.yxx"
3831 { (yyval.arg) = new AST::Array(); }
3832#line 3833 "gecode/flatzinc/parser.tab.cpp"
3833 break;
3834
3835 case 153: /* annotation_expr: '[' annotation_list annotation_list_tail ']' */
3836#line 1983 "../gecode/flatzinc/parser.yxx"
3837 { (yyval.arg) = (yyvsp[-2].arg); }
3838#line 3839 "gecode/flatzinc/parser.tab.cpp"
3839 break;
3840
3841 case 156: /* ann_non_array_expr: FZ_BOOL_LIT */
3842#line 1989 "../gecode/flatzinc/parser.yxx"
3843 { (yyval.arg) = new AST::BoolLit((yyvsp[0].iValue)); }
3844#line 3845 "gecode/flatzinc/parser.tab.cpp"
3845 break;
3846
3847 case 157: /* ann_non_array_expr: FZ_INT_LIT */
3848#line 1991 "../gecode/flatzinc/parser.yxx"
3849 { (yyval.arg) = new AST::IntLit((yyvsp[0].iValue)); }
3850#line 3851 "gecode/flatzinc/parser.tab.cpp"
3851 break;
3852
3853 case 158: /* ann_non_array_expr: FZ_FLOAT_LIT */
3854#line 1993 "../gecode/flatzinc/parser.yxx"
3855 { (yyval.arg) = new AST::FloatLit((yyvsp[0].dValue)); }
3856#line 3857 "gecode/flatzinc/parser.tab.cpp"
3857 break;
3858
3859 case 159: /* ann_non_array_expr: set_literal */
3860#line 1995 "../gecode/flatzinc/parser.yxx"
3861 { (yyval.arg) = (yyvsp[0].setLit); }
3862#line 3863 "gecode/flatzinc/parser.tab.cpp"
3863 break;
3864
3865 case 160: /* ann_non_array_expr: var_par_id */
3866#line 1997 "../gecode/flatzinc/parser.yxx"
3867 {
3868 ParserState* pp = static_cast<ParserState*>(parm);
3869 SymbolEntry e;
3870 bool gotSymbol = false;
3871 if (pp->symbols.get((yyvsp[0].sValue), e)) {
3872 gotSymbol = true;
3873 switch (e.t) {
3874 case ST_INTVARARRAY:
3875 {
3876 AST::Array *v = new AST::Array(pp->arrays[e.i]);
3877 for (int i=pp->arrays[e.i]; i--;) {
3878 std::ostringstream oss;
3879 oss << (yyvsp[0].sValue) << "["<<(i+1)<<"]";
3880 v->a[i] = new AST::IntVar(pp->arrays[e.i+i+1], oss.str());
3881 }
3882 (yyval.arg) = v;
3883 }
3884 break;
3885 case ST_BOOLVARARRAY:
3886 {
3887 AST::Array *v = new AST::Array(pp->arrays[e.i]);
3888 for (int i=pp->arrays[e.i]; i--;) {
3889 std::ostringstream oss;
3890 oss << (yyvsp[0].sValue) << "["<<(i+1)<<"]";
3891 v->a[i] = new AST::BoolVar(pp->arrays[e.i+i+1], oss.str());
3892 }
3893 (yyval.arg) = v;
3894 }
3895 break;
3896 case ST_FLOATVARARRAY:
3897 {
3898 AST::Array *v = new AST::Array(pp->arrays[e.i]);
3899 for (int i=pp->arrays[e.i]; i--;) {
3900 std::ostringstream oss;
3901 oss << (yyvsp[0].sValue) << "["<<(i+1)<<"]";
3902 v->a[i] = new AST::FloatVar(pp->arrays[e.i+i+1], oss.str());
3903 }
3904 (yyval.arg) = v;
3905 }
3906 break;
3907 case ST_SETVARARRAY:
3908 {
3909 AST::Array *v = new AST::Array(pp->arrays[e.i]);
3910 for (int i=pp->arrays[e.i]; i--;) {
3911 std::ostringstream oss;
3912 oss << (yyvsp[0].sValue) << "["<<(i+1)<<"]";
3913 v->a[i] = new AST::SetVar(pp->arrays[e.i+i+1], oss.str());
3914 }
3915 (yyval.arg) = v;
3916 }
3917 break;
3918 case ST_INTVALARRAY:
3919 {
3920 AST::Array *v = new AST::Array(pp->arrays[e.i]);
3921 for (int i=pp->arrays[e.i]; i--;)
3922 v->a[i] = new AST::IntLit(pp->arrays[e.i+i+1]);
3923 (yyval.arg) = v;
3924 }
3925 break;
3926 case ST_BOOLVALARRAY:
3927 {
3928 AST::Array *v = new AST::Array(pp->arrays[e.i]);
3929 for (int i=pp->arrays[e.i]; i--;)
3930 v->a[i] = new AST::BoolLit(pp->arrays[e.i+i+1]);
3931 (yyval.arg) = v;
3932 }
3933 break;
3934 case ST_SETVALARRAY:
3935 {
3936 AST::Array *v = new AST::Array(pp->arrays[e.i]);
3937 int idx = pp->arrays[e.i+1];
3938 for (int i=pp->arrays[e.i]; i--;)
3939 v->a[i] = new AST::SetLit(pp->setvals[idx+i]);
3940 (yyval.arg) = v;
3941 }
3942 break;
3943 case ST_FLOATVALARRAY:
3944 {
3945 AST::Array *v = new AST::Array(pp->arrays[e.i]);
3946 int idx = pp->arrays[e.i+1];
3947 for (int i=pp->arrays[e.i]; i--;)
3948 v->a[i] = new AST::FloatLit(pp->floatvals[idx+i]);
3949 (yyval.arg) = v;
3950 }
3951 break;
3952 case ST_INT:
3953 (yyval.arg) = new AST::IntLit(e.i);
3954 break;
3955 case ST_BOOL:
3956 (yyval.arg) = new AST::BoolLit(e.i);
3957 break;
3958 case ST_FLOAT:
3959 (yyval.arg) = new AST::FloatLit(pp->floatvals[e.i]);
3960 break;
3961 case ST_SET:
3962 (yyval.arg) = new AST::SetLit(pp->setvals[e.i]);
3963 break;
3964 default:
3965 gotSymbol = false;
3966 }
3967 }
3968 if (!gotSymbol)
3969 (yyval.arg) = getVarRefArg(pp,(yyvsp[0].sValue),true);
3970 free((yyvsp[0].sValue));
3971 }
3972#line 3973 "gecode/flatzinc/parser.tab.cpp"
3973 break;
3974
3975 case 161: /* ann_non_array_expr: var_par_id '[' ann_non_array_expr ']' */
3976#line 2103 "../gecode/flatzinc/parser.yxx"
3977 {
3978 ParserState* pp = static_cast<ParserState*>(parm);
3979 int i = -1;
3980 yyassert(pp, (yyvsp[-1].arg)->isInt(i), "Non-integer array index");
3981 if (!pp->hadError)
3982 (yyval.arg) = getArrayElement(static_cast<ParserState*>(parm),(yyvsp[-3].sValue),i,true);
3983 else
3984 (yyval.arg) = new AST::IntLit(0); // keep things consistent
3985 free((yyvsp[-3].sValue));
3986 }
3987#line 3988 "gecode/flatzinc/parser.tab.cpp"
3988 break;
3989
3990 case 162: /* ann_non_array_expr: FZ_STRING_LIT */
3991#line 2114 "../gecode/flatzinc/parser.yxx"
3992 {
3993 (yyval.arg) = new AST::String((yyvsp[0].sValue));
3994 free((yyvsp[0].sValue));
3995 }
3996#line 3997 "gecode/flatzinc/parser.tab.cpp"
3997 break;
3998
3999
4000#line 4001 "gecode/flatzinc/parser.tab.cpp"
4001
4002 default: break;
4003 }
4004 /* User semantic actions sometimes alter yychar, and that requires
4005 that yytoken be updated with the new translation. We take the
4006 approach of translating immediately before every use of yytoken.
4007 One alternative is translating here after every semantic action,
4008 but that translation would be missed if the semantic action invokes
4009 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
4010 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
4011 incorrect destructor might then be invoked immediately. In the
4012 case of YYERROR or YYBACKUP, subsequent parser actions might lead
4013 to an incorrect destructor call or verbose syntax error message
4014 before the lookahead is translated. */
4015 YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
4016
4017 YYPOPSTACK (yylen);
4018 yylen = 0;
4019
4020 *++yyvsp = yyval;
4021
4022 /* Now 'shift' the result of the reduction. Determine what state
4023 that goes to, based on the state we popped back to and the rule
4024 number reduced by. */
4025 {
4026 const int yylhs = yyr1[yyn] - YYNTOKENS;
4027 const int yyi = yypgoto[yylhs] + *yyssp;
4028 yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
4029 ? yytable[yyi]
4030 : yydefgoto[yylhs]);
4031 }
4032
4033 goto yynewstate;
4034
4035
4036/*--------------------------------------.
4037| yyerrlab -- here on detecting error. |
4038`--------------------------------------*/
4039yyerrlab:
4040 /* Make sure we have latest lookahead translation. See comments at
4041 user semantic actions for why this is necessary. */
4042 yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
4043 /* If not already recovering from an error, report this error. */
4044 if (!yyerrstatus)
4045 {
4046 ++yynerrs;
4047 {
4048 yypcontext_t yyctx
4049 = {yyssp, yytoken};
4050 char const *yymsgp = YY_("syntax error");
4051 int yysyntax_error_status;
4052 yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
4053 if (yysyntax_error_status == 0)
4054 yymsgp = yymsg;
4055 else if (yysyntax_error_status == -1)
4056 {
4057 if (yymsg != yymsgbuf)
4058 YYSTACK_FREE (yymsg);
4059 yymsg = YY_CAST (char *,
4060 YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc)));
4061 if (yymsg)
4062 {
4063 yysyntax_error_status
4064 = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
4065 yymsgp = yymsg;
4066 }
4067 else
4068 {
4069 yymsg = yymsgbuf;
4070 yymsg_alloc = sizeof yymsgbuf;
4071 yysyntax_error_status = YYENOMEM;
4072 }
4073 }
4074 yyerror (parm, yymsgp);
4075 if (yysyntax_error_status == YYENOMEM)
4076 goto yyexhaustedlab;
4077 }
4078 }
4079
4080 if (yyerrstatus == 3)
4081 {
4082 /* If just tried and failed to reuse lookahead token after an
4083 error, discard it. */
4084
4085 if (yychar <= YYEOF)
4086 {
4087 /* Return failure if at end of input. */
4088 if (yychar == YYEOF)
4089 YYABORT;
4090 }
4091 else
4092 {
4093 yydestruct ("Error: discarding",
4094 yytoken, &yylval, parm);
4095 yychar = YYEMPTY;
4096 }
4097 }
4098
4099 /* Else will try to reuse lookahead token after shifting the error
4100 token. */
4101 goto yyerrlab1;
4102
4103
4104/*---------------------------------------------------.
4105| yyerrorlab -- error raised explicitly by YYERROR. |
4106`---------------------------------------------------*/
4107yyerrorlab:
4108 /* Pacify compilers when the user code never invokes YYERROR and the
4109 label yyerrorlab therefore never appears in user code. */
4110 if (0)
4111 YYERROR;
4112
4113 /* Do not reclaim the symbols of the rule whose action triggered
4114 this YYERROR. */
4115 YYPOPSTACK (yylen);
4116 yylen = 0;
4117 YY_STACK_PRINT (yyss, yyssp);
4118 yystate = *yyssp;
4119 goto yyerrlab1;
4120
4121
4122/*-------------------------------------------------------------.
4123| yyerrlab1 -- common code for both syntax error and YYERROR. |
4124`-------------------------------------------------------------*/
4125yyerrlab1:
4126 yyerrstatus = 3; /* Each real token shifted decrements this. */
4127
4128 /* Pop stack until we find a state that shifts the error token. */
4129 for (;;)
4130 {
4131 yyn = yypact[yystate];
4132 if (!yypact_value_is_default (yyn))
4133 {
4134 yyn += YYSYMBOL_YYerror;
4135 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
4136 {
4137 yyn = yytable[yyn];
4138 if (0 < yyn)
4139 break;
4140 }
4141 }
4142
4143 /* Pop the current state because it cannot handle the error token. */
4144 if (yyssp == yyss)
4145 YYABORT;
4146
4147
4148 yydestruct ("Error: popping",
4149 YY_ACCESSING_SYMBOL (yystate), yyvsp, parm);
4150 YYPOPSTACK (1);
4151 yystate = *yyssp;
4152 YY_STACK_PRINT (yyss, yyssp);
4153 }
4154
4155 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
4156 *++yyvsp = yylval;
4157 YY_IGNORE_MAYBE_UNINITIALIZED_END
4158
4159
4160 /* Shift the error token. */
4161 YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
4162
4163 yystate = yyn;
4164 goto yynewstate;
4165
4166
4167/*-------------------------------------.
4168| yyacceptlab -- YYACCEPT comes here. |
4169`-------------------------------------*/
4170yyacceptlab:
4171 yyresult = 0;
4172 goto yyreturn;
4173
4174
4175/*-----------------------------------.
4176| yyabortlab -- YYABORT comes here. |
4177`-----------------------------------*/
4178yyabortlab:
4179 yyresult = 1;
4180 goto yyreturn;
4181
4182
4183#if 1
4184/*-------------------------------------------------.
4185| yyexhaustedlab -- memory exhaustion comes here. |
4186`-------------------------------------------------*/
4187yyexhaustedlab:
4188 yyerror (parm, YY_("memory exhausted"));
4189 yyresult = 2;
4190 goto yyreturn;
4191#endif
4192
4193
4194/*-------------------------------------------------------.
4195| yyreturn -- parsing is finished, clean up and return. |
4196`-------------------------------------------------------*/
4197yyreturn:
4198 if (yychar != YYEMPTY)
4199 {
4200 /* Make sure we have latest lookahead translation. See comments at
4201 user semantic actions for why this is necessary. */
4202 yytoken = YYTRANSLATE (yychar);
4203 yydestruct ("Cleanup: discarding lookahead",
4204 yytoken, &yylval, parm);
4205 }
4206 /* Do not reclaim the symbols of the rule whose action triggered
4207 this YYABORT or YYACCEPT. */
4208 YYPOPSTACK (yylen);
4209 YY_STACK_PRINT (yyss, yyssp);
4210 while (yyssp != yyss)
4211 {
4212 yydestruct ("Cleanup: popping",
4213 YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, parm);
4214 YYPOPSTACK (1);
4215 }
4216#ifndef yyoverflow
4217 if (yyss != yyssa)
4218 YYSTACK_FREE (yyss);
4219#endif
4220 if (yymsg != yymsgbuf)
4221 YYSTACK_FREE (yymsg);
4222 return yyresult;
4223}
4224