Generated on for Gecode by doxygen 1.17.0

Reading instance files described by reader specs. More...

Classes

class  Arm
 Arm of a sections statement. More...
class  Binding
 A name bound by a comprehension, visible while the binding exists. More...
class  Column
 Array built row by row from the values of a repeated statement. More...
class  Context
 A statement being executed, for errors. More...
class  Data
 Named values read from an instance. More...
class  DataImpl
 Implementation of Data. More...
class  Decl
 A name that a block may define, with the type and depth of its values. More...
class  Entry
 A named value. More...
class  Error
 Exception for errors in specs and instance files More...
class  Evaluator
 Evaluator of the expressions of a spec on an input. More...
class  Expr
 Expression. More...
class  Input
 Instance text with a position and line tracking. More...
class  Params
 Values for the param statements of a spec. More...
class  ParamsImpl
 Implementation of Params. More...
class  Pattern
 Line pattern such as "DIMENSION : {n:int}". More...
class  Place
 A position in the input, with its line. More...
class  Record
 A record name of a check. More...
class  RecordRef
 Records or a list of records of a named repeat. More...
class  Seq
 Growable array on the Gecode heap. More...
class  ShapeError
 Error about the shape or type of a value, located by the caller. More...
class  Spec
 Reader spec for a textual instance format. More...
class  SpecImpl
 Implementation of Spec. More...
class  Stmt
 Statement. More...
class  Type
 Type of the values that a declaration or a capture reads. More...
class  Value
 A value: scalar or nested (possibly ragged) array. More...
class  Witness
 A part of the explanation of a failed check, such as "record 3 of 'jobs'", with the position of the record in the input if known. More...

Typedefs

typedef Seq< std::unique_ptr< Stmt > > Block
 Sequence of statements.

Enumerations

enum class  ValueType { INT , FLOAT , STRING }
 Type of the values in a data entry. More...
enum class  ReadType {
  INT , FLOAT , NUM , WORD ,
  REST , SYMBOL
}
 What a declaration or a capture reads. More...

Functions

std::string quote (const std::string &s)
 Return s in single quotes, with newlines and tabs escaped.
bool add (long long int x, long long int y, long long int &r)
 Store x + y in r unless it overflows.
bool sub (long long int x, long long int y, long long int &r)
 Store x - y in r unless it overflows.
bool is_digit (char c)
 Test whether c is a digit.
bool is_letter (char c)
 Test whether c is a letter.
bool is_alnum (char c)
 Test whether c can occur in a name.
bool is_space (char c)
 Test whether c is white space.
bool is_blank (char c)
 Test whether c is white space within a line.
bool is_sign (char c)
 Test whether c is a sign.
bool is_exponent (char c)
 Test whether c starts the exponent of a float.
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.
bool parse_int (const std::string &t, long long int &v)
 Parse decimal integer t into v, and return whether it is one.
bool parse_float (const std::string &t, double &v)
 Parse decimal float t into v, and return whether it is one.
std::string record_starts (int id)
 Return the name of the record starts of the repeat numbered id.
bool is_internal (const std::string &n)
 Test whether n is a name used internally (see record_starts).
void declared (const Block &b, Seq< Decl > &out)
 Add the names that block b may define to out.
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.
void resolve (Block &b, const std::string &origin)
 Resolve the names in the expressions of b, the body of a spec from origin.
std::string read_file (const std::string &path)
 Read file path into a string.

Detailed Description

Reading instance files described by reader specs.

A reader spec is a short text that describes how a textual instance format is laid out: header counts, KEY : VALUE lines, sections, matrices, lists ended by sentinels, records, and character grids. Reading a file with a spec yields named values (Data): scalars and arrays, where the fields of repeated records are stored column-wise.

Programs supply the specs for the formats they read, typically as string literals. The spec language is described in The reader spec language.

Typedef Documentation

◆ Block

typedef Seq<std::unique_ptr<Stmt> > Gecode::Instance::Block

Sequence of statements.

Definition at line 603 of file impl.hpp.

Enumeration Type Documentation

◆ ValueType

enum class Gecode::Instance::ValueType
strong

Type of the values in a data entry.

Enumerator
INT 

Integers.

FLOAT 

Floating point numbers.

