Limbo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LpDriver.h
Go to the documentation of this file.
1 
8 #ifndef LPPARSER_DRIVER_H
9 #define LPPARSER_DRIVER_H
10 
11 #include "LpDataBase.h"
12 
16 namespace LpParser {
17 
18 using std::cout;
19 using std::endl;
20 using std::cerr;
21 using std::string;
22 using std::vector;
23 using std::pair;
24 using std::make_pair;
25 using std::ostringstream;
26 
35 class Driver
36 {
37 public:
40  Driver(LpDataBase& db);
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&);
112 protected:
113 };
114 
119 bool read(LpDataBase& db, const string& lpFile);
120 
121 } // namespace example
122 
123 #endif // EXAMPLE_DRIVER_H
Base class for lp database. Only pure virtual functions are defined. User needs to inheritate this cl...
Definition: LpDataBase.h:114
bool trace_scanning
enable debug output in the flex scanner
Definition: LpDriver.h:43
bool parse_file(const string &filename)
std::vector< Term > TermArray
array of terms
Definition: LpDataBase.h:105
string streamname
stream name (file or input stream) used for error messages.
Definition: LpDriver.h:49
std::vector< std::string > StringArray
string array
Definition: LpDataBase.h:40
Database for Lp parser.
bool parse_stream(std::istream &in, const string &sname="stream input")
void error(const class location &l, const string &m)
bool parse_string(const string &input, const string &sname="string stream")
bool trace_parsing
enable debug output in the bison parser
Definition: LpDriver.h:46
class Scanner * lexer
Definition: LpDriver.h:88
Driver(LpDataBase &db)
LpDataBase & m_db
Definition: LpDriver.h:92
bool read(LpDataBase &db, const string &lpFile)
API for LpParser. Read LP file and initialize database by calling user-defined callback functions...
namespace for LpParser
Definition: LpDataBase.h:21