Evaluator of the expressions of a spec on an input. More...
#include <gecode/instance/eval.hpp>
Public Member Functions | |
| Evaluator (const SpecImpl &s, const std::string &text, const std::string &origin) | |
| Initialize for spec s and input text from origin. | |
Protected Member Functions | |
| std::string | located (const std::string &msg) |
| Return the error message msg with the location and context. | |
| std::string | located (const std::string &msg, const Place &at) |
| Return the error message msg at at with the context. | |
| void | fail (const std::string &msg) |
| Throw an error with message msg at the current position. | |
| void | fail (const ShapeError &e, const std::string &n) |
| Throw an error for the shape error e of the value of n. | |
| void | visit (long long int k) |
| Account for visiting k values in expressions. | |
| void | set (const std::string &n, Value &&v) |
| Define n as v in the innermost frame. | |
| const Value * | lookup (const std::string &n) const |
| Return the value of n, or null if it is not defined. | |
| const Value & | ref (const Expr &e, Value &tmp) |
| Evaluate e, avoiding a copy for names. | |
| Seq< int > | record_path (int i) const |
| Return the indices of the record at of the check that select the records of its record name i. | |
| const Value & | starts (const Stmt *r, const std::string &n) |
| Return the record starts of repeat r, failing for n if the repeat has not run yet. | |
| int | count_records (const RecordRef &l) |
| Return the number of records in list l. | |
| size_t | record_start (const RecordRef &l, int i) |
| Return where record i of list l starts in the input, or npos. | |
| RecordRef | records_of (const Expr &e) |
| Evaluate e, a record or a list of records. | |
| const Value & | field (const Expr &e, Value &tmp) |
| Evaluate field e of a record or a list of records. | |
| long long int | integer (const Value &v, const std::string &op) |
| Return the integer of single value v, or fail for op. | |
| Value | eval (const Expr &e) |
| Evaluate e, keeping why only if e explains it. | |
| Value | evaluate (const Expr &e) |
| Evaluate e. | |
| bool | test (const Expr &e) |
| Return whether e is true, avoiding a copy for names. | |
| bool | explained (const Expr &e) |
| Return whether e is true, with only its own explanation in why. | |
| Value | unary (const Expr &e) |
| Evaluate unary expression e. | |
| Value | binary (const Expr &e) |
| Evaluate binary expression e. | |
| bool | compare (const Value &a, const Value &b, const Expr &e) |
| Compare single values a and b with the operator of e. | |
| Value | call (const Expr &e) |
| Call a function (names and arguments are checked by the parser). | |
| bool | defined (const Expr &e) const |
| Test whether name e is defined. | |
| bool | distinct (const Expr &e) |
| Test whether all integers in the arguments of call e differ. | |
| long long int | index (const Expr &e) |
| Return the value of index e. | |
| std::string | scalar_hint (const Expr &e) const |
| Return a hint for indexing e, a single value. | |
| Value | subscript (const Expr &e) |
| a[i]: element i, counted from 0, of the outermost list of a | |
| RecordRef | element_records (const Expr &e, const Expr &a) |
| Return the records that are the elements of array a of comprehension e, an array of values (see Expr::elements). | |
| void | explain (const Expr &e, const RecordRef &r, int i) |
| Add why element i of the array of all-comprehension e, with records r, is false. | |
| Value | comprehension (const Expr &e) |
| all, any, count, and sum over the elements of an array | |
| long long int | count (const Expr &e, const char *what) |
| Return the value of e, a count described by what. | |
| bool | holds (const Stmt &s, std::string &error) |
| Test whether check s holds, and otherwise store why it fails in error. | |
| bool | ranges (const Stmt &s, int i, int level) const |
| Test whether record name i of check s is defined and ranges over the repeat at level. | |
| bool | check_records (const Stmt &s, int deepest, Seq< int > &at, std::string &error) |
| Evaluate check s for the records inside the records at of its record name deepest, and return whether it holds. | |
| size_t | record_place (const Record &r, const Seq< int > &at) |
| Return where the record at of record name r starts in the input, or npos if that is unknown. | |
| Place | place (size_t q) const |
| Return the place of position q in the input, or the current place if q is npos. | |
| std::string | failure (const Stmt &s, int deepest, const Seq< int > &at) |
| Return why check s fails for the records at of its record name deepest. | |
Static Protected Member Functions | |
| static bool | truth (const Value &v) |
| Test whether v is true. | |
| static Value | boolean (bool b) |
| Return b as an integer. | |
| static bool | explains (const Expr &e) |
| Test whether e passes on why it is false (see why). | |
| static std::string | indexed (const Expr &e) |
| Describe the array of index expression e, for messages. | |
| static std::string | array_name (const Expr &a) |
| Describe array a of a comprehension, for messages. | |
| static std::string | record_text (const Record &r, const Seq< int > &at) |
| Describe the records at of record name r, innermost first. | |
Protected Attributes | |
| const SpecImpl & | spec |
| The spec. | |
| Input | in |
| The input. | |
| Seq< Seq< Entry > > | frames |
| Values: the outermost frame and one per active repeat iteration. | |
| Seq< Context > | context |
| Description of the statements being executed, for errors. | |
| int | spec_line |
| Spec line of the current statement. | |
| const Binding * | bindings |
| Names bound by the comprehensions being evaluated. | |
| const Stmt * | checked |
| The check being evaluated, or null. | |
| Seq< const Value * > | records |
| Values of its record names (see Record). | |
| const Seq< int > * | record_at |
| The records of the deepest of them, one index per repeat level. | |
| Seq< Witness > | why |
| Why the last condition evaluated is false, for messages: the elements of the all-comprehensions that failed, innermost first. | |
| long long int | effort |
| Values visited by expressions. | |
| const long long int | max_effort |
| Limit for effort, which grows with the input, so that repeated or nested expressions cannot take time far beyond the input's size. | |
Static Protected Attributes | |
| static const long long int | base_effort = 1LL << 20 |
| Base of the limit for effort. | |
Detailed Description
Evaluator of the expressions of a spec on an input.
Holds the values defined so far and evaluates expressions and checks with them. Errors point at the current position in the input.
Constructor & Destructor Documentation
◆ Evaluator()
| Gecode::Instance::Evaluator::Evaluator | ( | const SpecImpl & | s, |
| const std::string & | text, | ||
| const std::string & | origin ) |
Initialize for spec s and input text from origin.
Member Function Documentation
◆ located() [1/2]
|
protected |
Return the error message msg with the location and context.
◆ located() [2/2]
|
protected |
Return the error message msg at at with the context.
◆ fail() [1/2]
|
protected |
Throw an error with message msg at the current position.
◆ fail() [2/2]
|
protected |
Throw an error for the shape error e of the value of n.
◆ visit()
|
protected |
Account for visiting k values in expressions.
◆ set()
|
protected |
Define n as v in the innermost frame.
◆ lookup()
|
protected |
Return the value of n, or null if it is not defined.
◆ truth()
◆ boolean()
|
staticprotected |
Return b as an integer.
◆ ref()
Evaluate e, avoiding a copy for names.
The value is stored in tmp unless e is a name. Callers pass an integer scalar without a leaf as tmp, which needs no memory.
◆ record_path()
|
protected |
Return the indices of the record at of the check that select the records of its record name i.
◆ starts()
|
protected |
Return the record starts of repeat r, failing for n if the repeat has not run yet.
◆ count_records()
|
protected |
Return the number of records in list l.
◆ record_start()
|
protected |
Return where record i of list l starts in the input, or npos.
◆ records_of()
Evaluate e, a record or a list of records.
◆ field()
Evaluate field e of a record or a list of records.
The field of a list is the array of the field of each record. The value is stored in tmp unless it needs no copy.
◆ integer()
|
protected |
Return the integer of single value v, or fail for op.
◆ explains()
|
staticprotected |
Test whether e passes on why it is false (see why).
◆ eval()
Evaluate e, keeping why only if e explains it.
◆ evaluate()
◆ test()
|
protected |
Return whether e is true, avoiding a copy for names.
◆ explained()
|
protected |
Return whether e is true, with only its own explanation in why.
◆ unary()
◆ binary()
◆ compare()
|
protected |
Compare single values a and b with the operator of e.
◆ call()
Call a function (names and arguments are checked by the parser).
◆ defined()
|
protected |
Test whether name e is defined.
◆ distinct()
|
protected |
Test whether all integers in the arguments of call e differ.
◆ indexed()
|
staticprotected |
Describe the array of index expression e, for messages.
◆ index()
|
protected |
Return the value of index e.
◆ scalar_hint()
|
protected |
Return a hint for indexing e, a single value.
A record name in a check is one record, so that indexing the records needs their name.
◆ subscript()
a[i]: element i, counted from 0, of the outermost list of a
◆ array_name()
|
staticprotected |
Describe array a of a comprehension, for messages.
◆ element_records()
Return the records that are the elements of array a of comprehension e, an array of values (see Expr::elements).
◆ explain()
Add why element i of the array of all-comprehension e, with records r, is false.
◆ comprehension()
all, any, count, and sum over the elements of an array
The name of the comprehension e is bound to each element of the outermost list of the array in turn, or to each record of a list of records. all and any stop at the first element that decides the result.
◆ count()
|
protected |
Return the value of e, a count described by what.
◆ holds()
|
protected |
◆ ranges()
|
protected |
Test whether record name i of check s is defined and ranges over the repeat at level.
◆ check_records()
|
protected |
Evaluate check s for the records inside the records at of its record name deepest, and return whether it holds.
at has a record number per repeat level, from the outermost. Each record name that ranges over a level is set to its record. If the check fails, error is why.
◆ record_place()
|
protected |
Return where the record at of record name r starts in the input, or npos if that is unknown.
◆ place()
|
protected |
Return the place of position q in the input, or the current place if q is npos.
◆ record_text()
|
staticprotected |
Describe the records at of record name r, innermost first.
◆ failure()
|
protected |
Return why check s fails for the records at of its record name deepest.
Member Data Documentation
◆ spec
|
protected |
◆ in
◆ frames
◆ context
◆ spec_line
|
protected |
◆ bindings
|
protected |
◆ checked
|
protected |
◆ records
◆ record_at
|
protected |
◆ why
◆ effort
|
protected |
◆ max_effort
|
protected |
◆ base_effort
|
staticprotected |
The documentation for this class was generated from the following file:
- gecode/instance/eval.hpp
