mgf::Driver Class Reference

The primary user interface class. More...

#include <Driver.h>

List of all members.

Public Member Functions

 Driver (MgfFile &mgfFile)
 construct a new parser driver context
bool parse_stream (std::istream &in, const std::string &sname="stream input")
 Invoke the scanner and parser for a stream.
bool parse_string (const std::string &input, const std::string &sname="string stream")
 Invoke the scanner and parser on an input string.
bool parse_file (const std::string &filename)
 Invoke the scanner and parser on a file.
void error (const class location &l, const std::string &m)
 Error handling with associated line number.
void error (const std::string &m)
 General error handling.

Public Attributes

bool trace_scanning
 enable debug output in the flex scanner
bool trace_parsing
 enable debug output in the bison parser
std::string streamname
 stream name (file or input stream) used for error messages.
Scannerlexer
 Pointer to the current lexer instance, this is used to connect the parser to the scanner.
Context context
 Reference to the calculator context filled during parsing of the expressions.

Detailed Description

The primary user interface class.

The Driver 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.


Constructor & Destructor Documentation

mgf::Driver::Driver ( MgfFile mgfFile  ) 

construct a new parser driver context


Member Function Documentation

void mgf::Driver::error ( const std::string &  m  ) 

General error handling.

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

void mgf::Driver::error ( const class location &  l,
const std::string &  m 
)

Error handling with associated line number.

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

bool mgf::Driver::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:
filename input file name
Returns:
true if successfully parsed
bool mgf::Driver::parse_stream ( std::istream &  in,
const std::string &  sname = "stream input" 
)

Invoke the scanner and parser for a stream.

Parameters:
in input stream
sname stream name for error messages
Returns:
true if successfully parsed
bool mgf::Driver::parse_string ( const std::string &  input,
const std::string &  sname = "string stream" 
)

Invoke the scanner and parser on an input string.

Parameters:
input input string
sname stream name for error messages
Returns:
true if successfully parsed

Member Data Documentation

Reference to the calculator context filled during parsing of the expressions.

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

It is used in the yylex macro.

stream name (file or input stream) used for error messages.

enable debug output in the bison parser

enable debug output in the flex scanner


The documentation for this class was generated from the following files:
All Classes Namespaces Functions Variables Typedefs Friends

Generated on Sun Oct 10 10:20:34 2010 for mgfp by  doxygen 1.6.1