dReal4
DrDriver Class Reference

The DrDriver class brings together all components. More...

#include </home/soonhokong/work/dreal4/dreal/dr/driver.h>

Public Member Functions

 DrDriver ()=default
 construct a new parser driver context
 
 DrDriver (Context context)
 
bool parse_stream (std::istream &in, const std::string &sname="stream input")
 Invoke the scanner and parser for a stream. More...
 
bool parse_string (const std::string &input, const std::string &sname="string stream")
 Invoke the scanner and parser on an input string. More...
 
bool parse_file (const std::string &filename)
 Invoke the scanner and parser on a file. More...
 
const Variablelookup_variable (const std::string &name)
 Returns a variable associated with a name name. More...
 
void DeclareVariable (const Variable &v)
 Declare a variable v.
 
void DeclareVariable (const Variable &v, const Expression &lb, const Expression &ub)
 Declare a variable v which is bounded by an interval [lb, ub].
 
void Assert (const Formula &f)
 Asserts a formula f.
 
void Minimize (const Expression &f)
 Asserts a formula maximizing a cost function f.
 
void Solve ()
 Solves the constructed problem.
 

Static Public Member Functions

static void error (const location &l, const std::string &m)
 Error handling with associated line number. More...
 
static void error (const std::string &m)
 General error handling. More...
 

Public Attributes

bool trace_scanning_ {false}
 enable debug output in the flex scanner
 
bool trace_parsing_ {false}
 enable debug output in the bison parser
 
std::string streamname_
 stream name (file or input stream) used for error messages.
 
DrScannerscanner_ {nullptr}
 Pointer to the current scanenr instance, this is used to connect the parser to the scanner. More...
 

Detailed Description

The DrDriver class brings together all components.

It creates an instance of the Parser and Scanner classes and connects them. Then the input stream is fed into the scanner object and the parser gets it's token sequence. Furthermore the driver object is available in the grammar rules as a parameter. Therefore the driver class contains a reference to the structure into which the parsed data is saved.

Member Function Documentation

◆ error() [1/2]

void error ( const location &  l,
const std::string &  m 
)
static

Error handling with associated line number.

This can be modified to output the error e.g. to a dialog box.

◆ error() [2/2]

void error ( const std::string &  m)
static

General error handling.

This can be modified to output the error e.g. to a dialog box.

◆ lookup_variable()

const Variable & lookup_variable ( const std::string &  name)

Returns a variable associated with a name name.

Exceptions
ifno variable is associated with name.

◆ parse_file()

bool parse_file ( const std::string &  filename)

Invoke the scanner and parser on a file.

Use parse_stream with a std::ifstream if detection of file reading errors is required.

Parameters
filenameinput file name
Returns
true if successfully parsed

◆ parse_stream()

bool parse_stream ( std::istream &  in,
const std::string &  sname = "stream input" 
)

Invoke the scanner and parser for a stream.

Parameters
ininput stream
snamestream name for error messages
Returns
true if successfully parsed

◆ parse_string()

bool parse_string ( const std::string &  input,
const std::string &  sname = "string stream" 
)

Invoke the scanner and parser on an input string.

Parameters
inputinput string
snamestream name for error messages
Returns
true if successfully parsed

Member Data Documentation

◆ scanner_

DrScanner* scanner_ {nullptr}

Pointer to the current scanenr instance, this is used to connect the parser to the scanner.

It is used in the yylex macro.


The documentation for this class was generated from the following files: