You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.0 KiB

#ifndef _SYSY_DRIVER_H_
#define _SYSY_DRIVER_H_
#include <fstream>
#include <string>
#include <map>
// Generated by bison:
#include "SysYParser.h"
#include "SysYFlexLexer.h"
// Conducting the whole scanning and parsing of SysY.
class SysYDriver
{
public:
SysYDriver();
virtual ~SysYDriver();
std::map<std::string, int> variables;
int result;
// SysY lexer
SysYFlexLexer lexer;
std::ifstream instream;
// Handling the SysY scanner.
void scan_begin();
void scan_end();
bool trace_scanning;
// Run the parser on file F.
// Return 0 on success.
SyntaxTree::Node* parse(const std::string& f);
// The name of the file being parsed.
// Used later to pass the file name to the location tracker.
std::string file;
// Whether parser traces should be generated.
bool trace_parsing;
// Error handling.
void error(const yy::location& l, const std::string& m);
void error(const std::string& m);
SyntaxTree::Node* root = nullptr;
};
#endif // _SYSY_DRIVER_H_