-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtokenizer.h
44 lines (34 loc) · 1.24 KB
/
tokenizer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once
#include <sstream>
#include <fstream>
#include <iostream>
#include "lexicalscanner.h"
#include "errorhandler.h"
//The tokenizer class is used to parse input
class tokenizer
{
private:
std::string filename_; //holds the name of the input file
std::stringstream parser_; //holds the contents of the input file that will be parsed
std::string parser_type;
ErrorHandler errorHandler;
public:
~tokenizer() { } //default destructor
tokenizer() {filename_ = " ";} //default constructor - sets fileame to blank
//overloaded constructor - accepts a single argument string representing the input file name
tokenizer(std::string filename, std::string parser) {
filename_ = filename;
parser_type = parser;
}
vector<Record> parse_input(string output_file_name);// paramter = output location
//function for parsing the input that takes no arguments and returns a list of Record objects
const ErrorHandler & getErrorHandler() {
return errorHandler;
}
protected:
string get_output_file(const string & type);
void output_string(const string & type, const string & output);
template <class T>
void output_string(const string & type, T & o);
void output_string(const string & type, void (*fn)(ostream &));
};