38 #ifndef __FLATZINC_PARSER_HH__ 39 #define __FLATZINC_PARSER_HH__ 46 #define YY_NO_UNISTD_H 48 extern "C" int isatty(
int);
55 #define strdup _strdup 56 #define fileno _fileno 68 #include <gecode/flatzinc/parser.tab.hh> 71 namespace Gecode {
namespace FlatZinc {
73 typedef std::pair<std::string,Option<std::vector<int>* > >
intvartype;
76 typedef std::pair<std::string, VarSpec*>
varspec;
83 const std::pair<std::string,AST::Node*>&
y) {
84 return x.first < y.first;
192 : buf(b.c_str()),
pos(0), length(b.
size()), fg(fg0),
193 hadError(false), err(err0) {}
197 : buf(buf0),
pos(0), length(length0), fg(fg0),
198 hadError(false), err(err0) {}
204 std::vector<std::pair<std::string,AST::Node*> >
_output;
225 int num =
std::min(length - pos, lexBufSize);
226 memcpy(lexBuf,buf+pos,num);
232 _output.push_back(std::pair<std::string,AST::Node*>(x,n));
237 std::sort(_output.begin(),_output.end(),oo);
239 for (
unsigned int i=0;
i<_output.
size();
i++) {
240 a->a.push_back(
new AST::String(_output[
i].first+
" = "));
241 if (_output[
i].second->isArray()) {
243 for (
unsigned int j=0; j<oa->
a.size(); j++) {
244 a->
a.push_back(oa->
a[j]);
247 delete _output[
i].second;
249 a->a.push_back(_output[
i].second);
ParserState(char *buf0, int length0, std::ostream &err0, Gecode::FlatZinc::FlatZincSpace *fg0)
std::pair< std::string, VarSpec * > varspec
int size(void) const
Return size of array (number of elements)
SymbolTable< SymbolEntry > symbols
SymbolEntry se_iva(int i)
Construct integer variable array entry.
SymbolType
Types of symbols.
AST::Array * getOutput(void)
std::vector< varspec > intvars
std::vector< ConExpr * > constraints
bool pos(const View &x)
Test whether x is postive.
std::pair< std::string, Option< std::vector< int > *> > intvartype
SymbolEntry se_sv(int i)
Construct set variable entry.
std::vector< double > floatvals
SymbolEntry se_sva(int i)
Construct set variable array entry.
std::vector< varspec > floatvars
Array * getArray(void)
Cast this node to an array node.
SymbolEntry(SymbolType t0, int i0)
Constructor.
SymbolEntry se_fa(int i)
Construct float array entry.
struct Gecode::@579::NNF::@61::@63 a
For atomic nodes.
void sort(TaskViewArray< TaskView > &t)
Sort task view array t according to sto and inc (increasing or decreasing)
SymbolEntry se_i(int i)
Construct integer entry.
SymbolEntry se_sa(int i)
Construct set array entry.
const FloatNum min
Smallest allowed float value.
Gecode::IntArgs i(4, 1, 2, 3, 4)
Entries in the symbol table.
int n
Number of negative literals for node type.
SymbolEntry se_iv(int i)
Construct integer variable entry.
std::vector< varspec > setvars
std::vector< std::pair< std::string, AST::Node * > > _output
std::vector< int > arrays
SymbolEntry(void)
Default constructor.
bool operator()(const std::pair< std::string, AST::Node *> &x, const std::pair< std::string, AST::Node *> &y)
Return if x is less than y, based on first component.
unsigned int size(I &i)
Size of all ranges of range iterator i.
struct Gecode::@579::NNF::@61::@62 b
For binary nodes (and, or, eqv)
Gecode::FlatZinc::FlatZincSpace * fg
Symbol table mapping identifiers (strings) to values.
SymbolEntry se_f(int i)
Construct float entry.
std::vector< varspec > boolvars
SymbolEntry se_b(bool b)
Construct Boolean entry.
SymbolEntry se_s(int i)
Construct set entry.
void output(std::string x, AST::Node *n)
std::vector< ConExpr * > domainConstraints
Post propagator for SetVar SetOpType SetVar y
ParserState(const std::string &b, std::ostream &err0, Gecode::FlatZinc::FlatZincSpace *fg0)
SymbolEntry se_ia(int i)
Construct integer array entry.
SymbolEntry se_fv(int i)
Construct float variable entry.
SymbolEntry se_bva(int i)
Construct Boolean variable array entry.
Base class for variable specifications.
Post propagator for SetVar x
Strict weak ordering for output items.
A space that can be initialized with a FlatZinc model.
SymbolEntry se_fva(int i)
Construct float variable array entry.
Gecode toplevel namespace
SymbolEntry se_bv(int i)
Construct Boolean variable entry.
A node in a FlatZinc abstract syntax tree.
int fillBuffer(char *lexBuf, unsigned int lexBufSize)
SymbolEntry se_ba(int i)
Construct Boolean array entry.
std::vector< AST::SetLit > setvals
State of the FlatZinc parser