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