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.1 KiB
51 lines
1.1 KiB
12 months ago
|
#ifndef _SYSYF_DRIVER_H_
|
||
|
#define _SYSYF_DRIVER_H_
|
||
|
|
||
|
#include <fstream>
|
||
|
#include <string>
|
||
|
#include <map>
|
||
|
|
||
|
// Generated by bison:
|
||
|
#include "SysYFParser.h"
|
||
|
|
||
|
#include "SysYFFlexLexer.h"
|
||
|
|
||
|
// Conducting the whole scanning and parsing of SysYF.
|
||
|
class SysYFDriver
|
||
|
{
|
||
|
public:
|
||
|
SysYFDriver();
|
||
|
virtual ~SysYFDriver();
|
||
|
|
||
|
std::map<std::string, int> variables;
|
||
|
|
||
|
int result;
|
||
|
|
||
|
// SysYF lexer
|
||
|
SysYFFlexLexer lexer;
|
||
|
|
||
|
std::ifstream instream;
|
||
|
|
||
|
// Handling the SysYF scanner.
|
||
|
void scan_begin();
|
||
|
void scan_end();
|
||
|
bool trace_scanning;
|
||
|
|
||
|
// Run the parser on file F.
|
||
|
// Return 0 on success.
|
||
|
SysYF::Ptr<SysYF::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);
|
||
|
|
||
|
SysYF::Ptr<SysYF::SyntaxTree::Node> root = nullptr;
|
||
|
};
|
||
|
|
||
|
#endif // _SYSYF_DRIVER_H_
|