-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_LL.cpp
More file actions
28 lines (28 loc) · 899 Bytes
/
test_LL.cpp
File metadata and controls
28 lines (28 loc) · 899 Bytes
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
#include <Parser.h>
#include <iostream>
#include <fstream>
#include <sstream>
int main() {
Parser::Lexer lexer;
Parser::Parser parser;
lexer.makeTokensFromFile("parser/parser/rule.isc");
std::ofstream ofile("tokens");
if (!ofile) {
std::cerr << "could not open token file\n";
exit(1);
}
lexer.printTokens(ofile);
auto errors = lexer.getErrors();
for (auto error : errors) {
printf("Lexer: %zu:%zu: %s\n", error.line, error.column, error.message.c_str());
}
std::cout << std::endl;
auto tree = parser.parse(lexer);
auto parser_errors = parser.getErrors();
printf("errors size(): %zu\n", parser_errors.size());
for (auto error : parser_errors) {
printf("Parser: %zu:%zu(%zu): %s\n", error.line, error.column, error.pos, error.message.c_str());
}
std::ofstream file("AST");
parser.printAST(file);
}