Google OR-Tools v9.15
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
parser.tab.cc
Go to the documentation of this file.
1/* A Bison parser, made by GNU Bison 3.8.2. */
2
3/* Bison implementation for Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 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 <https://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, and Bison version. */
49#define YYBISON 30802
50
51/* Bison version string. */
52#define YYBISON_VERSION "3.8.2"
53
54/* Skeleton name. */
55#define YYSKELETON_NAME "yacc.c"
56
57/* Pure parsers. */
58#define YYPURE 2
59
60/* Push parsers. */
61#define YYPUSH 0
62
63/* Pull parsers. */
64#define YYPULL 1
65
66/* Substitute the type names. */
67#define YYSTYPE ORFZ_STYPE
68/* Substitute the variable and function names. */
69#define yyparse orfz_parse
70#define yylex orfz_lex
71#define yyerror orfz_error
72#define yydebug orfz_debug
73#define yynerrs orfz_nerrs
74
75#ifndef YY_CAST
76#ifdef __cplusplus
77#define YY_CAST(Type, Val) static_cast<Type>(Val)
78#define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type>(Val)
79#else
80#define YY_CAST(Type, Val) ((Type)(Val))
81#define YY_REINTERPRET_CAST(Type, Val) ((Type)(Val))
82#endif
83#endif
84#ifndef YY_NULLPTR
85#if defined __cplusplus
86#if 201103L <= __cplusplus
87#define YY_NULLPTR nullptr
88#else
89#define YY_NULLPTR 0
90#endif
91#else
92#define YY_NULLPTR ((void*)0)
93#endif
94#endif
95
96#include "parser.tab.hh"
97/* Symbol kind. */
100 YYSYMBOL_YYEOF = 0, /* "end of file" */
101 YYSYMBOL_YYerror = 1, /* error */
102 YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
103 YYSYMBOL_ARRAY = 3, /* ARRAY */
104 YYSYMBOL_TOKEN_BOOL = 4, /* TOKEN_BOOL */
105 YYSYMBOL_CONSTRAINT = 5, /* CONSTRAINT */
106 YYSYMBOL_TOKEN_FLOAT = 6, /* TOKEN_FLOAT */
107 YYSYMBOL_TOKEN_INT = 7, /* TOKEN_INT */
108 YYSYMBOL_MAXIMIZE = 8, /* MAXIMIZE */
109 YYSYMBOL_MINIMIZE = 9, /* MINIMIZE */
110 YYSYMBOL_OF = 10, /* OF */
111 YYSYMBOL_PREDICATE = 11, /* PREDICATE */
112 YYSYMBOL_SATISFY = 12, /* SATISFY */
113 YYSYMBOL_SET = 13, /* SET */
114 YYSYMBOL_SOLVE = 14, /* SOLVE */
115 YYSYMBOL_VAR = 15, /* VAR */
116 YYSYMBOL_DOTDOT = 16, /* DOTDOT */
117 YYSYMBOL_COLONCOLON = 17, /* COLONCOLON */
118 YYSYMBOL_IVALUE = 18, /* IVALUE */
119 YYSYMBOL_SVALUE = 19, /* SVALUE */
120 YYSYMBOL_IDENTIFIER = 20, /* IDENTIFIER */
121 YYSYMBOL_DVALUE = 21, /* DVALUE */
122 YYSYMBOL_22_ = 22, /* ';' */
123 YYSYMBOL_23_ = 23, /* '(' */
124 YYSYMBOL_24_ = 24, /* ')' */
125 YYSYMBOL_25_ = 25, /* ',' */
126 YYSYMBOL_26_ = 26, /* ':' */
127 YYSYMBOL_27_ = 27, /* '[' */
128 YYSYMBOL_28_ = 28, /* ']' */
129 YYSYMBOL_29_ = 29, /* '=' */
130 YYSYMBOL_30_ = 30, /* '{' */
131 YYSYMBOL_31_ = 31, /* '}' */
132 YYSYMBOL_YYACCEPT = 32, /* $accept */
133 YYSYMBOL_model = 33, /* model */
134 YYSYMBOL_predicates = 34, /* predicates */
135 YYSYMBOL_predicate = 35, /* predicate */
136 YYSYMBOL_predicate_arguments = 36, /* predicate_arguments */
137 YYSYMBOL_predicate_argument = 37, /* predicate_argument */
138 YYSYMBOL_predicate_array_argument = 38, /* predicate_array_argument */
139 YYSYMBOL_predicate_ints = 39, /* predicate_ints */
141 40, /* variable_or_constant_declarations */
143 41, /* variable_or_constant_declaration */
144 YYSYMBOL_optional_var_or_value = 42, /* optional_var_or_value */
145 YYSYMBOL_optional_var_or_value_array = 43, /* optional_var_or_value_array */
146 YYSYMBOL_var_or_value_array = 44, /* var_or_value_array */
147 YYSYMBOL_var_or_value = 45, /* var_or_value */
148 YYSYMBOL_int_domain = 46, /* int_domain */
149 YYSYMBOL_set_domain = 47, /* set_domain */
150 YYSYMBOL_float_domain = 48, /* float_domain */
151 YYSYMBOL_domain = 49, /* domain */
152 YYSYMBOL_integers = 50, /* integers */
153 YYSYMBOL_integer = 51, /* integer */
154 YYSYMBOL_floats = 52, /* floats */
155 YYSYMBOL_float = 53, /* float */
156 YYSYMBOL_const_literal = 54, /* const_literal */
157 YYSYMBOL_const_literals = 55, /* const_literals */
158 YYSYMBOL_constraints = 56, /* constraints */
159 YYSYMBOL_constraint = 57, /* constraint */
160 YYSYMBOL_arguments = 58, /* arguments */
161 YYSYMBOL_argument = 59, /* argument */
162 YYSYMBOL_annotations = 60, /* annotations */
163 YYSYMBOL_annotation_arguments = 61, /* annotation_arguments */
164 YYSYMBOL_annotation = 62, /* annotation */
165 YYSYMBOL_solve = 63 /* solve */
166};
168
169/* Unqualified %code blocks. */
170#line 49 "ortools/flatzinc/parser.yy"
171
172#include <cstdint>
173
174#include "absl/log/check.h"
175#include "absl/strings/match.h"
176#include "absl/strings/str_format.h"
178
190
191#line 194 "parser.tab.cc"
192
193#ifdef short
194#undef short
195#endif
196
197/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
198 <limits.h> and (if available) <stdint.h> are included
199 so that the code can choose integer types of a good width. */
200
201#ifndef __PTRDIFF_MAX__
202#include <limits.h> /* INFRINGES ON USER NAME SPACE */
203#if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
204#include <stdint.h> /* INFRINGES ON USER NAME SPACE */
205#define YY_STDINT_H
206#endif
207#endif
208
209/* Narrow types that promote to a signed type and that can represent a
210 signed or unsigned integer of at least N bits. In tables they can
211 save space and decrease cache pressure. Promoting to a signed type
212 helps avoid bugs in integer arithmetic. */
213
214#ifdef __INT_LEAST8_MAX__
215typedef __INT_LEAST8_TYPE__ yytype_int8;
216#elif defined YY_STDINT_H
217typedef int_least8_t yytype_int8;
218#else
219typedef signed char yytype_int8;
220#endif
221
222#ifdef __INT_LEAST16_MAX__
223typedef __INT_LEAST16_TYPE__ yytype_int16;
224#elif defined YY_STDINT_H
225typedef int_least16_t yytype_int16;
226#else
227typedef short yytype_int16;
228#endif
229
230/* Work around bug in HP-UX 11.23, which defines these macros
231 incorrectly for preprocessor constants. This workaround can likely
232 be removed in 2023, as HPE has promised support for HP-UX 11.23
233 (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
234 <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
235#ifdef __hpux
236#undef UINT_LEAST8_MAX
237#undef UINT_LEAST16_MAX
238#define UINT_LEAST8_MAX 255
239#define UINT_LEAST16_MAX 65535
240#endif
241
242#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
243typedef __UINT_LEAST8_TYPE__ yytype_uint8;
244#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H && \
245 UINT_LEAST8_MAX <= INT_MAX)
246typedef uint_least8_t yytype_uint8;
247#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
248typedef unsigned char yytype_uint8;
249#else
250typedef short yytype_uint8;
251#endif
252
253#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
254typedef __UINT_LEAST16_TYPE__ yytype_uint16;
255#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H && \
256 UINT_LEAST16_MAX <= INT_MAX)
257typedef uint_least16_t yytype_uint16;
258#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
259typedef unsigned short yytype_uint16;
260#else
261typedef int yytype_uint16;
262#endif
263
264#ifndef YYPTRDIFF_T
265#if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
266#define YYPTRDIFF_T __PTRDIFF_TYPE__
267#define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
268#elif defined PTRDIFF_MAX
269#ifndef ptrdiff_t
270#include <stddef.h> /* INFRINGES ON USER NAME SPACE */
271#endif
272#define YYPTRDIFF_T ptrdiff_t
273#define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
274#else
275#define YYPTRDIFF_T long
276#define YYPTRDIFF_MAXIMUM LONG_MAX
277#endif
278#endif
279
280#ifndef YYSIZE_T
281#ifdef __SIZE_TYPE__
282#define YYSIZE_T __SIZE_TYPE__
283#elif defined size_t
284#define YYSIZE_T size_t
285#elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
286#include <stddef.h> /* INFRINGES ON USER NAME SPACE */
287#define YYSIZE_T size_t
288#else
289#define YYSIZE_T unsigned
290#endif
291#endif
292
293#define YYSIZE_MAXIMUM \
294 YY_CAST(YYPTRDIFF_T, \
295 (YYPTRDIFF_MAXIMUM < YY_CAST(YYSIZE_T, -1) ? YYPTRDIFF_MAXIMUM \
296 : YY_CAST(YYSIZE_T, -1)))
297
298#define YYSIZEOF(X) YY_CAST(YYPTRDIFF_T, sizeof(X))
299
300/* Stored state numbers (used for stacks). */
302
303/* State numbers in computations. */
304typedef int yy_state_fast_t;
305
306#ifndef YY_
307#if defined YYENABLE_NLS && YYENABLE_NLS
308#if ENABLE_NLS
309#include <libintl.h> /* INFRINGES ON USER NAME SPACE */
310#define YY_(Msgid) dgettext("bison-runtime", Msgid)
311#endif
312#endif
313#ifndef YY_
314#define YY_(Msgid) Msgid
315#endif
316#endif
317
318#ifndef YY_ATTRIBUTE_PURE
319#if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
320#define YY_ATTRIBUTE_PURE __attribute__((__pure__))
321#else
322#define YY_ATTRIBUTE_PURE
323#endif
324#endif
325
326#ifndef YY_ATTRIBUTE_UNUSED
327#if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
328#define YY_ATTRIBUTE_UNUSED __attribute__((__unused__))
329#else
330#define YY_ATTRIBUTE_UNUSED
331#endif
332#endif
333
334/* Suppress unused-variable warnings by "using" E. */
335#if !defined lint || defined __GNUC__
336#define YY_USE(E) ((void)(E))
337#else
338#define YY_USE(E) /* empty */
339#endif
340
341/* Suppress an incorrect diagnostic about yylval being uninitialized. */
342#if defined __GNUC__ && !defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
343#if __GNUC__ * 100 + __GNUC_MINOR__ < 407
344#define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
345 _Pragma("GCC diagnostic push") \
346 _Pragma("GCC diagnostic ignored \"-Wuninitialized\"")
347#else
348#define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
349 _Pragma("GCC diagnostic push") \
350 _Pragma("GCC diagnostic ignored \"-Wuninitialized\"") \
351 _Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
352#endif
353#define YY_IGNORE_MAYBE_UNINITIALIZED_END _Pragma("GCC diagnostic pop")
354#else
355#define YY_INITIAL_VALUE(Value) Value
356#endif
357#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
358#define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
359#define YY_IGNORE_MAYBE_UNINITIALIZED_END
360#endif
361#ifndef YY_INITIAL_VALUE
362#define YY_INITIAL_VALUE(Value) /* Nothing. */
363#endif
364
365#if defined __cplusplus && defined __GNUC__ && !defined __ICC && 6 <= __GNUC__
366#define YY_IGNORE_USELESS_CAST_BEGIN \
367 _Pragma("GCC diagnostic push") \
368 _Pragma("GCC diagnostic ignored \"-Wuseless-cast\"")
369#define YY_IGNORE_USELESS_CAST_END _Pragma("GCC diagnostic pop")
370#endif
371#ifndef YY_IGNORE_USELESS_CAST_BEGIN
372#define YY_IGNORE_USELESS_CAST_BEGIN
373#define YY_IGNORE_USELESS_CAST_END
374#endif
375
376#define YY_ASSERT(E) ((void)(0 && (E)))
377
378#if 1
379
380/* The parser invokes alloca or malloc; define the necessary symbols. */
381
382#ifdef YYSTACK_USE_ALLOCA
383#if YYSTACK_USE_ALLOCA
384#ifdef __GNUC__
385#define YYSTACK_ALLOC __builtin_alloca
386#elif defined __BUILTIN_VA_ARG_INCR
387#include <alloca.h> /* INFRINGES ON USER NAME SPACE */
388#elif defined _AIX
389#define YYSTACK_ALLOC __alloca
390#elif defined _MSC_VER
391#include <malloc.h> /* INFRINGES ON USER NAME SPACE */
392#define alloca _alloca
393#else
394#define YYSTACK_ALLOC alloca
395#if !defined _ALLOCA_H && !defined EXIT_SUCCESS
396#include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
397/* Use EXIT_SUCCESS as a witness for stdlib.h. */
398#ifndef EXIT_SUCCESS
399#define EXIT_SUCCESS 0
400#endif
401#endif
402#endif
403#endif
404#endif
405
406#ifdef YYSTACK_ALLOC
407/* Pacify GCC's 'empty if-body' warning. */
408#define YYSTACK_FREE(Ptr) \
409 do { /* empty */ \
410 ; \
411 } while (0)
412#ifndef YYSTACK_ALLOC_MAXIMUM
413/* The OS might guarantee only one guard page at the bottom of the stack,
414 and a page size can be as small as 4096 bytes. So we cannot safely
415 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
416 to allow for a few compiler-allocated temporary stack slots. */
417#define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
418#endif
419#else
420#define YYSTACK_ALLOC YYMALLOC
421#define YYSTACK_FREE YYFREE
422#ifndef YYSTACK_ALLOC_MAXIMUM
423#define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
424#endif
425#if (defined __cplusplus && !defined EXIT_SUCCESS && \
426 !((defined YYMALLOC || defined malloc) && \
427 (defined YYFREE || defined free)))
428#include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
429#ifndef EXIT_SUCCESS
430#define EXIT_SUCCESS 0
431#endif
432#endif
433#ifndef YYMALLOC
434#define YYMALLOC malloc
435#if !defined malloc && !defined EXIT_SUCCESS
436void* malloc(YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
437#endif
438#endif
439#ifndef YYFREE
440#define YYFREE free
441#if !defined free && !defined EXIT_SUCCESS
442void free(void*); /* INFRINGES ON USER NAME SPACE */
443#endif
444#endif
445#endif
446#endif /* 1 */
447
448#if (!defined yyoverflow && \
449 (!defined __cplusplus || \
450 (defined ORFZ_STYPE_IS_TRIVIAL && ORFZ_STYPE_IS_TRIVIAL)))
451
452/* A type that is properly aligned for any stack member. */
457
458/* The size of the maximum gap between one aligned stack and the next. */
459#define YYSTACK_GAP_MAXIMUM (YYSIZEOF(union yyalloc) - 1)
460
461/* The size of an array large to enough to hold all stacks, each with
462 N elements. */
463#define YYSTACK_BYTES(N) \
464 ((N) * (YYSIZEOF(yy_state_t) + YYSIZEOF(YYSTYPE)) + YYSTACK_GAP_MAXIMUM)
465
466#define YYCOPY_NEEDED 1
467
468/* Relocate STACK from its old location to the new one. The
469 local variables YYSIZE and YYSTACKSIZE give the old and new number of
470 elements in the stack, and YYPTR gives the new location of the
471 stack. Advance YYPTR to a properly aligned location for the next
472 stack. */
473#define YYSTACK_RELOCATE(Stack_alloc, Stack) \
474 do { \
475 YYPTRDIFF_T yynewbytes; \
476 YYCOPY(&yyptr->Stack_alloc, Stack, yysize); \
477 Stack = &yyptr->Stack_alloc; \
478 yynewbytes = yystacksize * YYSIZEOF(*Stack) + YYSTACK_GAP_MAXIMUM; \
479 yyptr += yynewbytes / YYSIZEOF(*yyptr); \
480 } while (0)
481
482#endif
483
484#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
485/* Copy COUNT objects from SRC to DST. The source and destination do
486 not overlap. */
487#ifndef YYCOPY
488#if defined __GNUC__ && 1 < __GNUC__
489#define YYCOPY(Dst, Src, Count) \
490 __builtin_memcpy(Dst, Src, YY_CAST(YYSIZE_T, (Count)) * sizeof(*(Src)))
491#else
492#define YYCOPY(Dst, Src, Count) \
493 do { \
494 YYPTRDIFF_T yyi; \
495 for (yyi = 0; yyi < (Count); yyi++) (Dst)[yyi] = (Src)[yyi]; \
496 } while (0)
497#endif
498#endif
499#endif /* !YYCOPY_NEEDED */
500
501/* YYFINAL -- State number of the termination state. */
502#define YYFINAL 3
503/* YYLAST -- Last index in YYTABLE. */
504#define YYLAST 292
505
506/* YYNTOKENS -- Number of terminals. */
507#define YYNTOKENS 32
508/* YYNNTS -- Number of nonterminals. */
509#define YYNNTS 32
510/* YYNRULES -- Number of rules. */
511#define YYNRULES 101
512/* YYNSTATES -- Number of states. */
513#define YYNSTATES 233
514
515/* YYMAXUTOK -- Last valid token kind. */
516#define YYMAXUTOK 276
517
518/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
519 as returned by yylex, with out-of-bounds checking. */
520#define YYTRANSLATE(YYX) \
521 (0 <= (YYX) && (YYX) <= YYMAXUTOK \
522 ? YY_CAST(yysymbol_kind_t, yytranslate[YYX]) \
523 : YYSYMBOL_YYUNDEF)
524
525/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
526 as returned by yylex. */
527static const yytype_int8 yytranslate[] = {
528 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
529 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
530 23, 24, 2, 2, 25, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 26, 22,
531 2, 29, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
532 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 27, 2, 28, 2, 2, 2, 2, 2, 2,
533 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
534 2, 2, 2, 30, 2, 31, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
535 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
536 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
537 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
538 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
539 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
540 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
541 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21};
542
543#if ORFZ_DEBUG
544/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
545static const yytype_int16 yyrline[] = {
546 0, 118, 118, 125, 129, 130, 135, 138, 139, 142, 143, 144, 145, 148, 149,
547 152, 153, 160, 161, 164, 183, 198, 209, 224, 235, 250, 300, 385, 386, 389,
548 390, 391, 394, 398, 404, 405, 406, 409, 414, 429, 450, 451, 452, 453, 460,
549 461, 462, 463, 470, 471, 476, 477, 478, 481, 482, 485, 486, 487, 492, 493,
550 496, 497, 498, 503, 504, 505, 510, 511, 514, 515, 521, 525, 531, 532, 535,
551 549, 550, 553, 554, 555, 556, 557, 562, 588, 605, 653, 662, 666, 669, 670,
552 673, 674, 679, 680, 681, 695, 704, 710, 739, 748, 756, 767};
553#endif
554
556#define YY_ACCESSING_SYMBOL(State) YY_CAST(yysymbol_kind_t, yystos[State])
557
558#if 1
559/* The user-facing name of the symbol whose (internal) number is
560 YYSYMBOL. No bounds checking. */
561static const char* yysymbol_name(yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
562
563/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
564 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
565static const char* const yytname[] = {"\"end of file\"",
566 "error",
567 "\"invalid token\"",
568 "ARRAY",
569 "TOKEN_BOOL",
570 "CONSTRAINT",
571 "TOKEN_FLOAT",
572 "TOKEN_INT",
573 "MAXIMIZE",
574 "MINIMIZE",
575 "OF",
576 "PREDICATE",
577 "SATISFY",
578 "SET",
579 "SOLVE",
580 "VAR",
581 "DOTDOT",
582 "COLONCOLON",
583 "IVALUE",
584 "SVALUE",
585 "IDENTIFIER",
586 "DVALUE",
587 "';'",
588 "'('",
589 "')'",
590 "','",
591 "':'",
592 "'['",
593 "']'",
594 "'='",
595 "'{'",
596 "'}'",
597 "$accept",
598 "model",
599 "predicates",
600 "predicate",
601 "predicate_arguments",
602 "predicate_argument",
603 "predicate_array_argument",
604 "predicate_ints",
605 "variable_or_constant_declarations",
606 "variable_or_constant_declaration",
607 "optional_var_or_value",
608 "optional_var_or_value_array",
609 "var_or_value_array",
610 "var_or_value",
611 "int_domain",
612 "set_domain",
613 "float_domain",
614 "domain",
615 "integers",
616 "integer",
617 "floats",
618 "float",
619 "const_literal",
620 "const_literals",
621 "constraints",
622 "constraint",
623 "arguments",
624 "argument",
625 "annotations",
626 "annotation_arguments",
627 "annotation",
628 "solve",
629 YY_NULLPTR};
630
631static const char* yysymbol_name(yysymbol_kind_t yysymbol) {
632 return yytname[yysymbol];
633}
634#endif
635
636#define YYPACT_NINF (-192)
637
638#define yypact_value_is_default(Yyn) ((Yyn) == YYPACT_NINF)
639
640#define YYTABLE_NINF (-19)
641
642#define yytable_value_is_error(Yyn) 0
643
644/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
645 STATE-NUM. */
646static const yytype_int16 yypact[] = {
647 -192, 29, 7, -192, -15, 24, 41, 20, -192, 66, -192, 69,
648 -192, -192, -192, 115, 87, 90, 116, 113, 152, -192, -192, -192,
649 153, 54, 49, 178, 12, 166, 179, 177, -192, 172, 9, -192,
650 -192, 180, 181, -192, 182, 183, 175, 87, 184, 185, 186, 187,
651 -192, -192, 190, 113, 189, -192, -192, 193, 113, -192, -192, 191,
652 156, -192, -192, 58, 192, -192, 49, 195, 198, 199, 47, -192,
653 194, -192, 14, 83, 83, 83, -192, 100, 188, 203, 196, -192,
654 200, -192, -192, 197, -192, -192, 22, -192, 91, 205, -192, 201,
655 -192, 122, 113, 124, -192, -192, -192, 207, -192, 154, 96, 113,
656 -192, 219, 209, 220, -192, 221, 141, -192, 213, 206, -192, 27,
657 -192, 214, 216, 222, 208, -192, -192, 113, 155, -192, 120, -192,
658 83, 218, 100, 223, -192, 157, -192, 144, -192, -192, 67, 77,
659 -192, 224, 225, -192, 145, -192, 211, 226, 227, 147, 141, -192,
660 -192, 229, -192, -192, 142, 212, 100, -192, -192, 87, 228, 87,
661 230, 231, 232, -192, 233, -192, -192, -192, 234, -192, -192, -192,
662 -192, -192, 237, 217, 238, 235, 239, 240, -192, -192, 245, -192,
663 246, -192, -192, -192, -192, -192, 32, 37, 70, 105, 241, 242,
664 243, 244, -192, 135, 91, 108, 126, -192, 159, -192, 161, 247,
665 -192, -192, 163, -192, -192, 165, -192, 91, -192, 249, 174, -192,
666 -192, -192, 248, -192, -192};
667
668/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
669 Performed when YYTABLE does not specify something else to do. Zero
670 means the default is an error. */
671static const yytype_int8 yydefact[] = {
672 5, 0, 0, 1, 0, 0, 0, 73, 4, 0, 3, 0, 40, 48, 41, 0, 0, 0,
673 0, 0, 0, 50, 51, 52, 0, 0, 0, 0, 0, 0, 0, 0, 55, 56, 0, 54,
674 17, 0, 0, 87, 0, 0, 0, 0, 0, 8, 0, 0, 44, 45, 0, 0, 0, 42,
675 49, 0, 0, 43, 87, 0, 0, 72, 2, 0, 0, 6, 0, 0, 0, 0, 0, 87,
676 0, 53, 0, 0, 0, 0, 99, 0, 16, 0, 0, 13, 0, 7, 9, 0, 46, 47,
677 28, 57, 0, 77, 79, 82, 78, 0, 0, 0, 76, 101, 100, 92, 93, 94, 0, 0,
678 86, 0, 0, 0, 10, 0, 0, 25, 63, 68, 67, 0, 19, 0, 0, 34, 38, 35,
679 85, 0, 0, 33, 0, 87, 0, 0, 0, 0, 98, 0, 89, 0, 15, 14, 0, 0,
680 27, 0, 0, 66, 0, 80, 0, 0, 0, 0, 0, 84, 81, 74, 75, 90, 0, 0,
681 0, 97, 91, 0, 0, 0, 0, 0, 0, 64, 0, 65, 83, 36, 0, 37, 32, 95,
682 96, 88, 0, 0, 0, 0, 0, 0, 69, 39, 0, 11, 0, 87, 87, 87, 12, 87,
683 0, 0, 0, 31, 0, 0, 0, 0, 26, 0, 0, 0, 0, 21, 0, 71, 0, 61,
684 60, 23, 0, 59, 30, 0, 20, 0, 24, 0, 0, 22, 29, 70, 0, 58, 62};
685
686/* YYPGOTO[NTERM-NUM]. */
687static const yytype_int16 yypgoto[] = {
688 -192, -192, -192, -192, 215, -192, -192, 98, -192, -192, -192,
689 -192, 38, -108, 104, 106, 107, -7, -50, 236, -192, 25,
690 -191, -192, -192, -192, -192, -72, -56, 118, -76, -192};
691
692/* YYDEFGOTO[NTERM-NUM]. */
693static const yytype_uint8 yydefgoto[] = {
694 0, 1, 2, 6, 44, 45, 82, 83, 7, 20, 115, 206, 128, 129, 21, 22,
695 23, 46, 34, 35, 218, 219, 120, 214, 25, 40, 99, 100, 60, 137, 138, 41};
696
697/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
698 positive, shift that token. If negative, reduce the rule whose
699 number is the opposite. If YYTABLE_NINF, syntax error. */
700static const yytype_int16 yytable[] = {
701 24, 70, 74, 108, 101, 102, 144, 8, 4, 29, -18, -18, -18, -18, -18,
702 90, 48, 213, 5, 49, -18, -18, -18, 11, 12, -18, 13, 14, -18, 3,
703 50, 79, 229, 15, 56, 16, 64, -18, 17, 79, 57, 18, 51, 92, 9,
704 32, 178, 33, 130, 79, 19, 114, 42, 12, 79, 13, 14, 139, 147, 38,
705 158, 202, 15, 10, 43, 80, 203, 17, 39, 148, 18, 12, 56, 13, 14,
706 157, 81, 153, 89, 19, 15, 12, 165, 13, 14, 17, 181, 79, 18, 26,
707 15, 12, 167, 13, 14, 17, 27, 19, 18, 204, 15, 93, 94, 95, 96,
708 17, 30, 19, 18, 116, 97, 117, 118, 98, 103, 104, 105, 19, 103, 104,
709 105, 119, 79, 106, 136, 28, 107, 106, 215, 216, 107, 32, 31, 33, 205,
710 166, 217, 198, 199, 200, 123, 201, 124, 125, 123, 56, 124, 125, 131, 132,
711 126, 156, 127, 32, 220, 33, 127, 212, 182, 123, 184, 124, 125, 211, 76,
712 77, 179, 162, 78, 56, 56, 127, 56, 79, 36, 164, 173, 134, 177, 37,
713 154, 135, 162, 155, 56, 163, 223, 222, 226, 224, 154, 227, 52, 228, 215,
714 216, 47, 53, 54, 55, 58, 59, 63, 68, 61, 62, 69, 140, 65, 71,
715 66, 72, 67, 109, 75, 86, 87, 88, 84, 110, 112, 121, 91, 133, 111,
716 113, 80, 141, 122, 145, 142, 143, 149, 146, 150, 152, 159, 191, 151, 174,
717 180, 161, 171, 172, 175, 176, 79, 168, 221, 169, 170, 231, 160, 0, 183,
718 193, 185, 186, 187, 194, 195, 188, 189, 190, 192, 196, 197, 230, 207, 208,
719 209, 210, 0, 0, 225, 0, 232, 0, 0, 0, 0, 85, 0, 0, 0,
720 0, 0, 0, 0, 0, 0, 0, 73};
721
722static const yytype_int16 yycheck[] = {
723 7, 51, 58, 79, 76, 77, 114, 22, 1, 16, 3, 4, 5, 6, 7, 71,
724 4, 208, 11, 7, 13, 14, 15, 3, 4, 18, 6, 7, 21, 0, 18, 17,
725 223, 13, 25, 15, 43, 30, 18, 17, 31, 21, 30, 29, 20, 18, 154, 20,
726 98, 17, 30, 29, 3, 4, 17, 6, 7, 107, 31, 5, 132, 29, 13, 22,
727 15, 7, 29, 18, 14, 119, 21, 4, 25, 6, 7, 131, 18, 127, 31, 30,
728 13, 4, 15, 6, 7, 18, 162, 17, 21, 23, 13, 4, 15, 6, 7, 18,
729 27, 30, 21, 29, 13, 18, 19, 20, 21, 18, 16, 30, 21, 18, 27, 20,
730 21, 30, 18, 19, 20, 30, 18, 19, 20, 30, 17, 27, 28, 10, 30, 27,
731 20, 21, 30, 18, 16, 20, 29, 142, 28, 193, 194, 195, 18, 197, 20, 21,
732 18, 25, 20, 21, 24, 25, 28, 31, 30, 18, 28, 20, 30, 207, 165, 18,
733 167, 20, 21, 28, 8, 9, 24, 25, 12, 25, 25, 30, 25, 17, 22, 31,
734 31, 23, 31, 26, 25, 27, 25, 28, 25, 28, 25, 28, 25, 28, 25, 28,
735 26, 28, 20, 21, 18, 18, 21, 27, 20, 20, 27, 16, 22, 22, 16, 109,
736 24, 20, 25, 18, 26, 25, 23, 20, 18, 18, 26, 16, 20, 16, 28, 16,
737 28, 28, 7, 18, 27, 16, 10, 10, 18, 27, 18, 27, 18, 20, 16, 28,
738 28, 18, 18, 18, 18, 18, 17, 143, 210, 143, 143, 226, 134, -1, 26, 20,
739 26, 26, 26, 20, 20, 28, 28, 26, 26, 20, 20, 18, 27, 27, 27, 27,
740 -1, -1, 27, -1, 28, -1, -1, -1, -1, 66, -1, -1, -1, -1, -1, -1,
741 -1, -1, -1, -1, 56};
742
743/* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
744 state STATE-NUM. */
745static const yytype_int8 yystos[] = {
746 0, 33, 34, 0, 1, 11, 35, 40, 22, 20, 22, 3, 4, 6, 7, 13, 15, 18,
747 21, 30, 41, 46, 47, 48, 49, 56, 23, 27, 10, 49, 16, 16, 18, 20, 50, 51,
748 22, 26, 5, 14, 57, 63, 3, 15, 36, 37, 49, 18, 4, 7, 18, 30, 26, 18,
749 21, 27, 25, 31, 20, 20, 60, 22, 22, 27, 49, 24, 25, 26, 16, 16, 50, 20,
750 18, 51, 60, 23, 8, 9, 12, 17, 7, 18, 38, 39, 26, 36, 20, 18, 18, 31,
751 60, 28, 29, 18, 19, 20, 21, 27, 30, 58, 59, 59, 59, 18, 19, 20, 27, 30,
752 62, 25, 16, 28, 20, 28, 29, 42, 18, 20, 21, 30, 54, 16, 27, 18, 20, 21,
753 28, 30, 44, 45, 50, 24, 25, 16, 23, 27, 28, 61, 62, 50, 39, 18, 10, 10,
754 45, 16, 27, 31, 50, 18, 18, 16, 27, 50, 25, 28, 31, 60, 59, 18, 61, 18,
755 25, 28, 31, 15, 49, 15, 46, 47, 48, 18, 18, 31, 28, 18, 18, 31, 45, 24,
756 28, 62, 49, 26, 49, 26, 26, 26, 28, 28, 26, 20, 26, 20, 20, 20, 20, 20,
757 60, 60, 60, 60, 29, 29, 29, 29, 43, 27, 27, 27, 27, 28, 50, 54, 55, 20,
758 21, 28, 52, 53, 28, 44, 28, 25, 28, 27, 25, 28, 28, 54, 18, 53, 28};
759
760/* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */
761static const yytype_int8 yyr1[] = {
762 0, 32, 33, 34, 34, 34, 35, 36, 36, 37, 37, 37, 37, 38, 38, 39, 39,
763 40, 40, 41, 41, 41, 41, 41, 41, 41, 41, 42, 42, 43, 43, 43, 44, 44,
764 45, 45, 45, 45, 45, 45, 46, 46, 46, 46, 47, 47, 47, 47, 48, 48, 49,
765 49, 49, 50, 50, 51, 51, 51, 52, 52, 53, 53, 53, 54, 54, 54, 54, 54,
766 54, 54, 55, 55, 56, 56, 57, 58, 58, 59, 59, 59, 59, 59, 59, 59, 59,
767 59, 60, 60, 61, 61, 62, 62, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63};
768
769/* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM.
770 */
771static const yytype_int8 yyr2[] = {
772 0, 2, 5, 3, 3, 0, 5, 3, 1, 3, 4, 8, 9, 1, 3, 3, 1, 3, 0, 6, 15,
773 14, 15, 14, 15, 6, 13, 2, 0, 4, 3, 0, 3, 1, 1, 1, 3, 3, 1, 4, 1, 1,
774 3, 3, 3, 3, 5, 5, 1, 3, 1, 1, 1, 3, 1, 1, 1, 4, 3, 1, 1, 1, 4,
775 1, 3, 3, 2, 1, 1, 4, 3, 1, 3, 0, 6, 3, 1, 1, 1, 1, 3, 3, 1, 4,
776 3, 2, 3, 0, 3, 1, 3, 3, 1, 1, 1, 4, 4, 3, 2, 3, 4, 4};
777
778enum { YYENOMEM = -2 };
779
780#define yyerrok (yyerrstatus = 0)
781#define yyclearin (yychar = ORFZ_EMPTY)
782
783#define YYACCEPT goto yyacceptlab
784#define YYABORT goto yyabortlab
785#define YYERROR goto yyerrorlab
786#define YYNOMEM goto yyexhaustedlab
787
788#define YYRECOVERING() (!!yyerrstatus)
789
790#define YYBACKUP(Token, Value) \
791 do \
792 if (yychar == ORFZ_EMPTY) { \
793 yychar = (Token); \
794 yylval = (Value); \
795 YYPOPSTACK(yylen); \
796 yystate = *yyssp; \
797 goto yybackup; \
798 } else { \
799 yyerror(context, model, ok, scanner, \
800 YY_("syntax error: cannot back up")); \
801 YYERROR; \
802 } \
803 while (0)
804
805/* Backward compatibility with an undocumented macro.
806 Use ORFZ_error or ORFZ_UNDEF. */
807#define YYERRCODE ORFZ_UNDEF
808
809/* Enable debugging if requested. */
810#if ORFZ_DEBUG
811
812#ifndef YYFPRINTF
813#include <stdio.h> /* INFRINGES ON USER NAME SPACE */
814#define YYFPRINTF fprintf
815#endif
816
817#define YYDPRINTF(Args) \
818 do { \
819 if (yydebug) YYFPRINTF Args; \
820 } while (0)
821
822#define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
823 do { \
824 if (yydebug) { \
825 YYFPRINTF(stderr, "%s ", Title); \
826 yy_symbol_print(stderr, Kind, Value, context, model, ok, scanner); \
827 YYFPRINTF(stderr, "\n"); \
828 } \
829 } while (0)
830
831/*-----------------------------------.
832| Print this symbol's value on YYO. |
833`-----------------------------------*/
834
835static void yy_symbol_value_print(
836 FILE* yyo, yysymbol_kind_t yykind, YYSTYPE const* const yyvaluep,
838 operations_research::fz::Model* model, bool* ok, void* scanner) {
839 FILE* yyoutput = yyo;
840 YY_USE(yyoutput);
841 YY_USE(context);
842 YY_USE(model);
843 YY_USE(ok);
844 YY_USE(scanner);
845 if (!yyvaluep) return;
847 YY_USE(yykind);
849}
850
851/*---------------------------.
852| Print this symbol on YYO. |
853`---------------------------*/
854
855static void yy_symbol_print(FILE* yyo, yysymbol_kind_t yykind,
856 YYSTYPE const* const yyvaluep,
858 operations_research::fz::Model* model, bool* ok,
859 void* scanner) {
860 YYFPRINTF(yyo, "%s %s (", yykind < YYNTOKENS ? "token" : "nterm",
861 yysymbol_name(yykind));
862
863 yy_symbol_value_print(yyo, yykind, yyvaluep, context, model, ok, scanner);
864 YYFPRINTF(yyo, ")");
865}
866
867/*------------------------------------------------------------------.
868| yy_stack_print -- Print the state stack from its BOTTOM up to its |
869| TOP (included). |
870`------------------------------------------------------------------*/
871
872static void yy_stack_print(yy_state_t* yybottom, yy_state_t* yytop) {
873 YYFPRINTF(stderr, "Stack now");
874 for (; yybottom <= yytop; yybottom++) {
875 int yybot = *yybottom;
876 YYFPRINTF(stderr, " %d", yybot);
877 }
878 YYFPRINTF(stderr, "\n");
879}
880
881#define YY_STACK_PRINT(Bottom, Top) \
882 do { \
883 if (yydebug) yy_stack_print((Bottom), (Top)); \
884 } while (0)
885
886/*------------------------------------------------.
887| Report that the YYRULE is going to be reduced. |
888`------------------------------------------------*/
889
890static void yy_reduce_print(yy_state_t* yyssp, YYSTYPE* yyvsp, int yyrule,
892 operations_research::fz::Model* model, bool* ok,
893 void* scanner) {
894 int yylno = yyrline[yyrule];
895 int yynrhs = yyr2[yyrule];
896 int yyi;
897 YYFPRINTF(stderr, "Reducing stack by rule %d (line %d):\n", yyrule - 1,
898 yylno);
899 /* The symbols being reduced. */
900 for (yyi = 0; yyi < yynrhs; yyi++) {
901 YYFPRINTF(stderr, " $%d = ", yyi + 1);
902 yy_symbol_print(stderr, YY_ACCESSING_SYMBOL(+yyssp[yyi + 1 - yynrhs]),
903 &yyvsp[(yyi + 1) - (yynrhs)], context, model, ok, scanner);
904 YYFPRINTF(stderr, "\n");
905 }
906}
907
908#define YY_REDUCE_PRINT(Rule) \
909 do { \
910 if (yydebug) \
911 yy_reduce_print(yyssp, yyvsp, Rule, context, model, ok, scanner); \
912 } while (0)
913
914/* Nonzero means print parse trace. It is left uninitialized so that
915 multiple parsers can coexist. */
916int yydebug;
917#else /* !ORFZ_DEBUG */
918#define YYDPRINTF(Args) ((void)0)
919#define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
920#define YY_STACK_PRINT(Bottom, Top)
921#define YY_REDUCE_PRINT(Rule)
922#endif /* !ORFZ_DEBUG */
923
924/* YYINITDEPTH -- initial size of the parser's stacks. */
925#ifndef YYINITDEPTH
926#define YYINITDEPTH 200
927#endif
928
929/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
930 if the built-in stack extension method is used).
931
932 Do not make this value too large; the results are undefined if
933 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
934 evaluated with infinite-precision integer arithmetic. */
935
936#ifndef YYMAXDEPTH
937#define YYMAXDEPTH 10000
938#endif
939
940/* Context of a parse error. */
945
946/* Put in YYARG at most YYARGN of the expected tokens given the
947 current YYCTX, and return the number of tokens stored in YYARG. If
948 YYARG is null, return the number of expected tokens (guaranteed to
949 be less than YYNTOKENS). Return YYENOMEM on memory exhaustion.
950 Return 0 if there are more than YYARGN expected tokens, yet fill
951 YYARG up to YYARGN. */
953 yysymbol_kind_t yyarg[], int yyargn) {
954 /* Actual size of YYARG. */
955 int yycount = 0;
956 int yyn = yypact[+*yyctx->yyssp];
957 if (!yypact_value_is_default(yyn)) {
958 /* Start YYX at -YYN if negative to avoid negative indexes in
959 YYCHECK. In other words, skip the first -YYN actions for
960 this state because they are default actions. */
961 int yyxbegin = yyn < 0 ? -yyn : 0;
962 /* Stay within bounds of both yycheck and yytname. */
963 int yychecklim = YYLAST - yyn + 1;
964 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
965 int yyx;
966 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
967 if (yycheck[yyx + yyn] == yyx && yyx != YYSYMBOL_YYerror &&
968 !yytable_value_is_error(yytable[yyx + yyn])) {
969 if (!yyarg)
970 ++yycount;
971 else if (yycount == yyargn)
972 return 0;
973 else
974 yyarg[yycount++] = YY_CAST(yysymbol_kind_t, yyx);
975 }
976 }
977 if (yyarg && yycount == 0 && 0 < yyargn) yyarg[0] = YYSYMBOL_YYEMPTY;
978 return yycount;
979}
980
981#ifndef yystrlen
982#if defined __GLIBC__ && defined _STRING_H
983#define yystrlen(S) (YY_CAST(YYPTRDIFF_T, strlen(S)))
984#else
985/* Return the length of YYSTR. */
986static YYPTRDIFF_T yystrlen(const char* yystr) {
987 YYPTRDIFF_T yylen;
988 for (yylen = 0; yystr[yylen]; yylen++) continue;
989 return yylen;
990}
991#endif
992#endif
993
994#ifndef yystpcpy
995#if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
996#define yystpcpy stpcpy
997#else
998/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
999 YYDEST. */
1000static char* yystpcpy(char* yydest, const char* yysrc) {
1001 char* yyd = yydest;
1002 const char* yys = yysrc;
1003
1004 while ((*yyd++ = *yys++) != '\0') continue;
1005
1006 return yyd - 1;
1007}
1008#endif
1009#endif
1010
1011#ifndef yytnamerr
1012/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1013 quotes and backslashes, so that it's suitable for yyerror. The
1014 heuristic is that double-quoting is unnecessary unless the string
1015 contains an apostrophe, a comma, or backslash (other than
1016 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1017 null, do not copy; instead, return the length of what the result
1018 would have been. */
1019static YYPTRDIFF_T yytnamerr(char* yyres, const char* yystr) {
1020 if (*yystr == '"') {
1021 YYPTRDIFF_T yyn = 0;
1022 char const* yyp = yystr;
1023 for (;;) switch (*++yyp) {
1024 case '\'':
1025 case ',':
1026 goto do_not_strip_quotes;
1027
1028 case '\\':
1029 if (*++yyp != '\\')
1030 goto do_not_strip_quotes;
1031 else
1032 goto append;
1033
1034 append:
1035 default:
1036 if (yyres) yyres[yyn] = *yyp;
1037 yyn++;
1038 break;
1039
1040 case '"':
1041 if (yyres) yyres[yyn] = '\0';
1042 return yyn;
1043 }
1044 do_not_strip_quotes:;
1045 }
1046
1047 if (yyres)
1048 return yystpcpy(yyres, yystr) - yyres;
1049 else
1050 return yystrlen(yystr);
1051}
1052#endif
1053
1055 yysymbol_kind_t yyarg[], int yyargn) {
1056 /* Actual size of YYARG. */
1057 int yycount = 0;
1058 /* There are many possibilities here to consider:
1059 - If this state is a consistent state with a default action, then
1060 the only way this function was invoked is if the default action
1061 is an error action. In that case, don't check for expected
1062 tokens because there are none.
1063 - The only way there can be no lookahead present (in yychar) is if
1064 this state is a consistent state with a default action. Thus,
1065 detecting the absence of a lookahead is sufficient to determine
1066 that there is no unexpected or expected token to report. In that
1067 case, just report a simple "syntax error".
1068 - Don't assume there isn't a lookahead just because this state is a
1069 consistent state with a default action. There might have been a
1070 previous inconsistent state, consistent state with a non-default
1071 action, or user semantic action that manipulated yychar.
1072 - Of course, the expected token list depends on states to have
1073 correct lookahead information, and it depends on the parser not
1074 to perform extra reductions after fetching a lookahead from the
1075 scanner and before detecting a syntax error. Thus, state merging
1076 (from LALR or IELR) and default reductions corrupt the expected
1077 token list. However, the list is correct for canonical LR with
1078 one exception: it will still contain any token that will not be
1079 accepted due to an error action in a later state.
1080 */
1081 if (yyctx->yytoken != YYSYMBOL_YYEMPTY) {
1082 int yyn;
1083 if (yyarg) yyarg[yycount] = yyctx->yytoken;
1084 ++yycount;
1085 yyn = yypcontext_expected_tokens(yyctx, yyarg ? yyarg + 1 : yyarg,
1086 yyargn - 1);
1087 if (yyn == YYENOMEM)
1088 return YYENOMEM;
1089 else
1090 yycount += yyn;
1091 }
1092 return yycount;
1093}
1094
1095/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1096 about the unexpected token YYTOKEN for the state stack whose top is
1097 YYSSP.
1098
1099 Return 0 if *YYMSG was successfully written. Return -1 if *YYMSG is
1100 not large enough to hold the message. In that case, also set
1101 *YYMSG_ALLOC to the required number of bytes. Return YYENOMEM if the
1102 required number of bytes is too large to store. */
1103static int yysyntax_error(YYPTRDIFF_T* yymsg_alloc, char** yymsg,
1104 const yypcontext_t* yyctx) {
1105 enum { YYARGS_MAX = 5 };
1106 /* Internationalized format string. */
1107 const char* yyformat = YY_NULLPTR;
1108 /* Arguments of yyformat: reported tokens (one for the "unexpected",
1109 one per "expected"). */
1110 yysymbol_kind_t yyarg[YYARGS_MAX];
1111 /* Cumulated lengths of YYARG. */
1112 YYPTRDIFF_T yysize = 0;
1113
1114 /* Actual size of YYARG. */
1115 int yycount = yy_syntax_error_arguments(yyctx, yyarg, YYARGS_MAX);
1116 if (yycount == YYENOMEM) return YYENOMEM;
1117
1118 switch (yycount) {
1119#define YYCASE_(N, S) \
1120 case N: \
1121 yyformat = S; \
1122 break
1123 default: /* Avoid compiler warnings. */
1124 YYCASE_(0, YY_("syntax error"));
1125 YYCASE_(1, YY_("syntax error, unexpected %s"));
1126 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1127 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1128 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1129 YYCASE_(
1130 5,
1131 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1132#undef YYCASE_
1133 }
1134
1135 /* Compute error message size. Don't count the "%s"s, but reserve
1136 room for the terminator. */
1137 yysize = yystrlen(yyformat) - 2 * yycount + 1;
1138 {
1139 int yyi;
1140 for (yyi = 0; yyi < yycount; ++yyi) {
1141 YYPTRDIFF_T yysize1 = yysize + yytnamerr(YY_NULLPTR, yytname[yyarg[yyi]]);
1142 if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1143 yysize = yysize1;
1144 else
1145 return YYENOMEM;
1146 }
1147 }
1148
1149 if (*yymsg_alloc < yysize) {
1150 *yymsg_alloc = 2 * yysize;
1151 if (!(yysize <= *yymsg_alloc && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1152 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1153 return -1;
1154 }
1155
1156 /* Avoid sprintf, as that infringes on the user's name space.
1157 Don't have undefined behavior even if the translation
1158 produced a string with the wrong number of "%s"s. */
1159 {
1160 char* yyp = *yymsg;
1161 int yyi = 0;
1162 while ((*yyp = *yyformat) != '\0')
1163 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) {
1164 yyp += yytnamerr(yyp, yytname[yyarg[yyi++]]);
1165 yyformat += 2;
1166 } else {
1167 ++yyp;
1168 ++yyformat;
1169 }
1170 }
1171 return 0;
1172}
1173
1174/*-----------------------------------------------.
1175| Release the memory associated to this symbol. |
1176`-----------------------------------------------*/
1177
1178static void yydestruct(const char* yymsg, yysymbol_kind_t yykind,
1179 YYSTYPE* yyvaluep,
1181 operations_research::fz::Model* model, bool* ok,
1182 void* scanner) {
1183 YY_USE(yyvaluep);
1184 YY_USE(context);
1185 YY_USE(model);
1186 YY_USE(ok);
1187 YY_USE(scanner);
1188 if (!yymsg) yymsg = "Deleting";
1189 YY_SYMBOL_PRINT(yymsg, yykind, yyvaluep, yylocationp);
1190
1192 YY_USE(yykind);
1194}
1195
1196/*----------.
1197| yyparse. |
1198`----------*/
1199
1201 operations_research::fz::Model* model, bool* ok, void* scanner) {
1202 /* Lookahead token kind. */
1203 int yychar;
1204
1205 /* The semantic value of the lookahead symbol. */
1206 /* Default value used for initialization, for pacifying older GCCs
1207 or non-GCC compilers. */
1208 YY_INITIAL_VALUE(static YYSTYPE yyval_default;)
1209 YYSTYPE yylval YY_INITIAL_VALUE(= yyval_default);
1210
1211 /* Number of syntax errors so far. */
1212 int yynerrs = 0;
1213
1214 yy_state_fast_t yystate = 0;
1215 /* Number of tokens to shift before error messages enabled. */
1216 int yyerrstatus = 0;
1217
1218 /* Refer to the stacks through separate pointers, to allow yyoverflow
1219 to reallocate them elsewhere. */
1220
1221 /* Their size. */
1222 YYPTRDIFF_T yystacksize = YYINITDEPTH;
1223
1224 /* The state stack: array, bottom, top. */
1225 yy_state_t yyssa[YYINITDEPTH];
1226 yy_state_t* yyss = yyssa;
1227 yy_state_t* yyssp = yyss;
1228
1229 /* The semantic value stack: array, bottom, top. */
1230 YYSTYPE yyvsa[YYINITDEPTH];
1231 YYSTYPE* yyvs = yyvsa;
1232 YYSTYPE* yyvsp = yyvs;
1233
1234 int yyn;
1235 /* The return value of yyparse. */
1236 int yyresult;
1237 /* Lookahead symbol kind. */
1239 /* The variables used to return semantic value and location from the
1240 action routines. */
1241 YYSTYPE yyval;
1242
1243 /* Buffer for error messages, and its allocated size. */
1244 char yymsgbuf[128];
1245 char* yymsg = yymsgbuf;
1246 YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf;
1247
1248#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1249
1250 /* The number of symbols on the RHS of the reduced rule.
1251 Keep to zero when no symbol should be popped. */
1252 int yylen = 0;
1253
1254 YYDPRINTF((stderr, "Starting parse\n"));
1255
1256 yychar = ORFZ_EMPTY; /* Cause a token to be read. */
1257
1258 goto yysetstate;
1259
1260/*------------------------------------------------------------.
1261| yynewstate -- push a new state, which is found in yystate. |
1262`------------------------------------------------------------*/
1263yynewstate:
1264 /* In all cases, when you get here, the value and location stacks
1265 have just been pushed. So pushing a state here evens the stacks. */
1266 yyssp++;
1267
1268/*--------------------------------------------------------------------.
1269| yysetstate -- set current state (the top of the stack) to yystate. |
1270`--------------------------------------------------------------------*/
1271yysetstate:
1272 YYDPRINTF((stderr, "Entering state %d\n", yystate));
1273 YY_ASSERT(0 <= yystate && yystate < YYNSTATES);
1275 *yyssp = YY_CAST(yy_state_t, yystate);
1277 YY_STACK_PRINT(yyss, yyssp);
1278
1279 if (yyss + yystacksize - 1 <= yyssp)
1280#if !defined yyoverflow && !defined YYSTACK_RELOCATE
1281 YYNOMEM;
1282#else
1283 {
1284 /* Get the current used size of the three stacks, in elements. */
1285 YYPTRDIFF_T yysize = yyssp - yyss + 1;
1286
1287#if defined yyoverflow
1288 {
1289 /* Give user a chance to reallocate the stack. Use copies of
1290 these so that the &'s don't force the real ones into
1291 memory. */
1292 yy_state_t* yyss1 = yyss;
1293 YYSTYPE* yyvs1 = yyvs;
1294
1295 /* Each stack pointer address is followed by the size of the
1296 data in use in that stack, in bytes. This used to be a
1297 conditional around just the two extra args, but that might
1298 be undefined if yyoverflow is a macro. */
1299 yyoverflow(YY_("memory exhausted"), &yyss1, yysize * YYSIZEOF(*yyssp),
1300 &yyvs1, yysize * YYSIZEOF(*yyvsp), &yystacksize);
1301 yyss = yyss1;
1302 yyvs = yyvs1;
1303 }
1304#else /* defined YYSTACK_RELOCATE */
1305 /* Extend the stack our own way. */
1306 if (YYMAXDEPTH <= yystacksize) YYNOMEM;
1307 yystacksize *= 2;
1308 if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH;
1309
1310 {
1311 yy_state_t* yyss1 = yyss;
1312 union yyalloc* yyptr =
1313 YY_CAST(union yyalloc*,
1315 if (!yyptr) YYNOMEM;
1316 YYSTACK_RELOCATE(yyss_alloc, yyss);
1317 YYSTACK_RELOCATE(yyvs_alloc, yyvs);
1318#undef YYSTACK_RELOCATE
1319 if (yyss1 != yyssa) YYSTACK_FREE(yyss1);
1320 }
1321#endif
1322
1323 yyssp = yyss + yysize - 1;
1324 yyvsp = yyvs + yysize - 1;
1325
1327 YYDPRINTF(
1328 (stderr, "Stack size increased to %ld\n", YY_CAST(long, yystacksize)));
1330
1331 if (yyss + yystacksize - 1 <= yyssp) YYABORT;
1332 }
1333#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1334
1335 if (yystate == YYFINAL) YYACCEPT;
1336
1337 goto yybackup;
1338
1339/*-----------.
1340| yybackup. |
1341`-----------*/
1342yybackup:
1343 /* Do appropriate processing given the current state. Read a
1344 lookahead token if we need one and don't already have one. */
1345
1346 /* First try to decide what to do without reference to lookahead token. */
1347 yyn = yypact[yystate];
1348 if (yypact_value_is_default(yyn)) goto yydefault;
1349
1350 /* Not known => get a lookahead token if don't already have one. */
1351
1352 /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1353 if (yychar == ORFZ_EMPTY) {
1354 YYDPRINTF((stderr, "Reading a token\n"));
1355 yychar = yylex(&yylval, scanner);
1356 }
1357
1358 if (yychar <= ORFZ_EOF) {
1359 yychar = ORFZ_EOF;
1360 yytoken = YYSYMBOL_YYEOF;
1361 YYDPRINTF((stderr, "Now at end of input.\n"));
1362 } else if (yychar == ORFZ_error) {
1363 /* The scanner already issued an error message, process directly
1364 to error recovery. But do not keep the error token as
1365 lookahead, it is too special and may lead us to an endless
1366 loop in error recovery. */
1367 yychar = ORFZ_UNDEF;
1368 yytoken = YYSYMBOL_YYerror;
1369 goto yyerrlab1;
1370 } else {
1371 yytoken = YYTRANSLATE(yychar);
1372 YY_SYMBOL_PRINT("Next token is", yytoken, &yylval, &yylloc);
1373 }
1374
1375 /* If the proper action on seeing token YYTOKEN is to reduce or to
1376 detect an error, take that action. */
1377 yyn += yytoken;
1378 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault;
1379 yyn = yytable[yyn];
1380 if (yyn <= 0) {
1381 if (yytable_value_is_error(yyn)) goto yyerrlab;
1382 yyn = -yyn;
1383 goto yyreduce;
1384 }
1385
1386 /* Count tokens shifted since error; after three, turn off error
1387 status. */
1388 if (yyerrstatus) yyerrstatus--;
1389
1390 /* Shift the lookahead token. */
1391 YY_SYMBOL_PRINT("Shifting", yytoken, &yylval, &yylloc);
1392 yystate = yyn;
1394 *++yyvsp = yylval;
1396
1397 /* Discard the shifted token. */
1398 yychar = ORFZ_EMPTY;
1399 goto yynewstate;
1400
1401/*-----------------------------------------------------------.
1402| yydefault -- do the default action for the current state. |
1403`-----------------------------------------------------------*/
1404yydefault:
1405 yyn = yydefact[yystate];
1406 if (yyn == 0) goto yyerrlab;
1407 goto yyreduce;
1408
1409/*-----------------------------.
1410| yyreduce -- do a reduction. |
1411`-----------------------------*/
1412yyreduce:
1413 /* yyn is the number of a rule to reduce with. */
1414 yylen = yyr2[yyn];
1415
1416 /* If YYLEN is nonzero, implement the default value of the action:
1417 '$$ = $1'.
1418
1419 Otherwise, the following line sets YYVAL to garbage.
1420 This behavior is undocumented and Bison
1421 users should not rely upon it. Assigning to YYVAL
1422 unconditionally makes the parser a bit smaller, and it avoids a
1423 GCC warning that YYVAL may be used uninitialized. */
1424 yyval = yyvsp[1 - yylen];
1425
1426 YY_REDUCE_PRINT(yyn);
1427 switch (yyn) {
1428 case 4: /* predicates: predicates error ';' */
1429#line 129 "ortools/flatzinc/parser.yy"
1430 {
1431 yyerrok;
1432 }
1433#line 1595 "parser.tab.cc"
1434 break;
1435
1436 case 19: /* variable_or_constant_declaration: domain ':' IDENTIFIER
1437 annotations '=' const_literal */
1438#line 164 "ortools/flatzinc/parser.yy"
1439 {
1440 // Declaration of a (named) constant: we simply register it in the
1441 // parser's context, and don't store it in the model.
1442 const Domain& domain = (yyvsp[-5].domain);
1443 const std::string& identifier = (yyvsp[-3].string_value);
1444 const Domain& assignment = (yyvsp[0].domain);
1445 std::vector<Annotation>* const annotations = (yyvsp[-2].annotations);
1446
1447 if (!assignment.HasOneValue()) {
1448 // TODO(user): Check that the assignment is included in the domain.
1449 context->domain_map[identifier] = assignment;
1450 } else {
1451 const int64_t value = assignment.values.front();
1452 CHECK(domain.Contains(value));
1453 context->integer_map[identifier] = value;
1454 }
1455 delete annotations;
1456 }
1457#line 1619 "parser.tab.cc"
1458 break;
1459
1460 case 20: /* variable_or_constant_declaration: ARRAY '[' IVALUE DOTDOT IVALUE
1461 ']' OF int_domain ':' IDENTIFIER annotations '=' '[' integers
1462 ']' */
1463#line 184 "ortools/flatzinc/parser.yy"
1464 {
1465 std::vector<Annotation>* const annotations = (yyvsp[-4].annotations);
1466 // Declaration of a (named) constant array. See rule right above.
1467 CHECK_EQ((yyvsp[-12].integer_value), 1)
1468 << "Only [1..n] array are supported here.";
1469 const int64_t num_constants = (yyvsp[-10].integer_value);
1470 const std::string& identifier = (yyvsp[-5].string_value);
1471 const std::vector<int64_t>* const assignments = (yyvsp[-1].integers);
1472 CHECK(assignments != nullptr);
1473 CHECK_EQ(num_constants, assignments->size());
1474 // TODO(user): CHECK all values within domain.
1475 context->integer_array_map[identifier] = *assignments;
1476 delete assignments;
1477 delete annotations;
1478 }
1479#line 1638 "parser.tab.cc"
1480 break;
1481
1482 case 21: /* variable_or_constant_declaration: ARRAY '[' IVALUE DOTDOT IVALUE
1483 ']' OF int_domain ':' IDENTIFIER annotations '=' '[' ']' */
1484#line 199 "ortools/flatzinc/parser.yy"
1485 {
1486 std::vector<Annotation>* const annotations = (yyvsp[-3].annotations);
1487 // Declaration of a (named) constant array. See rule right above.
1488 CHECK_EQ((yyvsp[-11].integer_value), 1)
1489 << "Only [1..n] array are supported here.";
1490 const int64_t num_constants = (yyvsp[-9].integer_value);
1491 CHECK_EQ(num_constants, 0) << "Empty arrays should have a size of 0";
1492 const std::string& identifier = (yyvsp[-4].string_value);
1493 context->integer_array_map[identifier] = std::vector<int64_t>();
1494 delete annotations;
1495 }
1496#line 1653 "parser.tab.cc"
1497 break;
1498
1499 case 22: /* variable_or_constant_declaration: ARRAY '[' IVALUE DOTDOT IVALUE
1500 ']' OF float_domain ':' IDENTIFIER annotations '=' '[' floats
1501 ']' */
1502#line 210 "ortools/flatzinc/parser.yy"
1503 {
1504 std::vector<Annotation>* const annotations = (yyvsp[-4].annotations);
1505 // Declaration of a (named) constant array. See rule right above.
1506 CHECK_EQ((yyvsp[-12].integer_value), 1)
1507 << "Only [1..n] array are supported here.";
1508 const int64_t num_constants = (yyvsp[-10].integer_value);
1509 const std::string& identifier = (yyvsp[-5].string_value);
1510 const std::vector<double>* const assignments = (yyvsp[-1].doubles);
1511 CHECK(assignments != nullptr);
1512 CHECK_EQ(num_constants, assignments->size());
1513 // TODO(user): CHECK all values within domain.
1514 context->float_array_map[identifier] = *assignments;
1515 delete assignments;
1516 delete annotations;
1517 }
1518#line 1672 "parser.tab.cc"
1519 break;
1520
1521 case 23: /* variable_or_constant_declaration: ARRAY '[' IVALUE DOTDOT IVALUE
1522 ']' OF float_domain ':' IDENTIFIER annotations '=' '[' ']' */
1523#line 225 "ortools/flatzinc/parser.yy"
1524 {
1525 std::vector<Annotation>* const annotations = (yyvsp[-3].annotations);
1526 // Declaration of a (named) constant array. See rule right above.
1527 CHECK_EQ((yyvsp[-11].integer_value), 1)
1528 << "Only [1..n] array are supported here.";
1529 const int64_t num_constants = (yyvsp[-9].integer_value);
1530 CHECK_EQ(num_constants, 0) << "Empty arrays should have a size of 0";
1531 const std::string& identifier = (yyvsp[-4].string_value);
1532 context->float_array_map[identifier] = std::vector<double>();
1533 delete annotations;
1534 }
1535#line 1687 "parser.tab.cc"
1536 break;
1537
1538 case 24: /* variable_or_constant_declaration: ARRAY '[' IVALUE DOTDOT IVALUE
1539 ']' OF set_domain ':' IDENTIFIER annotations '=' '['
1540 const_literals ']' */
1541#line 236 "ortools/flatzinc/parser.yy"
1542 {
1543 // Declaration of a (named) set constant array: See rule above.
1544 CHECK_EQ((yyvsp[-12].integer_value), 1)
1545 << "Only [1..n] array are supported here.";
1546 const int64_t num_domains = (yyvsp[-10].integer_value);
1547 // const Domain& domain = $8;
1548 const std::string& identifier = (yyvsp[-5].string_value);
1549 const std::vector<Domain>* const assignments = (yyvsp[-1].domains);
1550 const std::vector<Annotation>* const annotations =
1551 (yyvsp[-4].annotations);
1552 CHECK(assignments != nullptr);
1553 CHECK_EQ(num_domains, assignments->size());
1554 context->domain_array_map[identifier] = *assignments;
1555 delete assignments;
1556 delete annotations;
1557 }
1558#line 1706 "parser.tab.cc"
1559 break;
1560
1561 case 25: /* variable_or_constant_declaration: VAR domain ':' IDENTIFIER
1562 annotations optional_var_or_value */
1563#line 250 "ortools/flatzinc/parser.yy"
1564 {
1565 // Declaration of a variable. If it's unassigned or assigned to a
1566 // constant, we'll create a new var stored in the model. If it's
1567 // assigned to another variable x then we simply adjust that
1568 // existing variable x according to the current (re-)declaration.
1569 const Domain& domain = (yyvsp[-4].domain);
1570 const std::string& identifier = (yyvsp[-2].string_value);
1571 std::vector<Annotation>* const annotations = (yyvsp[-1].annotations);
1572 const VarRefOrValue& assignment = (yyvsp[0].var_or_value);
1573 const bool introduced = ContainsId(annotations, "var_is_introduced") ||
1574 absl::StartsWith(identifier, "X_INTRODUCED");
1575 Variable* var = nullptr;
1576 if (!assignment.defined) {
1577 var = model->AddVariable(identifier, domain, introduced);
1578 CHECK_EQ(var->domain.is_a_set, domain.is_a_set);
1579 } else if (assignment.variable == nullptr) { // A constant.
1580 if (assignment.is_float) {
1581 // Assigned to an float constant.
1582 const double value = assignment.float_value;
1583 var = model->AddVariable(identifier, Domain::FloatValue(value),
1584 introduced);
1585 } else if (assignment.is_domain) {
1586 // TODO(user): Check that the assignment is included in the domain.
1587 // We force the set domain because we can have the following code:
1588 // var set of {0,18}: x = {0,18};
1589 // where the second domain is not tagged as a set.
1590 //
1591 // Assigned to a set constant.
1592 var = model->AddVariable(identifier, assignment.domain, introduced,
1593 domain.is_a_set);
1594 } else {
1595 CHECK(domain.Contains(assignment.value));
1596 var = model->AddVariable(
1597 identifier, Domain::IntegerValue(assignment.value), introduced);
1598 }
1599 } else { // a variable.
1600 var = assignment.variable;
1601 var->Merge(identifier, domain, introduced);
1602 }
1603
1604 // We also register the variable in the parser's context, and add some
1605 // output to the model if needed.
1606 context->variable_map[identifier] = var;
1607 if (ContainsId(annotations, "output_var")) {
1609 identifier, var, domain.display_as_boolean));
1610 }
1611 delete annotations;
1612 }
1613#line 1761 "parser.tab.cc"
1614 break;
1615
1616 case 26: /* variable_or_constant_declaration: ARRAY '[' IVALUE DOTDOT IVALUE
1617 ']' OF VAR domain ':' IDENTIFIER annotations
1618 optional_var_or_value_array */
1619#line 301 "ortools/flatzinc/parser.yy"
1620 {
1621 // Declaration of a "variable array": these is exactly like N simple
1622 // variable declarations, where the identifier for declaration #i is
1623 // IDENTIFIER[i] (1-based index).
1624 CHECK_EQ((yyvsp[-10].integer_value), 1);
1625 const int64_t num_vars = (yyvsp[-8].integer_value);
1626 const Domain& domain = (yyvsp[-4].domain);
1627 const std::string& identifier = (yyvsp[-2].string_value);
1628 std::vector<Annotation>* const annotations = (yyvsp[-1].annotations);
1629 std::vector<VarRefOrValue>* const assignments =
1630 (yyvsp[0].var_or_value_array);
1631 CHECK(assignments == nullptr || assignments->size() == num_vars);
1632 const bool introduced = ContainsId(annotations, "var_is_introduced") ||
1633 absl::StartsWith(identifier, "X_INTRODUCED");
1634
1635 std::vector<Variable*> vars(num_vars, nullptr);
1636
1637 for (int i = 0; i < num_vars; ++i) {
1638 const std::string var_name =
1639 absl::StrFormat("%s[%d]", identifier, i + 1);
1640 if (assignments == nullptr) {
1641 vars[i] = model->AddVariable(var_name, domain, introduced);
1642 } else if ((*assignments)[i].variable == nullptr) { // A constant.
1643 if ((*assignments)[i].is_float) {
1644 // Assigned to an float constant.
1645 const double value = (*assignments)[i].float_value;
1646 vars[i] = model->AddVariable(var_name, Domain::FloatValue(value),
1647 introduced);
1648 } else if ((*assignments)[i].is_domain) {
1649 // TODO(user): Check that the assignment is included in the domain.
1650 // We force the set domain because we can have the following code:
1651 // var set of {0,18}: x = {0,18};
1652 // where the second domain is not tagged as a set.
1653 //
1654 // Assigned to a set constant.
1655 vars[i] = model->AddVariable(var_name, (*assignments)[i].domain,
1656 introduced, domain.is_a_set);
1657 } else {
1658 // Assigned to an integer constant.
1659 const int64_t value = (*assignments)[i].value;
1660 CHECK(domain.Contains(value));
1661 vars[i] = model->AddVariable(var_name, Domain::IntegerValue(value),
1662 introduced);
1663 }
1664 } else {
1665 Variable* const var = (*assignments)[i].variable;
1666 CHECK(var != nullptr);
1667 vars[i] = var;
1668 vars[i]->Merge(var_name, domain, introduced);
1669 }
1670 }
1671 delete assignments;
1672
1673 // Register the variable array on the context.
1674 context->variable_array_map[identifier] = vars;
1675
1676 // We parse the annotations to build an output object if
1677 // needed. It's a bit more convoluted than the simple variable
1678 // output.
1679 if (annotations != nullptr) {
1680 for (int i = 0; i < annotations->size(); ++i) {
1681 const Annotation& ann = (*annotations)[i];
1682 if (ann.IsFunctionCallWithIdentifier("output_array")) {
1683 // We have found an output annotation.
1684 CHECK_EQ(1, ann.annotations.size());
1685 CHECK_EQ(Annotation::ANNOTATION_LIST, ann.annotations.back().type);
1686 const Annotation& list = ann.annotations.back();
1687 // Let's build the vector of bounds.
1688 std::vector<SolutionOutputSpecs::Bounds> bounds;
1689 for (int a = 0; a < list.annotations.size(); ++a) {
1690 const Annotation& bound = list.annotations[a];
1691 CHECK_EQ(Annotation::INTERVAL, bound.type);
1692 bounds.emplace_back(SolutionOutputSpecs::Bounds(
1693 bound.interval_min, bound.interval_max));
1694 }
1695 // We add the output information.
1697 identifier, bounds, vars, domain.display_as_boolean));
1698 }
1699 }
1700 delete annotations;
1701 }
1702 }
1703#line 1848 "parser.tab.cc"
1704 break;
1705
1706 case 27: /* optional_var_or_value: '=' var_or_value */
1707#line 385 "ortools/flatzinc/parser.yy"
1708 {
1709 (yyval.var_or_value) = (yyvsp[0].var_or_value);
1710 }
1711#line 1854 "parser.tab.cc"
1712 break;
1713
1714 case 28: /* optional_var_or_value: %empty */
1715#line 386 "ortools/flatzinc/parser.yy"
1716 {
1718 }
1719#line 1860 "parser.tab.cc"
1720 break;
1721
1722 case 29: /* optional_var_or_value_array: '=' '[' var_or_value_array ']' */
1723#line 389 "ortools/flatzinc/parser.yy"
1724 {
1725 (yyval.var_or_value_array) = (yyvsp[-1].var_or_value_array);
1726 }
1727#line 1866 "parser.tab.cc"
1728 break;
1729
1730 case 30: /* optional_var_or_value_array: '=' '[' ']' */
1731#line 390 "ortools/flatzinc/parser.yy"
1732 {
1733 (yyval.var_or_value_array) = nullptr;
1734 }
1735#line 1872 "parser.tab.cc"
1736 break;
1737
1738 case 31: /* optional_var_or_value_array: %empty */
1739#line 391 "ortools/flatzinc/parser.yy"
1740 {
1741 (yyval.var_or_value_array) = nullptr;
1742 }
1743#line 1878 "parser.tab.cc"
1744 break;
1745
1746 case 32: /* var_or_value_array: var_or_value_array ',' var_or_value */
1747#line 394 "ortools/flatzinc/parser.yy"
1748 {
1749 (yyval.var_or_value_array) = (yyvsp[-2].var_or_value_array);
1750 (yyval.var_or_value_array)->push_back((yyvsp[0].var_or_value));
1751 }
1752#line 1887 "parser.tab.cc"
1753 break;
1754
1755 case 33: /* var_or_value_array: var_or_value */
1756#line 398 "ortools/flatzinc/parser.yy"
1757 {
1758 (yyval.var_or_value_array) = new std::vector<VarRefOrValue>();
1759 (yyval.var_or_value_array)->push_back((yyvsp[0].var_or_value));
1760 }
1761#line 1896 "parser.tab.cc"
1762 break;
1763
1764 case 34: /* var_or_value: IVALUE */
1765#line 404 "ortools/flatzinc/parser.yy"
1766 {
1767 (yyval.var_or_value) = VarRefOrValue::Value((yyvsp[0].integer_value));
1768 }
1769#line 1902 "parser.tab.cc"
1770 break;
1771
1772 case 35: /* var_or_value: DVALUE */
1773#line 405 "ortools/flatzinc/parser.yy"
1774 {
1775 (yyval.var_or_value) = VarRefOrValue::FloatValue((yyvsp[0].double_value));
1776 }
1777#line 1908 "parser.tab.cc"
1778 break;
1779
1780 case 36: /* var_or_value: IVALUE DOTDOT IVALUE */
1781#line 406 "ortools/flatzinc/parser.yy"
1782 {
1784 (yyvsp[-2].integer_value), (yyvsp[0].integer_value)));
1785 }
1786#line 1916 "parser.tab.cc"
1787 break;
1788
1789 case 37: /* var_or_value: '{' integers '}' */
1790#line 409 "ortools/flatzinc/parser.yy"
1791 {
1792 CHECK((yyvsp[-1].integers) != nullptr);
1794 Domain::IntegerList(std::move(*(yyvsp[-1].integers))));
1795 delete (yyvsp[-1].integers);
1796 }
1797#line 1926 "parser.tab.cc"
1798 break;
1799
1800 case 38: /* var_or_value: IDENTIFIER */
1801#line 414 "ortools/flatzinc/parser.yy"
1802 {
1803 // A reference to an existing integer constant or variable.
1804 const std::string& id = (yyvsp[0].string_value);
1805 if (context->integer_map.contains(id)) {
1806 (yyval.var_or_value) =
1807 VarRefOrValue::Value(context->integer_map.at(id));
1808 } else if (context->float_map.contains(id)) {
1809 (yyval.var_or_value) =
1810 VarRefOrValue::FloatValue(context->float_map.at(id));
1811 } else if (context->variable_map.contains(id)) {
1812 (yyval.var_or_value) =
1813 VarRefOrValue::VarRef(context->variable_map.at(id));
1814 } else {
1815 LOG(ERROR) << "Unknown symbol " << id;
1817 *ok = false;
1818 }
1819 }
1820#line 1946 "parser.tab.cc"
1821 break;
1822
1823 case 39: /* var_or_value: IDENTIFIER '[' IVALUE ']' */
1824#line 429 "ortools/flatzinc/parser.yy"
1825 {
1826 // A given element of an existing constant array or variable array.
1827 const std::string& id = (yyvsp[-3].string_value);
1828 const int64_t value = (yyvsp[-1].integer_value);
1829 if (context->integer_array_map.contains(id)) {
1831 Lookup(context->integer_array_map.at(id), value));
1832 } else if (context->float_array_map.contains(id)) {
1834 Lookup(context->float_array_map.at(id), value));
1835 } else if (context->variable_array_map.contains(id)) {
1837 Lookup(context->variable_array_map.at(id), value));
1838 } else {
1839 LOG(ERROR) << "Unknown symbol " << id;
1841 *ok = false;
1842 }
1843 }
1844#line 1970 "parser.tab.cc"
1845 break;
1846
1847 case 40: /* int_domain: TOKEN_BOOL */
1848#line 450 "ortools/flatzinc/parser.yy"
1849 {
1850 (yyval.domain) = Domain::Boolean();
1851 }
1852#line 1976 "parser.tab.cc"
1853 break;
1854
1855 case 41: /* int_domain: TOKEN_INT */
1856#line 451 "ortools/flatzinc/parser.yy"
1857 {
1858 (yyval.domain) = Domain::AllInt64();
1859 }
1860#line 1982 "parser.tab.cc"
1861 break;
1862
1863 case 42: /* int_domain: IVALUE DOTDOT IVALUE */
1864#line 452 "ortools/flatzinc/parser.yy"
1865 {
1866 (yyval.domain) =
1867 Domain::Interval((yyvsp[-2].integer_value), (yyvsp[0].integer_value));
1868 }
1869#line 1988 "parser.tab.cc"
1870 break;
1871
1872 case 43: /* int_domain: '{' integers '}' */
1873#line 453 "ortools/flatzinc/parser.yy"
1874 {
1875 CHECK((yyvsp[-1].integers) != nullptr);
1876 (yyval.domain) = Domain::IntegerList(std::move(*(yyvsp[-1].integers)));
1877 delete (yyvsp[-1].integers);
1878 }
1879#line 1998 "parser.tab.cc"
1880 break;
1881
1882 case 44: /* set_domain: SET OF TOKEN_BOOL */
1883#line 460 "ortools/flatzinc/parser.yy"
1884 {
1885 (yyval.domain) = Domain::SetOfBoolean();
1886 }
1887#line 2004 "parser.tab.cc"
1888 break;
1889
1890 case 45: /* set_domain: SET OF TOKEN_INT */
1891#line 461 "ortools/flatzinc/parser.yy"
1892 {
1893 (yyval.domain) = Domain::SetOfAllInt64();
1894 }
1895#line 2010 "parser.tab.cc"
1896 break;
1897
1898 case 46: /* set_domain: SET OF IVALUE DOTDOT IVALUE */
1899#line 462 "ortools/flatzinc/parser.yy"
1900 {
1901 (yyval.domain) = Domain::SetOfInterval((yyvsp[-2].integer_value),
1902 (yyvsp[0].integer_value));
1903 }
1904#line 2016 "parser.tab.cc"
1905 break;
1906
1907 case 47: /* set_domain: SET OF '{' integers '}' */
1908#line 463 "ortools/flatzinc/parser.yy"
1909 {
1910 CHECK((yyvsp[-1].integers) != nullptr);
1911 (yyval.domain) =
1912 Domain::SetOfIntegerList(std::move(*(yyvsp[-1].integers)));
1913 delete (yyvsp[-1].integers);
1914 }
1915#line 2026 "parser.tab.cc"
1916 break;
1917
1918 case 48: /* float_domain: TOKEN_FLOAT */
1919#line 470 "ortools/flatzinc/parser.yy"
1920 {
1921 (yyval.domain) = Domain::AllFloats();
1922 }
1923#line 2032 "parser.tab.cc"
1924 break;
1925
1926 case 49: /* float_domain: DVALUE DOTDOT DVALUE */
1927#line 471 "ortools/flatzinc/parser.yy"
1928 {
1929 (yyval.domain) = Domain::FloatInterval((yyvsp[-2].double_value),
1930 (yyvsp[0].double_value));
1931 }
1932#line 2040 "parser.tab.cc"
1933 break;
1934
1935 case 50: /* domain: int_domain */
1936#line 476 "ortools/flatzinc/parser.yy"
1937 {
1938 (yyval.domain) = (yyvsp[0].domain);
1939 }
1940#line 2046 "parser.tab.cc"
1941 break;
1942
1943 case 51: /* domain: set_domain */
1944#line 477 "ortools/flatzinc/parser.yy"
1945 {
1946 (yyval.domain) = (yyvsp[0].domain);
1947 }
1948#line 2052 "parser.tab.cc"
1949 break;
1950
1951 case 52: /* domain: float_domain */
1952#line 478 "ortools/flatzinc/parser.yy"
1953 {
1954 (yyval.domain) = (yyvsp[0].domain);
1955 }
1956#line 2058 "parser.tab.cc"
1957 break;
1958
1959 case 53: /* integers: integers ',' integer */
1960#line 481 "ortools/flatzinc/parser.yy"
1961 {
1962 (yyval.integers) = (yyvsp[-2].integers);
1963 (yyval.integers)->emplace_back((yyvsp[0].integer_value));
1964 }
1965#line 2064 "parser.tab.cc"
1966 break;
1967
1968 case 54: /* integers: integer */
1969#line 482 "ortools/flatzinc/parser.yy"
1970 {
1971 (yyval.integers) = new std::vector<int64_t>();
1972 (yyval.integers)->emplace_back((yyvsp[0].integer_value));
1973 }
1974#line 2070 "parser.tab.cc"
1975 break;
1976
1977 case 55: /* integer: IVALUE */
1978#line 485 "ortools/flatzinc/parser.yy"
1979 {
1980 (yyval.integer_value) = (yyvsp[0].integer_value);
1981 }
1982#line 2076 "parser.tab.cc"
1983 break;
1984
1985 case 56: /* integer: IDENTIFIER */
1986#line 486 "ortools/flatzinc/parser.yy"
1987 {
1988 (yyval.integer_value) = context->integer_map.at((yyvsp[0].string_value));
1989 }
1990#line 2082 "parser.tab.cc"
1991 break;
1992
1993 case 57: /* integer: IDENTIFIER '[' IVALUE ']' */
1994#line 487 "ortools/flatzinc/parser.yy"
1995 {
1996 (yyval.integer_value) =
1997 Lookup(context->integer_array_map.at((yyvsp[-3].string_value)),
1998 (yyvsp[-1].integer_value));
1999 }
2000#line 2090 "parser.tab.cc"
2001 break;
2002
2003 case 58: /* floats: floats ',' float */
2004#line 492 "ortools/flatzinc/parser.yy"
2005 {
2006 (yyval.doubles) = (yyvsp[-2].doubles);
2007 (yyval.doubles)->emplace_back((yyvsp[0].double_value));
2008 }
2009#line 2096 "parser.tab.cc"
2010 break;
2011
2012 case 59: /* floats: float */
2013#line 493 "ortools/flatzinc/parser.yy"
2014 {
2015 (yyval.doubles) = new std::vector<double>();
2016 (yyval.doubles)->emplace_back((yyvsp[0].double_value));
2017 }
2018#line 2102 "parser.tab.cc"
2019 break;
2020
2021 case 60: /* float: DVALUE */
2022#line 496 "ortools/flatzinc/parser.yy"
2023 {
2024 (yyval.double_value) = (yyvsp[0].double_value);
2025 }
2026#line 2108 "parser.tab.cc"
2027 break;
2028
2029 case 61: /* float: IDENTIFIER */
2030#line 497 "ortools/flatzinc/parser.yy"
2031 {
2032 (yyval.double_value) = context->float_map.at((yyvsp[0].string_value));
2033 }
2034#line 2114 "parser.tab.cc"
2035 break;
2036
2037 case 62: /* float: IDENTIFIER '[' IVALUE ']' */
2038#line 498 "ortools/flatzinc/parser.yy"
2039 {
2040 (yyval.double_value) =
2041 Lookup(context->float_array_map.at((yyvsp[-3].string_value)),
2042 (yyvsp[-1].integer_value));
2043 }
2044#line 2122 "parser.tab.cc"
2045 break;
2046
2047 case 63: /* const_literal: IVALUE */
2048#line 503 "ortools/flatzinc/parser.yy"
2049 {
2050 (yyval.domain) = Domain::IntegerValue((yyvsp[0].integer_value));
2051 }
2052#line 2128 "parser.tab.cc"
2053 break;
2054
2055 case 64: /* const_literal: IVALUE DOTDOT IVALUE */
2056#line 504 "ortools/flatzinc/parser.yy"
2057 {
2058 (yyval.domain) =
2059 Domain::Interval((yyvsp[-2].integer_value), (yyvsp[0].integer_value));
2060 }
2061#line 2134 "parser.tab.cc"
2062 break;
2063
2064 case 65: /* const_literal: '{' integers '}' */
2065#line 505 "ortools/flatzinc/parser.yy"
2066 {
2067 CHECK((yyvsp[-1].integers) != nullptr);
2068 (yyval.domain) = Domain::IntegerList(std::move(*(yyvsp[-1].integers)));
2069 delete (yyvsp[-1].integers);
2070 }
2071#line 2144 "parser.tab.cc"
2072 break;
2073
2074 case 66: /* const_literal: '{' '}' */
2075#line 510 "ortools/flatzinc/parser.yy"
2076 {
2077 (yyval.domain) = Domain::EmptyDomain();
2078 }
2079#line 2150 "parser.tab.cc"
2080 break;
2081
2082 case 67: /* const_literal: DVALUE */
2083#line 511 "ortools/flatzinc/parser.yy"
2084 {
2085 (yyval.domain) = Domain::FloatValue((yyvsp[0].double_value));
2086 }
2087#line 2158 "parser.tab.cc"
2088 break;
2089
2090 case 68: /* const_literal: IDENTIFIER */
2091#line 514 "ortools/flatzinc/parser.yy"
2092 {
2093 (yyval.domain) = Domain::IntegerValue(
2094 context->integer_map.at((yyvsp[0].string_value)));
2095 }
2096#line 2164 "parser.tab.cc"
2097 break;
2098
2099 case 69: /* const_literal: IDENTIFIER '[' IVALUE ']' */
2100#line 515 "ortools/flatzinc/parser.yy"
2101 {
2102 (yyval.domain) = Domain::IntegerValue(
2103 Lookup(context->integer_array_map.at((yyvsp[-3].string_value)),
2104 (yyvsp[-1].integer_value)));
2105 }
2106#line 2173 "parser.tab.cc"
2107 break;
2108
2109 case 70: /* const_literals: const_literals ',' const_literal */
2110#line 521 "ortools/flatzinc/parser.yy"
2111 {
2112 (yyval.domains) = (yyvsp[-2].domains);
2113 (yyval.domains)->emplace_back((yyvsp[0].domain));
2114 }
2115#line 2182 "parser.tab.cc"
2116 break;
2117
2118 case 71: /* const_literals: const_literal */
2119#line 525 "ortools/flatzinc/parser.yy"
2120 {
2121 (yyval.domains) = new std::vector<Domain>();
2122 (yyval.domains)->emplace_back((yyvsp[0].domain));
2123 }
2124#line 2188 "parser.tab.cc"
2125 break;
2126
2127 case 74: /* constraint: CONSTRAINT IDENTIFIER '(' arguments ')' annotations
2128 */
2129#line 535 "ortools/flatzinc/parser.yy"
2130 {
2131 const std::string& identifier = (yyvsp[-4].string_value);
2132 CHECK((yyvsp[-2].args) != nullptr) << "Missing argument in constraint";
2133 const std::vector<Argument>& arguments = *(yyvsp[-2].args);
2134 std::vector<Annotation>* const annotations = (yyvsp[0].annotations);
2135
2136 model->AddConstraint(identifier, arguments,
2137 ContainsId(annotations, "domain"),
2138 ContainsId(annotations, "symmetry_breaking"),
2139 ContainsId(annotations, "redundant"));
2140 delete annotations;
2141 delete (yyvsp[-2].args);
2142 }
2143#line 2205 "parser.tab.cc"
2144 break;
2145
2146 case 75: /* arguments: arguments ',' argument */
2147#line 549 "ortools/flatzinc/parser.yy"
2148 {
2149 (yyval.args) = (yyvsp[-2].args);
2150 (yyval.args)->emplace_back((yyvsp[0].arg));
2151 }
2152#line 2211 "parser.tab.cc"
2153 break;
2154
2155 case 76: /* arguments: argument */
2156#line 550 "ortools/flatzinc/parser.yy"
2157 {
2158 (yyval.args) = new std::vector<Argument>();
2159 (yyval.args)->emplace_back((yyvsp[0].arg));
2160 }
2161#line 2217 "parser.tab.cc"
2162 break;
2163
2164 case 77: /* argument: IVALUE */
2165#line 553 "ortools/flatzinc/parser.yy"
2166 {
2167 (yyval.arg) = Argument::IntegerValue((yyvsp[0].integer_value));
2168 }
2169#line 2223 "parser.tab.cc"
2170 break;
2171
2172 case 78: /* argument: DVALUE */
2173#line 554 "ortools/flatzinc/parser.yy"
2174 {
2175 (yyval.arg) = Argument::FloatValue((yyvsp[0].double_value));
2176 }
2177#line 2229 "parser.tab.cc"
2178 break;
2179
2180 case 79: /* argument: SVALUE */
2181#line 555 "ortools/flatzinc/parser.yy"
2182 {
2183 (yyval.arg) = Argument::VoidArgument();
2184 }
2185#line 2235 "parser.tab.cc"
2186 break;
2187
2188 case 80: /* argument: IVALUE DOTDOT IVALUE */
2189#line 556 "ortools/flatzinc/parser.yy"
2190 {
2191 (yyval.arg) = Argument::Interval((yyvsp[-2].integer_value),
2192 (yyvsp[0].integer_value));
2193 }
2194#line 2241 "parser.tab.cc"
2195 break;
2196
2197 case 81: /* argument: '{' integers '}' */
2198#line 557 "ortools/flatzinc/parser.yy"
2199 {
2200 CHECK((yyvsp[-1].integers) != nullptr);
2201 (yyval.arg) = Argument::IntegerList(std::move(*(yyvsp[-1].integers)));
2202 delete (yyvsp[-1].integers);
2203 }
2204#line 2251 "parser.tab.cc"
2205 break;
2206
2207 case 82: /* argument: IDENTIFIER */
2208#line 562 "ortools/flatzinc/parser.yy"
2209 {
2210 const std::string& id = (yyvsp[0].string_value);
2211 if (context->integer_map.contains(id)) {
2212 (yyval.arg) = Argument::IntegerValue(context->integer_map.at(id));
2213 } else if (context->integer_array_map.contains(id)) {
2214 (yyval.arg) = Argument::IntegerList(context->integer_array_map.at(id));
2215 } else if (context->float_map.contains(id)) {
2216 const double d = context->float_map.at(id);
2217 (yyval.arg) = Argument::FloatValue(d);
2218 } else if (context->float_array_map.contains(id)) {
2219 const auto& double_values = context->float_array_map.at(id);
2220 (yyval.arg) = Argument::FloatList(std::move(double_values));
2221 } else if (context->variable_map.contains(id)) {
2222 (yyval.arg) = Argument::VarRef(context->variable_map.at(id));
2223 } else if (context->variable_array_map.contains(id)) {
2224 (yyval.arg) = Argument::VarRefArray(context->variable_array_map.at(id));
2225 } else if (context->domain_map.contains(id)) {
2226 const Domain& d = context->domain_map.at(id);
2227 (yyval.arg) = Argument::FromDomain(d);
2228 } else {
2229 CHECK(context->domain_array_map.contains(id))
2230 << "Unknown identifier: " << id;
2231 const std::vector<Domain>& d = context->domain_array_map.at(id);
2232 (yyval.arg) = Argument::DomainList(d);
2233 }
2234 }
2235#line 2282 "parser.tab.cc"
2236 break;
2237
2238 case 83: /* argument: IDENTIFIER '[' IVALUE ']' */
2239#line 588 "ortools/flatzinc/parser.yy"
2240 {
2241 const std::string& id = (yyvsp[-3].string_value);
2242 const int64_t index = (yyvsp[-1].integer_value);
2243 if (context->integer_array_map.contains(id)) {
2244 (yyval.arg) = Argument::IntegerValue(
2245 Lookup(context->integer_array_map.at(id), index));
2246 } else if (context->variable_array_map.contains(id)) {
2247 (yyval.arg) =
2248 Argument::VarRef(Lookup(context->variable_array_map.at(id), index));
2249 } else {
2250 CHECK(context->domain_array_map.contains(id))
2251 << "Unknown identifier: " << id;
2252 const Domain& d = Lookup(context->domain_array_map.at(id), index);
2253 (yyval.arg) = Argument::FromDomain(d);
2254 }
2255 }
2256#line 2304 "parser.tab.cc"
2257 break;
2258
2259 case 84: /* argument: '[' var_or_value_array ']' */
2260#line 605 "ortools/flatzinc/parser.yy"
2261 {
2262 std::vector<VarRefOrValue>* const arguments =
2263 (yyvsp[-1].var_or_value_array);
2264 CHECK(arguments != nullptr);
2265 bool has_variables = false;
2266 bool has_floats = false;
2267 for (int i = 0; i < arguments->size(); ++i) {
2268 if ((*arguments)[i].variable != nullptr) {
2269 has_variables = true;
2270 }
2271 if ((*arguments)[i].is_float) {
2272 has_floats = true;
2273 }
2274 }
2275 if (has_variables) {
2276 std::vector<Variable*> vars;
2277 vars.reserve(arguments->size());
2278 for (int i = 0; i < arguments->size(); ++i) {
2279 const VarRefOrValue data = (*arguments)[i];
2280 if (data.variable != nullptr) {
2281 vars.push_back(data.variable);
2282 } else if (!data.is_float) {
2283 vars.push_back(model->AddConstant(data.value));
2284 } else {
2285 vars.push_back(model->AddFloatConstant(data.float_value));
2286 }
2287 }
2288 (yyval.arg) = Argument::VarRefArray(std::move(vars));
2289 } else if (has_floats) {
2290 std::vector<double> values;
2291 values.reserve(arguments->size());
2292 for (const VarRefOrValue& data : *arguments) {
2293 if (data.is_float) {
2294 values.push_back(data.float_value);
2295 } else {
2296 values.push_back(data.value);
2297 }
2298 }
2299 (yyval.arg) = Argument::FloatList(std::move(values));
2300 } else {
2301 std::vector<int64_t> values;
2302 values.reserve(arguments->size());
2303 for (const VarRefOrValue& data : *arguments) {
2304 values.push_back(data.value);
2305 }
2306 (yyval.arg) = Argument::IntegerList(std::move(values));
2307 }
2308 delete arguments;
2309 }
2310#line 2357 "parser.tab.cc"
2311 break;
2312
2313 case 85: /* argument: '[' ']' */
2314#line 653 "ortools/flatzinc/parser.yy"
2315 {
2316 (yyval.arg) = Argument::VoidArgument();
2317 }
2318#line 2365 "parser.tab.cc"
2319 break;
2320
2321 case 86: /* annotations: annotations COLONCOLON annotation */
2322#line 662 "ortools/flatzinc/parser.yy"
2323 {
2324 (yyval.annotations) = (yyvsp[-2].annotations) != nullptr
2325 ? (yyvsp[-2].annotations)
2326 : new std::vector<Annotation>();
2327 (yyval.annotations)->emplace_back((yyvsp[0].annotation));
2328 }
2329#line 2374 "parser.tab.cc"
2330 break;
2331
2332 case 87: /* annotations: %empty */
2333#line 666 "ortools/flatzinc/parser.yy"
2334 {
2335 (yyval.annotations) = nullptr;
2336 }
2337#line 2380 "parser.tab.cc"
2338 break;
2339
2340 case 88: /* annotation_arguments: annotation_arguments ',' annotation */
2341#line 669 "ortools/flatzinc/parser.yy"
2342 {
2343 (yyval.annotations) = (yyvsp[-2].annotations);
2344 (yyval.annotations)->emplace_back((yyvsp[0].annotation));
2345 }
2346#line 2386 "parser.tab.cc"
2347 break;
2348
2349 case 89: /* annotation_arguments: annotation */
2350#line 670 "ortools/flatzinc/parser.yy"
2351 {
2352 (yyval.annotations) = new std::vector<Annotation>();
2353 (yyval.annotations)->emplace_back((yyvsp[0].annotation));
2354 }
2355#line 2392 "parser.tab.cc"
2356 break;
2357
2358 case 90: /* annotation: IVALUE DOTDOT IVALUE */
2359#line 673 "ortools/flatzinc/parser.yy"
2360 {
2361 (yyval.annotation) = Annotation::Interval((yyvsp[-2].integer_value),
2362 (yyvsp[0].integer_value));
2363 }
2364#line 2398 "parser.tab.cc"
2365 break;
2366
2367 case 91: /* annotation: '{' integers '}' */
2368#line 674 "ortools/flatzinc/parser.yy"
2369 {
2370 CHECK((yyvsp[-1].integers) != nullptr);
2371 (yyval.annotation) =
2372 Annotation::IntegerList(std::move(*(yyvsp[-1].integers)));
2373 delete (yyvsp[-1].integers);
2374 }
2375#line 2408 "parser.tab.cc"
2376 break;
2377
2378 case 92: /* annotation: IVALUE */
2379#line 679 "ortools/flatzinc/parser.yy"
2380 {
2381 (yyval.annotation) = Annotation::IntegerValue((yyvsp[0].integer_value));
2382 }
2383#line 2414 "parser.tab.cc"
2384 break;
2385
2386 case 93: /* annotation: SVALUE */
2387#line 680 "ortools/flatzinc/parser.yy"
2388 {
2389 (yyval.annotation) = Annotation::String((yyvsp[0].string_value));
2390 }
2391#line 2420 "parser.tab.cc"
2392 break;
2393
2394 case 94: /* annotation: IDENTIFIER */
2395#line 681 "ortools/flatzinc/parser.yy"
2396 {
2397 const std::string& id = (yyvsp[0].string_value);
2398 if (context->variable_map.contains(id)) {
2399 (yyval.annotation) = Annotation::VarRef(context->variable_map.at(id));
2400 } else if (context->variable_array_map.contains(id)) {
2401 (yyval.annotation) =
2403 } else if (context->integer_map.contains(id)) {
2404 (yyval.annotation) =
2405 Annotation::IntegerValue(context->integer_map.at(id));
2406 } else if (context->integer_array_map.contains(id)) {
2407 (yyval.annotation) =
2409 } else {
2410 (yyval.annotation) = Annotation::Identifier(id);
2411 }
2412 }
2413#line 2439 "parser.tab.cc"
2414 break;
2415
2416 case 95: /* annotation: IDENTIFIER '(' annotation_arguments ')' */
2417#line 695 "ortools/flatzinc/parser.yy"
2418 {
2419 std::vector<Annotation>* const annotations = (yyvsp[-1].annotations);
2420 if (annotations != nullptr) {
2422 (yyvsp[-3].string_value), std::move(*annotations));
2423 delete annotations;
2424 } else {
2425 (yyval.annotation) = Annotation::FunctionCall((yyvsp[-3].string_value));
2426 }
2427 }
2428#line 2453 "parser.tab.cc"
2429 break;
2430
2431 case 96: /* annotation: IDENTIFIER '[' IVALUE ']' */
2432#line 704 "ortools/flatzinc/parser.yy"
2433 {
2434 CHECK(context->variable_array_map.contains((yyvsp[-3].string_value)))
2435 << "Unknown identifier: " << (yyvsp[-3].string_value);
2437 Lookup(context->variable_array_map.at((yyvsp[-3].string_value)),
2438 (yyvsp[-1].integer_value)));
2439 }
2440#line 2464 "parser.tab.cc"
2441 break;
2442
2443 case 97: /* annotation: '[' annotation_arguments ']' */
2444#line 710 "ortools/flatzinc/parser.yy"
2445 {
2446 std::vector<Annotation>* const annotations = (yyvsp[-1].annotations);
2447 if (annotations != nullptr && !annotations->empty()) {
2448 bool all_integers = true;
2449 bool all_vars = true;
2450 for (const Annotation& ann : *annotations) {
2451 if (ann.type != Annotation::INT_VALUE) all_integers = false;
2452 if (ann.type != Annotation::VAR_REF) all_vars = false;
2453 }
2454 if (all_integers) {
2455 std::vector<int64_t> values;
2456 for (const Annotation& ann : *annotations) {
2457 values.push_back(ann.interval_min);
2458 }
2459 (yyval.annotation) = Annotation::IntegerList(values);
2460 } else if (all_vars) {
2461 std::vector<Variable*> vars;
2462 for (const Annotation& ann : *annotations) {
2463 vars.push_back(ann.variables[0]);
2464 }
2465 (yyval.annotation) = Annotation::VarRefArray(vars);
2466 } else {
2467 (yyval.annotation) =
2468 Annotation::AnnotationList(std::move(*annotations));
2469 }
2470 delete annotations;
2471 } else {
2472 (yyval.annotation) = Annotation::Empty();
2473 }
2474 }
2475#line 2498 "parser.tab.cc"
2476 break;
2477
2478 case 98: /* annotation: '[' ']' */
2479#line 739 "ortools/flatzinc/parser.yy"
2480 {
2481 (yyval.annotation) = Annotation::Empty();
2482 }
2483#line 2506 "parser.tab.cc"
2484 break;
2485
2486 case 99: /* solve: SOLVE annotations SATISFY */
2487#line 748 "ortools/flatzinc/parser.yy"
2488 {
2489 if ((yyvsp[-1].annotations) != nullptr) {
2490 model->Satisfy(std::move(*(yyvsp[-1].annotations)));
2491 delete (yyvsp[-1].annotations);
2492 } else {
2493 model->Satisfy(std::vector<Annotation>());
2494 }
2495 }
2496#line 2519 "parser.tab.cc"
2497 break;
2498
2499 case 100: /* solve: SOLVE annotations MINIMIZE argument */
2500#line 756 "ortools/flatzinc/parser.yy"
2501 {
2502 Variable* obj_var = (yyvsp[0].arg).type == Argument::VAR_REF
2503 ? (yyvsp[0].arg).Var()
2504 : model->AddConstant((yyvsp[0].arg).Value());
2505 if ((yyvsp[-2].annotations) != nullptr) {
2506 model->Minimize(obj_var, std::move(*(yyvsp[-2].annotations)));
2507 delete (yyvsp[-2].annotations);
2508 } else {
2509 model->Minimize(obj_var, std::vector<Annotation>());
2510 }
2511 }
2512#line 2535 "parser.tab.cc"
2513 break;
2514
2515 case 101: /* solve: SOLVE annotations MAXIMIZE argument */
2516#line 767 "ortools/flatzinc/parser.yy"
2517 {
2518 Variable* obj_var = (yyvsp[0].arg).type == Argument::VAR_REF
2519 ? (yyvsp[0].arg).Var()
2520 : model->AddConstant((yyvsp[0].arg).Value());
2521 if ((yyvsp[-2].annotations) != nullptr) {
2522 model->Maximize(obj_var, std::move(*(yyvsp[-2].annotations)));
2523 delete (yyvsp[-2].annotations);
2524 } else {
2525 model->Maximize(obj_var, std::vector<Annotation>());
2526 }
2527 }
2528#line 2551 "parser.tab.cc"
2529 break;
2530
2531#line 2555 "parser.tab.cc"
2532
2533 default:
2534 break;
2535 }
2536 /* User semantic actions sometimes alter yychar, and that requires
2537 that yytoken be updated with the new translation. We take the
2538 approach of translating immediately before every use of yytoken.
2539 One alternative is translating here after every semantic action,
2540 but that translation would be missed if the semantic action invokes
2541 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
2542 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
2543 incorrect destructor might then be invoked immediately. In the
2544 case of YYERROR or YYBACKUP, subsequent parser actions might lead
2545 to an incorrect destructor call or verbose syntax error message
2546 before the lookahead is translated. */
2547 YY_SYMBOL_PRINT("-> $$ =", YY_CAST(yysymbol_kind_t, yyr1[yyn]), &yyval,
2548 &yyloc);
2549
2550 YYPOPSTACK(yylen);
2551 yylen = 0;
2552
2553 *++yyvsp = yyval;
2554
2555 /* Now 'shift' the result of the reduction. Determine what state
2556 that goes to, based on the state we popped back to and the rule
2557 number reduced by. */
2558 {
2559 const int yylhs = yyr1[yyn] - YYNTOKENS;
2560 const int yyi = yypgoto[yylhs] + *yyssp;
2561 yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
2562 ? yytable[yyi]
2563 : yydefgoto[yylhs]);
2564 }
2565
2566 goto yynewstate;
2567
2568/*--------------------------------------.
2569| yyerrlab -- here on detecting error. |
2570`--------------------------------------*/
2571yyerrlab:
2572 /* Make sure we have latest lookahead translation. See comments at
2573 user semantic actions for why this is necessary. */
2574 yytoken = yychar == ORFZ_EMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE(yychar);
2575 /* If not already recovering from an error, report this error. */
2576 if (!yyerrstatus) {
2577 ++yynerrs;
2578 {
2579 yypcontext_t yyctx = {yyssp, yytoken};
2580 char const* yymsgp = YY_("syntax error");
2581 int yysyntax_error_status;
2582 yysyntax_error_status = yysyntax_error(&yymsg_alloc, &yymsg, &yyctx);
2583 if (yysyntax_error_status == 0)
2584 yymsgp = yymsg;
2585 else if (yysyntax_error_status == -1) {
2586 if (yymsg != yymsgbuf) YYSTACK_FREE(yymsg);
2587 yymsg = YY_CAST(char*, YYSTACK_ALLOC(YY_CAST(YYSIZE_T, yymsg_alloc)));
2588 if (yymsg) {
2589 yysyntax_error_status = yysyntax_error(&yymsg_alloc, &yymsg, &yyctx);
2590 yymsgp = yymsg;
2591 } else {
2592 yymsg = yymsgbuf;
2593 yymsg_alloc = sizeof yymsgbuf;
2594 yysyntax_error_status = YYENOMEM;
2595 }
2596 }
2597 yyerror(context, model, ok, scanner, yymsgp);
2598 if (yysyntax_error_status == YYENOMEM) YYNOMEM;
2599 }
2600 }
2601
2602 if (yyerrstatus == 3) {
2603 /* If just tried and failed to reuse lookahead token after an
2604 error, discard it. */
2605
2606 if (yychar <= ORFZ_EOF) {
2607 /* Return failure if at end of input. */
2608 if (yychar == ORFZ_EOF) YYABORT;
2609 } else {
2610 yydestruct("Error: discarding", yytoken, &yylval, context, model, ok,
2611 scanner);
2612 yychar = ORFZ_EMPTY;
2613 }
2614 }
2615
2616 /* Else will try to reuse lookahead token after shifting the error
2617 token. */
2618 goto yyerrlab1;
2619
2620/*---------------------------------------------------.
2621| yyerrorlab -- error raised explicitly by YYERROR. |
2622`---------------------------------------------------*/
2623yyerrorlab:
2624 /* Pacify compilers when the user code never invokes YYERROR and the
2625 label yyerrorlab therefore never appears in user code. */
2626 if (0) YYERROR;
2627 ++yynerrs;
2628
2629 /* Do not reclaim the symbols of the rule whose action triggered
2630 this YYERROR. */
2631 YYPOPSTACK(yylen);
2632 yylen = 0;
2633 YY_STACK_PRINT(yyss, yyssp);
2634 yystate = *yyssp;
2635 goto yyerrlab1;
2636
2637/*-------------------------------------------------------------.
2638| yyerrlab1 -- common code for both syntax error and YYERROR. |
2639`-------------------------------------------------------------*/
2640yyerrlab1:
2641 yyerrstatus = 3; /* Each real token shifted decrements this. */
2642
2643 /* Pop stack until we find a state that shifts the error token. */
2644 for (;;) {
2645 yyn = yypact[yystate];
2646 if (!yypact_value_is_default(yyn)) {
2647 yyn += YYSYMBOL_YYerror;
2648 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror) {
2649 yyn = yytable[yyn];
2650 if (0 < yyn) break;
2651 }
2652 }
2653
2654 /* Pop the current state because it cannot handle the error token. */
2655 if (yyssp == yyss) YYABORT;
2656
2657 yydestruct("Error: popping", YY_ACCESSING_SYMBOL(yystate), yyvsp, context,
2658 model, ok, scanner);
2659 YYPOPSTACK(1);
2660 yystate = *yyssp;
2661 YY_STACK_PRINT(yyss, yyssp);
2662 }
2663
2665 *++yyvsp = yylval;
2667
2668 /* Shift the error token. */
2669 YY_SYMBOL_PRINT("Shifting", YY_ACCESSING_SYMBOL(yyn), yyvsp, yylsp);
2670
2671 yystate = yyn;
2672 goto yynewstate;
2673
2674/*-------------------------------------.
2675| yyacceptlab -- YYACCEPT comes here. |
2676`-------------------------------------*/
2677yyacceptlab:
2678 yyresult = 0;
2679 goto yyreturnlab;
2680
2681/*-----------------------------------.
2682| yyabortlab -- YYABORT comes here. |
2683`-----------------------------------*/
2684yyabortlab:
2685 yyresult = 1;
2686 goto yyreturnlab;
2687
2688/*-----------------------------------------------------------.
2689| yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. |
2690`-----------------------------------------------------------*/
2691yyexhaustedlab:
2692 yyerror(context, model, ok, scanner, YY_("memory exhausted"));
2693 yyresult = 2;
2694 goto yyreturnlab;
2695
2696/*----------------------------------------------------------.
2697| yyreturnlab -- parsing is finished, clean up and return. |
2698`----------------------------------------------------------*/
2699yyreturnlab:
2700 if (yychar != ORFZ_EMPTY) {
2701 /* Make sure we have latest lookahead translation. See comments at
2702 user semantic actions for why this is necessary. */
2703 yytoken = YYTRANSLATE(yychar);
2704 yydestruct("Cleanup: discarding lookahead", yytoken, &yylval, context,
2705 model, ok, scanner);
2706 }
2707 /* Do not reclaim the symbols of the rule whose action triggered
2708 this YYABORT or YYACCEPT. */
2709 YYPOPSTACK(yylen);
2710 YY_STACK_PRINT(yyss, yyssp);
2711 while (yyssp != yyss) {
2712 yydestruct("Cleanup: popping", YY_ACCESSING_SYMBOL(+*yyssp), yyvsp, context,
2713 model, ok, scanner);
2714 YYPOPSTACK(1);
2715 }
2716#ifndef yyoverflow
2717 if (yyss != yyssa) YYSTACK_FREE(yyss);
2718#endif
2719 if (yymsg != yymsgbuf) YYSTACK_FREE(yymsg);
2720 return yyresult;
2721}
2722
2723#line 779 "ortools/flatzinc/parser.yy"
void AddConstraint(absl::string_view id, std::vector< Argument > arguments, bool is_domain, bool symmetry, bool redundant)
Definition model.cc:1046
Variable * AddVariable(absl::string_view name, const Domain &domain, bool defined, bool set_is_fixed=false)
Definition model.cc:1020
Variable * AddFloatConstant(double value)
Definition model.cc:1039
void AddOutput(SolutionOutputSpecs output)
Definition model.cc:1058
void Maximize(Variable *obj, std::vector< Annotation > search_annotations)
Definition model.cc:1074
void Satisfy(std::vector< Annotation > search_annotations)
Definition model.cc:1062
void Minimize(Variable *obj, std::vector< Annotation > search_annotations)
Definition model.cc:1067
Variable * AddConstant(int64_t value)
Definition model.cc:1032
const T & Lookup(const std::vector< T > &v, int index)
int64_t ConvertAsIntegerOrDie(double d)
static const char * yysymbol_name(yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED
static YYPTRDIFF_T yystrlen(const char *yystr)
const T & Lookup(const std::vector< T > &v, int index)
#define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
#define YYMAXDEPTH
static void yydestruct(const char *yymsg, yysymbol_kind_t yykind, YYSTYPE *yyvaluep, operations_research::fz::ParserContext *context, operations_research::fz::Model *model, bool *ok, void *scanner)
#define YYSTACK_FREE
static const yytype_int8 yytranslate[]
yysymbol_kind_t
Definition parser.tab.cc:98
@ YYSYMBOL_integer
@ YYSYMBOL_25_
@ YYSYMBOL_YYUNDEF
@ YYSYMBOL_const_literals
@ YYSYMBOL_optional_var_or_value_array
@ YYSYMBOL_float_domain
@ YYSYMBOL_var_or_value_array
@ YYSYMBOL_var_or_value
@ YYSYMBOL_DVALUE
@ YYSYMBOL_SVALUE
@ YYSYMBOL_26_
@ YYSYMBOL_YYerror
@ YYSYMBOL_SET
@ YYSYMBOL_IVALUE
@ YYSYMBOL_predicate
@ YYSYMBOL_SATISFY
@ YYSYMBOL_29_
@ YYSYMBOL_TOKEN_FLOAT
@ YYSYMBOL_28_
@ YYSYMBOL_variable_or_constant_declarations
@ YYSYMBOL_annotation
@ YYSYMBOL_predicate_arguments
@ YYSYMBOL_constraints
@ YYSYMBOL_variable_or_constant_declaration
@ YYSYMBOL_annotations
@ YYSYMBOL_floats
@ YYSYMBOL_model
@ YYSYMBOL_integers
@ YYSYMBOL_solve
@ YYSYMBOL_arguments
@ YYSYMBOL_optional_var_or_value
@ YYSYMBOL_predicate_array_argument
@ YYSYMBOL_annotation_arguments
@ YYSYMBOL_DOTDOT
@ YYSYMBOL_TOKEN_INT
@ YYSYMBOL_VAR
@ YYSYMBOL_set_domain
@ YYSYMBOL_TOKEN_BOOL
@ YYSYMBOL_constraint
@ YYSYMBOL_MINIMIZE
@ YYSYMBOL_ARRAY
@ YYSYMBOL_float
@ YYSYMBOL_predicate_argument
@ YYSYMBOL_COLONCOLON
@ YYSYMBOL_const_literal
@ YYSYMBOL_predicate_ints
@ YYSYMBOL_YYACCEPT
@ YYSYMBOL_30_
@ YYSYMBOL_23_
@ YYSYMBOL_domain
@ YYSYMBOL_YYEOF
@ YYSYMBOL_OF
@ YYSYMBOL_22_
@ YYSYMBOL_24_
@ YYSYMBOL_27_
@ YYSYMBOL_argument
@ YYSYMBOL_YYEMPTY
Definition parser.tab.cc:99
@ YYSYMBOL_IDENTIFIER
@ YYSYMBOL_predicates
@ YYSYMBOL_int_domain
@ YYSYMBOL_PREDICATE
@ YYSYMBOL_31_
@ YYSYMBOL_CONSTRAINT
@ YYSYMBOL_MAXIMIZE
@ YYSYMBOL_SOLVE
#define yyerrok
#define YY_ASSERT(E)
#define YY_(Msgid)
#define YYNOMEM
#define YY_IGNORE_MAYBE_UNINITIALIZED_END
static const yytype_int8 yydefact[]
#define YYNSTATES
#define YYSTYPE
Definition parser.tab.cc:67
#define YY_IGNORE_USELESS_CAST_END
short yytype_int16
#define YYABORT
#define YYSTACK_BYTES(N)
yytype_uint8 yy_state_t
#define YY_REDUCE_PRINT(Rule)
#define YY_CAST(Type, Val)
Definition parser.tab.cc:80
static const yytype_int16 yypact[]
#define yylex
Definition parser.tab.cc:70
#define YYCASE_(N, S)
static const yytype_uint8 yydefgoto[]
#define YY_NULLPTR
Definition parser.tab.cc:92
#define YYFINAL
#define YY_ACCESSING_SYMBOL(State)
#define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
static const yytype_int16 yypgoto[]
#define YY_INITIAL_VALUE(Value)
static YYPTRDIFF_T yytnamerr(char *yyres, const char *yystr)
#define yyparse
Definition parser.tab.cc:69
#define YYNTOKENS
unsigned char yytype_uint8
#define YY_STACK_PRINT(Bottom, Top)
#define YYSIZE_T
#define YYSTACK_ALLOC_MAXIMUM
#define yydebug
Definition parser.tab.cc:72
#define YY_IGNORE_USELESS_CAST_BEGIN
static const yytype_int8 yyr2[]
void * malloc(YYSIZE_T)
#define YYPTRDIFF_T
#define yynerrs
Definition parser.tab.cc:73
static const yytype_int16 yytable[]
#define YYACCEPT
#define yytable_value_is_error(Yyn)
@ YYENOMEM
#define YYTRANSLATE(YYX)
static const yytype_int8 yystos[]
#define YY_ATTRIBUTE_UNUSED
static const char *const yytname[]
static int yypcontext_expected_tokens(const yypcontext_t *yyctx, yysymbol_kind_t yyarg[], int yyargn)
static const yytype_int8 yyr1[]
static char * yystpcpy(char *yydest, const char *yysrc)
#define YYPOPSTACK(N)
int yy_state_fast_t
unsigned short yytype_uint16
#define YYLAST
#define YYSTACK_RELOCATE(Stack_alloc, Stack)
#define yypact_value_is_default(Yyn)
#define YYINITDEPTH
static int yy_syntax_error_arguments(const yypcontext_t *yyctx, yysymbol_kind_t yyarg[], int yyargn)
signed char yytype_int8
void free(void *)
#define YYERROR
#define YYSIZEOF(X)
static const yytype_int16 yycheck[]
#define YYSTACK_ALLOC
#define YYDPRINTF(Args)
#define YY_USE(E)
#define yyerror
Definition parser.tab.cc:71
static int yysyntax_error(YYPTRDIFF_T *yymsg_alloc, char **yymsg, const yypcontext_t *yyctx)
@ ORFZ_UNDEF
Definition parser.tab.hh:82
@ ORFZ_EMPTY
Definition parser.tab.hh:79
@ ORFZ_EOF
Definition parser.tab.hh:80
@ ORFZ_error
Definition parser.tab.hh:81
#define yylval
Definition parser.yy.cc:782
#define yyalloc
Definition parser.yy.cc:237
static Annotation String(absl::string_view str)
Definition model.cc:920
static Annotation FunctionCall(absl::string_view id)
Definition model.cc:870
static Annotation FunctionCallWithArguments(absl::string_view id, std::vector< Annotation > args)
Definition model.cc:859
static Annotation Empty()
Definition model.cc:833
static Annotation AnnotationList(std::vector< Annotation > list)
Definition model.cc:841
static Annotation IntegerList(const std::vector< int64_t > &values)
Definition model.cc:894
static Annotation VarRefArray(std::vector< Variable * > variables)
Definition model.cc:911
static Annotation Identifier(absl::string_view id)
Definition model.cc:850
@ ANNOTATION_LIST
Definition model.h:267
@ INT_VALUE
Definition model.h:270
@ INTERVAL
Definition model.h:272
@ VAR_REF
Definition model.h:273
static Annotation VarRef(Variable *var)
Definition model.cc:902
static Annotation IntegerValue(int64_t value)
Definition model.cc:887
static Annotation Interval(int64_t interval_min, int64_t interval_max)
Definition model.cc:879
static Argument FloatList(std::vector< double > floats)
Definition model.cc:582
static Argument FloatValue(double value)
Definition model.cc:567
static Argument VoidArgument()
Definition model.cc:548
static Argument IntegerValue(int64_t value)
Definition model.cc:505
static Argument Interval(int64_t imin, int64_t imax)
Definition model.cc:512
static Argument FromDomain(const Domain &domain)
Definition model.cc:554
static Argument IntegerList(std::vector< int64_t > values)
Definition model.cc:520
static Argument VarRef(Variable *var)
Definition model.cc:534
static Argument DomainList(std::vector< Domain > domains)
Definition model.cc:527
static Argument VarRefArray(std::vector< Variable * > vars)
Definition model.cc:541
@ VAR_REF
Definition model.h:164
static Domain Boolean()
Definition model.cc:67
static Domain AllFloats()
Definition model.cc:107
static Domain IntegerList(std::vector< int64_t > values)
Definition model.cc:40
static Domain IntegerValue(int64_t value)
Definition model.cc:53
static Domain FloatValue(double value)
Definition model.cc:122
static Domain EmptyDomain()
Definition model.cc:105
static Domain FloatInterval(double lb, double ub)
Definition model.cc:114
static Domain SetOfBoolean()
Definition model.cc:99
static Domain Interval(int64_t included_min, int64_t included_max)
Definition model.cc:59
static Domain SetOfAllInt64()
Definition model.cc:81
static Domain SetOfInterval(int64_t included_min, int64_t included_max)
Definition model.cc:93
static Domain SetOfIntegerList(std::vector< int64_t > values)
Definition model.cc:75
static Domain AllInt64()
Definition model.cc:47
static SolutionOutputSpecs MultiDimensionalArray(absl::string_view name, std::vector< Bounds > bounds, std::vector< Variable * > flat_variables, bool display_as_boolean)
Definition model.cc:984
static SolutionOutputSpecs SingleVariable(absl::string_view name, Variable *variable, bool display_as_boolean)
Definition model.cc:975
static VarRefOrValue VarRef(Variable *var)
Definition parser_util.h:46
static VarRefOrValue DomainValue(Domain domain)
Definition parser_util.h:58
static VarRefOrValue FloatValue(double value)
Definition parser_util.h:65
static VarRefOrValue Undefined()
Definition parser_util.h:45
static VarRefOrValue Value(int64_t value)
Definition parser_util.h:52
bool IsFunctionCallWithIdentifier(absl::string_view identifier) const
Definition model.h:292
std::vector< Annotation > annotations
Definition model.h:304
std::vector< int64_t > values
Definition model.h:106
bool Contains(int64_t value) const
Definition model.cc:363
std::vector< double > * doubles
Definition parser_util.h:93
std::vector< Annotation > * annotations
Definition parser_util.h:97
std::vector< int64_t > * integers
Definition parser_util.h:92
std::vector< Domain > * domains
Definition parser_util.h:91
std::vector< Argument > * args
Definition parser_util.h:95
std::vector< VarRefOrValue > * var_or_value_array
Definition parser_util.h:99
absl::flat_hash_map< std::string, std::vector< Variable * > > variable_array_map
Definition parser_util.h:36
absl::flat_hash_map< std::string, Domain > domain_map
Definition parser_util.h:37
absl::flat_hash_map< std::string, int64_t > integer_map
Definition parser_util.h:31
absl::flat_hash_map< std::string, std::vector< double > > float_array_map
Definition parser_util.h:34
absl::flat_hash_map< std::string, Variable * > variable_map
Definition parser_util.h:35
absl::flat_hash_map< std::string, std::vector< Domain > > domain_array_map
Definition parser_util.h:38
absl::flat_hash_map< std::string, double > float_map
Definition parser_util.h:33
absl::flat_hash_map< std::string, std::vector< int64_t > > integer_array_map
Definition parser_util.h:32
bool Merge(absl::string_view other_name, const Domain &other_domain, bool other_temporary)
Definition model.cc:783
yysymbol_kind_t yytoken
yy_state_t * yyssp
YYSTYPE yyvs_alloc
yy_state_t yyss_alloc