Generated on for Gecode by doxygen 1.18.0
impl.hpp
Go to the documentation of this file.
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2/*
3 * Main authors:
4 * Mikael Zayenz Lagerkvist <lagerkvist@gecode.dev>
5 *
6 * Copyright:
7 * Mikael Zayenz Lagerkvist, 2026
8 *
9 * This file is part of Gecode, the generic constraint
10 * development environment:
11 * http://www.gecode.dev
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining
14 * a copy of this software and associated documentation files (the
15 * "Software"), to deal in the Software without restriction, including
16 * without limitation the rights to use, copy, modify, merge, publish,
17 * distribute, sublicense, and/or sell copies of the Software, and to
18 * permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be
22 * included in all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 *
32 */
33
34/*
35 * Internal declarations shared by the implementation files of the
36 * instance module. Not part of the public interface.
37 */
38
39#ifndef GECODE_INSTANCE_IMPL_HPP
40#define GECODE_INSTANCE_IMPL_HPP
41
42#include <gecode/instance.hh>
43
44#include <climits>
45#include <new>
46#include <utility>
47
48namespace Gecode { namespace Instance {
49
50 /*
51 * Character classes and number syntax, ASCII only and independent of the
52 * global locale
53 */
54
56 inline bool is_digit(char c) {
57 return (c >= '0') && (c <= '9');
58 }
59
60 inline bool is_letter(char c) {
61 return ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'));
62 }
63
64 inline bool is_alnum(char c) {
65 return is_digit(c) || is_letter(c) || (c == '_');
66 }
67
68 inline bool is_space(char c) {
69 return (c == ' ') || (c == '\t') || (c == '\n') || (c == '\r') || (c == '\v') || (c == '\f');
70 }
71
72 inline bool is_blank(char c) {
73 return (c == ' ') || (c == '\t') || (c == '\r');
74 }
75
76 inline bool is_sign(char c) {
77 return (c == '+') || (c == '-');
78 }
79
80 inline bool is_exponent(char c) {
81 return (c == 'e') || (c == 'E');
82 }
83
90 inline size_t number_end(const std::string& s, size_t p, bool sign, bool real) {
91 size_t q = p;
92 for (; q < s.size(); q++) {
93 char c = s[q];
94 if (is_digit(c))
95 continue;
96 if (sign && (q == p) && is_sign(c))
97 continue;
98 if (real && ((c == '.') || is_exponent(c)))
99 continue;
100 if (real && (q > p) && is_sign(c) && is_exponent(s[q-1]))
101 continue;
102 break;
103 }
104 return q;
105 }
106
107 bool parse_int(const std::string& t, long long int& v);
109 bool parse_float(const std::string& t, double& v);
110
117 template<class T>
118 class Seq {
119 private:
121 T* x;
123 int n;
125 int cap;
127 void grow(int m) {
128 // Doubling, computed without overflow
129 long long int d = std::min(2LL*cap, static_cast<long long int>(INT_MAX));
130 int c = std::max(std::max(m, static_cast<int>(d)), 2);
131 T* y = static_cast<T*>(heap.ralloc(sizeof(T)*static_cast<size_t>(c)));
132 for (int i=0; i<n; i++) {
133 new (&y[i]) T(std::move(x[i]));
134 x[i].~T();
135 }
136 if (x != nullptr)
137 heap.rfree(x);
138 x = y; cap = c;
139 }
140 public:
142 Seq(void)
143 : x(nullptr), n(0), cap(0) {}
144
145 Seq(const Seq& s)
146 : Seq() {
147 // Delegating, so that the destructor runs if a copy throws
148 reserve(s.n);
149 for (int i=0; i<s.n; i++)
150 push(s.x[i]);
151 }
152
153 Seq(Seq&& s) noexcept : x(s.x), n(s.n), cap(s.cap) {
154 s.x = nullptr; s.n = 0; s.cap = 0;
155 }
156
157 Seq& operator =(Seq s) noexcept {
158 std::swap(x,s.x); std::swap(n,s.n); std::swap(cap,s.cap);
159 return *this;
160 }
161
162 ~Seq(void) {
163 clear();
164 if (x != nullptr)
165 heap.rfree(x);
166 }
167
168 int size(void) const { return n; }
170 bool empty(void) const { return n == 0; }
172 void reserve(int m) {
173 if (m > cap) grow(m);
174 }
175
176 void push(const T& v) {
177 if (n == cap) {
178 T t(v);
179 grow(n+1);
180 new (&x[n]) T(std::move(t));
181 } else {
182 new (&x[n]) T(v);
183 }
184 n++;
185 }
186
187 void push(T&& v) {
188 if (n == cap) {
189 T t(std::move(v));
190 grow(n+1);
191 new (&x[n]) T(std::move(t));
192 } else {
193 new (&x[n]) T(std::move(v));
194 }
195 n++;
196 }
197
198 void pop(void) {
199 assert(n > 0);
200 x[--n].~T();
201 }
202
203 void clear(void) {
204 while (n > 0)
205 x[--n].~T();
206 }
207
208 T& operator [](int i) {
209 assert((i >= 0) && (i < n));
210 return x[i];
211 }
212
213 const T& operator [](int i) const {
214 assert((i >= 0) && (i < n));
215 return x[i];
216 }
217
218 T& back(void) {
219 assert(n > 0);
220 return x[n-1];
221 }
222
223 const T& back(void) const {
224 assert(n > 0);
225 return x[n-1];
226 }
227
228 T* begin(void) { return x; }
230 T* end(void) { return x+n; }
232 const T* begin(void) const { return x; }
234 const T* end(void) const { return x+n; }
235 };
236
239 public:
241 std::string msg;
243 explicit ShapeError(const std::string& m) : msg(m) {}
244 };
245
255 class Value {
256 public:
260 int depth;
271
273 Value(void)
274 : type(ValueType::INT), depth(1) {
276 lengths[0].push(0);
277 }
278
279 explicit Value(ValueType t)
280 : type(t), depth(0) {}
281
282 static Value integer(long long int v) {
283 Value x(ValueType::INT); x.ints.push(v);
284 return x;
285 }
286
287 static Value real(double v) {
289 return x;
290 }
291
292 static Value string(const std::string& v) {
294 return x;
295 }
296
298 bool is_scalar(void) const { return depth == 0; }
300 bool is_number(void) const { return (depth == 0) && (type != ValueType::STRING); }
302 int leaves(void) const {
303 switch (type) {
304 case ValueType::INT: return ints.size();
305 case ValueType::FLOAT: return reals.size();
306 default: return strs.size();
307 }
308 }
309
310 int size(void) const { return depth == 0 ? 0 : lengths[0][0]; }
312 double as_double(int i=0) const {
313 return type == ValueType::INT ? static_cast<double>(ints[i]) : reals[i];
314 }
315
316 void to_float(void) {
317 if (type != ValueType::INT) return;
318 for (long long int v : ints)
319 reals.push(static_cast<double>(v));
320 ints.clear();
322 }
323
324 void push(const Value& s) {
325 if (leaves() == 0) {
326 type = s.type;
327 } else if ((type == ValueType::STRING) != (s.type == ValueType::STRING)) {
328 throw ShapeError("strings and numbers are mixed");
329 } else if ((type == ValueType::INT) && (s.type == ValueType::FLOAT)) {
330 to_float();
331 }
332 switch (s.type) {
333 case ValueType::INT:
334 if (type == ValueType::INT) ints.push(s.ints[0]);
335 else reals.push(static_cast<double>(s.ints[0]));
336 break;
337 case ValueType::FLOAT: reals.push(s.reals[0]); break;
338 default: strs.push(s.strs[0]); break;
339 }
340 }
341
342 bool is_empty_list(void) const { return (depth > 0) && (lengths[0][0] == 0); }
345 type = t;
346 depth = 1;
347 ints.clear(); reals.clear(); strs.clear();
348 while (lengths.size() > 1)
349 lengths.pop();
350 if (lengths.empty())
352 lengths[0].clear();
353 lengths[0].push(0);
354 }
355
357 void index(void);
359 void range(int level, int pos, int& from, int& to) const;
360 };
361
374 class Column {
375 private:
377 Value c;
379 int rows;
381 int pending;
383 bool started;
385 bool missing;
387 int d;
388 public:
390 Column(ValueType t, int depth);
392 void add(Value& v);
394 void skip(void);
397 };
398
400 class Entry {
401 public:
403 std::string name;
407 Entry(void) {}
409 Entry(const std::string& n, Value&& v)
410 : name(n), value(std::move(v)) {}
411 };
412
414 class DataImpl {
415 public:
419 const Value* find(const std::string& n) const {
420 for (const Entry& e : entries)
421 if (e.name == n)
422 return &e.value;
423 return nullptr;
424 }
425 };
426
435
436 /*
437 * Spec syntax tree
438 */
439
440 class Stmt;
441
453 class Expr {
454 public:
456 enum class Kind { INT, FLOAT, STR, NAME, BINARY, UNARY, CALL, INDEX, FIELD, COMPREHENSION } kind;
458 enum class Op {
459 OR, AND, EQ, NE, LT, GT, LE, GE, ADD, SUB, MUL, DIV, MOD, POW, NEG, NOT
460 } op;
462 long long int i;
464 double f;
466 std::string s;
468 std::string var;
472 const Stmt* records;
474 int open;
481 explicit Expr(Kind k)
482 : kind(k), op(Op::OR), i(0), f(0.0), record(-1), records(nullptr), open(0), elements(nullptr) {}
483 };
484
492 class Record {
493 public:
495 std::string name;
497 std::string label;
501 std::string starts;
502 };
503
511 inline std::string record_starts(int id) {
512 return "#" + std::to_string(id);
513 }
514
515 inline bool is_internal(const std::string& n) {
516 return !n.empty() && (n[0] == '#');
517 }
518
528
538 class Type {
539 public:
543 std::unique_ptr<Expr> lo;
545 std::unique_ptr<Expr> hi;
549 const Stmt* named;
551 std::string name;
553 std::string alphabet;
555 std::string blank;
557 std::string strip;
559 long long int base;
562 : read(r), exclusive(false), named(nullptr), base(1) {}
563
564 bool ranged(void) const {
565 return (lo != nullptr) || (hi != nullptr) || (named != nullptr);
566 }
567
568 Type use(const Stmt* d) const {
569 Type t(read);
570 t.named = d;
571 t.alphabet = alphabet;
572 t.blank = blank;
573 t.strip = strip;
574 t.base = base;
575 return t;
576 }
577 };
578
580 class Pattern {
581 public:
583 class Item {
584 public:
586 enum class Kind { LIT, SPACE, CAP, ANY, VAR } kind;
588 std::string text;
594 explicit Item(Kind k) : kind(k), required(false) {}
595 };
596
597 std::string source;
600 };
601
604
606 class Arm {
607 public:
615 bool last;
617 Arm(void)
618 : optional(false), last(false) {}
619 };
620
622 class Stmt {
623 public:
625 enum class Kind {
626 COMMENT, STOP, TOKENS, SEPARATORS, TRAILING, PARAM, READ, LIST,
627 LINE, FIND, SKIP, EXPECT, INDEX, REPEAT, SECTIONS, IF, LET, CHECK,
628 TYPE, INSTANCES, EACH
631 int line;
636 std::string name;
638 std::string chars;
640 std::string message;
642 std::string store;
644 std::string list;
646 std::string each;
650 std::unique_ptr<Expr> expr;
652 std::unique_ptr<Expr> sentinel;
654 std::unique_ptr<Expr> offset;
674 int id;
678 Stmt(Kind k, int l)
679 : kind(k), line(l), until_eol(false), until_eof(false), has_until(false), skip_other(false), id(0) {}
680 };
681
683 class Decl {
684 public:
686 std::string name;
690 int depth;
691 };
692
693 void declared(const Block& b, Seq<Decl>& out);
694
696 [[noreturn]] void fail_at(const std::string& origin, int line, const std::string& m);
697
706 void resolve(Block& b, const std::string& origin);
707
709 class SpecImpl {
710 public:
712 std::string origin;
714 std::string name;
718 SpecImpl(const std::string& text, const std::string& origin);
725 Data read(const std::string& input, const std::string& origin, const Params& p, bool catalog) const;
726 };
727
729 std::string read_file(const std::string& path);
730
731}}
732
733#endif
734
735// STATISTICS: instance-any
void rfree(void *p)
Free memory block starting at p.
Definition heap.hpp:378
void * ralloc(size_t s)
Allocate s bytes from heap.
Definition heap.hpp:361
Arm(void)
Initialize.
Definition impl.hpp:617
Block body
Statements run after the line matched.
Definition impl.hpp:611
Pattern pattern
Line pattern.
Definition impl.hpp:609
bool last
Whether the sections statement ends after this arm.
Definition impl.hpp:615
bool optional
Whether the input may lack a line matching the arm.
Definition impl.hpp:613
Column(ValueType t, int depth)
Empty column for rows of type t and depth depth.
void skip(void)
Add a missing row.
Value finish(void)
Return the array.
void add(Value &v)
Add a row v; throws ShapeError with a phrase completing the name.
Implementation of Data.
Definition impl.hpp:414
Seq< Entry > entries
The entries in definition order.
Definition impl.hpp:417
const Value * find(const std::string &n) const
Return entry n or null.
Definition impl.hpp:419
Named values read from an instance.
Definition instance.hh:406
A name that a block may define, with the type and depth of its values.
Definition impl.hpp:683
std::string name
Name.
Definition impl.hpp:686
ValueType type
Type of the leaves.
Definition impl.hpp:688
A named value.
Definition impl.hpp:400
Entry(void)
Initialize as the empty integer list without a name.
Definition impl.hpp:407
std::string name
Name.
Definition impl.hpp:403
Value value
Value.
Definition impl.hpp:405
Entry(const std::string &n, Value &&v)
Initialize as v named n.
Definition impl.hpp:409
Op
Operator of unary and binary expressions.
Definition impl.hpp:458
const Stmt * elements
For a comprehension, the repeat whose records are the elements of its array, or null.
Definition impl.hpp:477
std::string var
Name bound by a comprehension.
Definition impl.hpp:468
long long int i
Integer literal.
Definition impl.hpp:462
std::string s
String literal, name, operator, or function.
Definition impl.hpp:466
int open
1 for a list of records of records, 0 for a record
Definition impl.hpp:474
double f
Float literal.
Definition impl.hpp:464
enum Gecode::Instance::Expr::Kind kind
int record
Index of a record name among the records of its check (-1 if none).
Definition impl.hpp:470
Kind
Kind of expression.
Definition impl.hpp:456
Seq< std::unique_ptr< Expr > > args
Operands or arguments.
Definition impl.hpp:479
const Stmt * records
The repeat whose records or lists of records this is, or null.
Definition impl.hpp:472
Expr(Kind k)
Initialize with kind k.
Definition impl.hpp:481
enum Gecode::Instance::Expr::Op op
Implementation of Params.
Definition impl.hpp:428
Seq< std::string > names
Names.
Definition impl.hpp:431
Seq< std::string > values
Values.
Definition impl.hpp:433
Values for the param statements of a spec.
Definition instance.hh:364
std::string text
Literal text, capture name, or variable name.
Definition impl.hpp:588
enum Gecode::Instance::Pattern::Item::Kind kind
bool required
Whether a space item needs at least one blank.
Definition impl.hpp:592
Type type
What a capture reads.
Definition impl.hpp:590
Item(Kind k)
Initialize with kind k.
Definition impl.hpp:594
Line pattern such as "DIMENSION : {n:int}".
Definition impl.hpp:580
Seq< Item > items
Items.
Definition impl.hpp:599
std::string source
Source text.
Definition impl.hpp:597
A record name of a check.
Definition impl.hpp:492
std::string name
The name of the values.
Definition impl.hpp:495
std::string label
The name in messages: the name, or the list of records.
Definition impl.hpp:497
Seq< const Stmt * > repeats
The repeats between the check and the definition, outermost first.
Definition impl.hpp:499
std::string starts
Name of the record starts of the innermost of these repeats.
Definition impl.hpp:501
Growable array on the Gecode heap.
Definition impl.hpp:118
Seq & operator=(Seq s) noexcept
Assign elements of s.
Definition impl.hpp:157
Seq(const Seq &s)
Copy elements of s.
Definition impl.hpp:145
bool empty(void) const
Test whether empty.
Definition impl.hpp:170
~Seq(void)
Release memory.
Definition impl.hpp:162
const T & back(void) const
Return last element.
Definition impl.hpp:223
void push(const std::unique_ptr< Stmt > &v)
Definition impl.hpp:176
Seq(Seq &&s) noexcept
Take elements of s.
Definition impl.hpp:153
T * end(void)
Iteration support.
Definition impl.hpp:230
int size(void) const
Return number of elements.
Definition impl.hpp:168
Seq(void)
Empty array.
Definition impl.hpp:142
T * begin(void)
Iteration support.
Definition impl.hpp:228
const T * end(void) const
Iteration support.
Definition impl.hpp:234
const T * begin(void) const
Iteration support.
Definition impl.hpp:232
T & operator[](int i)
Return element i.
Definition impl.hpp:208
void pop(void)
Remove last element.
Definition impl.hpp:198
T & back(void)
Return last element.
Definition impl.hpp:218
void push(T &&v)
Append v.
Definition impl.hpp:187
ShapeError(const std::string &m)
Initialize with message m.
Definition impl.hpp:243
std::string msg
Message.
Definition impl.hpp:241
SpecImpl(const std::string &text, const std::string &origin)
Parse text from origin.
Block body
Statements.
Definition impl.hpp:716
std::string name
Format name.
Definition impl.hpp:714
Data read(const std::string &input, const std::string &origin, const Params &p, bool catalog) const
Read input from origin.
std::string origin
Where the spec comes from.
Definition impl.hpp:712
bool until_eof
Repeat until end of input.
Definition impl.hpp:660
bool has_until
Repeat or sections end at a token from words.
Definition impl.hpp:662
Seq< Record > records
Record names of a check.
Definition impl.hpp:676
bool skip_other
Sections skip unknown lines.
Definition impl.hpp:664
enum Gecode::Instance::Stmt::Kind kind
std::string message
Message of a check statement.
Definition impl.hpp:640
std::string chars
Characters for tokens and separators statements.
Definition impl.hpp:638
bool until_eol
List ends at end of line.
Definition impl.hpp:658
Stmt(Kind k, int l)
Initialize with kind k at spec line l.
Definition impl.hpp:678
Kind
Kind of statement.
Definition impl.hpp:625
std::string each
Name of each record of a repeat, inside and after it.
Definition impl.hpp:646
Block orelse
Else-branch.
Definition impl.hpp:670
std::string store
Name for the terminating token found.
Definition impl.hpp:642
std::unique_ptr< Expr > offset
Added to every number read.
Definition impl.hpp:654
int id
Number of a repeat, in the order of the spec.
Definition impl.hpp:674
int line
Line in the spec.
Definition impl.hpp:631
Pattern pattern
Pattern for line and find.
Definition impl.hpp:666
std::unique_ptr< Expr > sentinel
List terminator.
Definition impl.hpp:652
Seq< Arm > arms
Arms of sections.
Definition impl.hpp:672
std::string name
Name defined.
Definition impl.hpp:636
Block body
Body, then-branch.
Definition impl.hpp:668
Seq< std::unique_ptr< Expr > > dims
Array dimensions.
Definition impl.hpp:648
Type type
What read and list statements read, or the type a type statement defines.
Definition impl.hpp:634
std::string list
Name of the list of records of a repeat.
Definition impl.hpp:644
Seq< std::string > words
Prefixes, literal tokens, or terminating tokens.
Definition impl.hpp:656
std::unique_ptr< Expr > expr
Count, condition, layout, value, or default.
Definition impl.hpp:650
Type of the values that a declaration or a capture reads.
Definition impl.hpp:538
bool ranged(void) const
Test whether the type has a range, possibly through its name.
Definition impl.hpp:564
std::unique_ptr< Expr > lo
Lower bound of a range, or null.
Definition impl.hpp:543
const Stmt * named
The type statement defining a named type, or null.
Definition impl.hpp:549
std::string blank
Symbols that stand for 0.
Definition impl.hpp:555
Type use(const Stmt *d) const
Return a use of the type defined by type statement d.
Definition impl.hpp:568
bool exclusive
Whether the upper bound is excluded.
Definition impl.hpp:547
std::string name
Name of a named type.
Definition impl.hpp:551
ReadType read
What the type reads.
Definition impl.hpp:541
std::string alphabet
Symbols of an alphabet type.
Definition impl.hpp:553
std::string strip
Symbols to skip.
Definition impl.hpp:557
long long int base
Value of the first symbol.
Definition impl.hpp:559
std::unique_ptr< Expr > hi
Upper bound of a range, or null.
Definition impl.hpp:545
Type(ReadType r=ReadType::INT)
Initialize as r.
Definition impl.hpp:561
A value: scalar or nested (possibly ragged) array.
Definition impl.hpp:255
int leaves(void) const
Return number of leaves.
Definition impl.hpp:302
ValueType type
Type of the leaves.
Definition impl.hpp:258
void to_float(void)
Convert integer leaves to floats.
Definition impl.hpp:316
static Value real(double v)
Float scalar.
Definition impl.hpp:287
Seq< long long int > ints
Integer leaves.
Definition impl.hpp:266
void push(const Value &s)
Append the value of scalar s, adapting the type.
Definition impl.hpp:324
static Value string(const std::string &v)
String scalar.
Definition impl.hpp:292
Value(void)
The empty integer list.
Definition impl.hpp:273
Seq< std::string > strs
String leaves.
Definition impl.hpp:270
void range(int level, int pos, int &from, int &to) const
Find leaf range of list pos at level level.
double as_double(int i=0) const
Return value of numeric scalar or leaf i as a double.
Definition impl.hpp:312
bool is_number(void) const
Test whether numeric scalar.
Definition impl.hpp:300
Seq< Seq< int > > starts
Start of each list among the lists or leaves one level down (see index).
Definition impl.hpp:264
bool is_scalar(void) const
Test whether scalar.
Definition impl.hpp:298
Seq< Seq< int > > lengths
List lengths per level.
Definition impl.hpp:262
Value(ValueType t)
Scalar of type t whose leaf is still to be added.
Definition impl.hpp:279
int depth
Nesting depth (0 for scalars).
Definition impl.hpp:260
void index(void)
Compute starts, needed by range.
void clear_list(ValueType t)
Make this the empty list of type t, keeping the memory for reuse.
Definition impl.hpp:344
Seq< double > reals
Float leaves.
Definition impl.hpp:268
bool is_empty_list(void) const
Test whether this is an empty list.
Definition impl.hpp:342
int size(void) const
Return length of outermost list.
Definition impl.hpp:310
static Value integer(long long int v)
Integer scalar.
Definition impl.hpp:282
Heap heap
The single global heap.
Reading instance files described by reader specs.
void resolve(Block &b, const std::string &origin)
Resolve the names in the expressions of b, the body of a spec from origin.
ValueType
Type of the values in a data entry.
Definition instance.hh:349
@ FLOAT
Floating point numbers.
Definition instance.hh:351
bool is_digit(char c)
Test whether c is a digit.
Definition impl.hpp:56
std::string record_starts(int id)
Return the name of the record starts of the repeat numbered id.
Definition impl.hpp:511
bool parse_float(const std::string &t, double &v)
Parse decimal float t into v, and return whether it is one.
std::string read_file(const std::string &path)
Read file path into a string.
void declared(const Block &b, Seq< Decl > &out)
Add the names that block b may define to out.
bool is_space(char c)
Test whether c is white space.
Definition impl.hpp:68
ReadType
What a declaration or a capture reads.
Definition impl.hpp:520
@ NUM
An integer if possible, otherwise a float.
Definition impl.hpp:523
@ REST
The rest of the line as a string.
Definition impl.hpp:525
@ SYMBOL
A character of an alphabet, as an integer.
Definition impl.hpp:526
@ WORD
A token as a string.
Definition impl.hpp:524
bool is_alnum(char c)
Test whether c can occur in a name.
Definition impl.hpp:64
bool parse_int(const std::string &t, long long int &v)
Parse decimal integer t into v, and return whether it is one.
size_t number_end(const std::string &s, size_t p, bool sign, bool real)
Return where the number starting at position p of s ends.
Definition impl.hpp:90
void fail_at(const std::string &origin, int line, const std::string &m)
Throw an error with message m for line line of the spec from origin.
bool is_exponent(char c)
Test whether c starts the exponent of a float.
Definition impl.hpp:80
bool is_letter(char c)
Test whether c is a letter.
Definition impl.hpp:60
bool is_blank(char c)
Test whether c is white space within a line.
Definition impl.hpp:72
Seq< std::unique_ptr< Stmt > > Block
Sequence of statements.
Definition impl.hpp:603
bool is_sign(char c)
Test whether c is a sign.
Definition impl.hpp:76
bool is_internal(const std::string &n)
Test whether n is a name used internally (see record_starts).
Definition impl.hpp:515
Gecode toplevel namespace
void path(Home home, const IntVarArgs &x, IntVar s, IntVar e, IntPropLevel ipl=IPL_DEF)
Post propagator such that x forms a Hamiltonian path.