STRING 

Strings.

Definition at line 349 of file instance.hh.

◆ ReadType

enum class Gecode::Instance::ReadType
strong

What a declaration or a capture reads.

Enumerator
INT 

An integer.

FLOAT 

A float.

NUM 

An integer if possible, otherwise a float.

WORD 

A token as a string.

REST 

The rest of the line as a string.

SYMBOL 

A character of an alphabet, as an integer.

Definition at line 520 of file impl.hpp.

Function Documentation

◆ quote()

std::string Gecode::Instance::quote ( const std::string & s)

Return s in single quotes, with newlines and tabs escaped.

Definition at line 43 of file eval.cpp.

◆ add()

bool Gecode::Instance::add ( long long int x,
long long int y,
long long int & r )

Store x + y in r unless it overflows.

Definition at line 54 of file eval.cpp.

◆ sub()

bool Gecode::Instance::sub ( long long int x,
long long int y,
long long int & r )

Store x - y in r unless it overflows.

Definition at line 62 of file eval.cpp.

◆ is_digit()

bool Gecode::Instance::is_digit ( char c)
inline

Test whether c is a digit.

Definition at line 56 of file impl.hpp.

◆ is_letter()

bool Gecode::Instance::is_letter ( char c)
inline

Test whether c is a letter.

Definition at line 60 of file impl.hpp.

◆ is_alnum()

bool Gecode::Instance::is_alnum ( char c)
inline

Test whether c can occur in a name.

Definition at line 64 of file impl.hpp.

◆ is_space()

bool Gecode::Instance::is_space ( char c)
inline

Test whether c is white space.

Definition at line 68 of file impl.hpp.

◆ is_blank()

bool Gecode::Instance::is_blank ( char c)
inline

Test whether c is white space within a line.

Definition at line 72 of file impl.hpp.

◆ is_sign()

bool Gecode::Instance::is_sign ( char c)
inline

Test whether c is a sign.

Definition at line 76 of file impl.hpp.

◆ is_exponent()

bool Gecode::Instance::is_exponent ( char c)
inline

Test whether c starts the exponent of a float.

Definition at line 80 of file impl.hpp.

◆ number_end()

size_t Gecode::Instance::number_end ( const std::string & s,
size_t p,
bool sign,
bool real )
inline

Return where the number starting at position p of s ends.

A number has digits, a sign first if sign, and, if real, also '.', 'e', 'E', and a sign directly after 'e' or 'E'. Only the characters are scanned: parse_int and parse_float check the syntax.

Definition at line 90 of file impl.hpp.

◆ parse_int()

bool Gecode::Instance::parse_int ( const std::string & t,
long long int & v )

Parse decimal integer t into v, and return whether it is one.

Definition at line 62 of file spec.cpp.

◆ parse_float()

bool Gecode::Instance::parse_float ( const std::string & t,
double & v )

Parse decimal float t into v, and return whether it is one.

Definition at line 72 of file spec.cpp.

◆ record_starts()

std::string Gecode::Instance::record_starts ( int id)
inline

Return the name of the record starts of the repeat numbered id.

A repeat stores where each of its records starts in the input under this name, which is not a spec name, so that a failed check can point at a record. Such names are not part of the data read.

Definition at line 511 of file impl.hpp.

◆ is_internal()

bool Gecode::Instance::is_internal ( const std::string & n)
inline

Test whether n is a name used internally (see record_starts).

Definition at line 515 of file impl.hpp.

◆ declared()

void Gecode::Instance::declared ( const Block & b,
Seq< Decl > & out )

Add the names that block b may define to out.

Definition at line 1207 of file spec.cpp.

◆ fail_at()

void Gecode::Instance::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.

Definition at line 84 of file spec.cpp.

◆ resolve()

void Gecode::Instance::resolve ( Block & b,
const std::string & origin )

Resolve the names in the expressions of b, the body of a spec from origin.

Finds the expressions that are records or lists of records of a named repeat (see Expr) and the record names of the checks (see Record), and reports their misuse.

Definition at line 619 of file resolve.cpp.

◆ read_file()

std::string Gecode::Instance::read_file ( const std::string & path)

Read file path into a string.

Definition at line 49 of file spec.cpp.