Limbo 3.5.4
Loading...
Searching...
No Matches
LpDriver.h
Go to the documentation of this file.
1
7
8#ifndef LPPARSER_DRIVER_H
9#define LPPARSER_DRIVER_H
10
11#include "LpDataBase.h"
12
16namespace LpParser {
17
18using std::cout;
19using std::endl;
20using std::cerr;
21using std::string;
22using std::vector;
23using std::pair;
24using std::make_pair;
25using std::ostringstream;
26
35class Driver
36{
37public:
41
44
47
49 string streamname;
50
56 bool parse_stream(std::istream& in,
57 const string& sname = "stream input");
58
64 bool parse_string(const string& input,
65 const string& sname = "string stream");
66
72 bool parse_file(const string& filename);
73
74 // To demonstrate pure handling of parse errors, instead of
75 // simply dumping them on the standard error output, we will pass
76 // them to the driver using the following two member functions.
77
80 void error(const class location& l, const string& m);
81
84 void error(const string& m);
85
88 class Scanner* lexer;
89
93
95 // coef*var
96 void obj_cbk(bool minimize, TermArray const& terms);
97 // sum coef*var compare_op constant
98 void constraint_cbk(TermArray& terms, char compare, double constant);
99 // sum coef*var compare_op constant
100 void constraint_cbk(string const& name, TermArray& terms, char compare, double constant);
101 // var compare_op constant
102 void bound_cbk(string const& var, char compare, double constant);
103 // constant compare_op var
104 void bound_cbk(double constant, char compare, string const& var);
105 // constant1 compare_op1 var compare_op2 constant2
106 void bound_cbk(double constant1, char compare1, string const& var, char compare2, double constant2);
107 // generals type (integer)
108 void generals_cbk(StringArray const&);
109 // binary type
110 void binary_cbk(StringArray const&);
112protected:
113};
114
119bool read(LpDataBase& db, const string& lpFile);
120
121} // namespace example
122
123#endif // EXAMPLE_DRIVER_H
Database for Lp parser.
Driver(LpDataBase &db)
bool parse_file(const string &filename)
void error(const class location &l, const string &m)
class Scanner * lexer
Definition LpDriver.h:88
bool trace_scanning
enable debug output in the flex scanner
Definition LpDriver.h:43
bool trace_parsing
enable debug output in the bison parser
Definition LpDriver.h:46
string streamname
stream name (file or input stream) used for error messages.
Definition LpDriver.h:49
LpDataBase & m_db
Definition LpDriver.h:92
bool parse_stream(std::istream &in, const string &sname="stream input")
bool parse_string(const string &input, const string &sname="string stream")
void error(const string &m)
Base class for lp database. Only pure virtual functions are defined. User needs to inheritate this ...
Definition LpDataBase.h:115
namespace for LpParser
Definition LpDataBase.h:21
std::vector< std::string > StringArray
string array
Definition LpDataBase.h:40
std::vector< Term > TermArray
array of terms
Definition LpDataBase.h:105
bool read(LpDataBase &db, const string &lpFile)
API for LpParser. Read LP file and initialize database by calling user-defined callback functions.