blob: 4c78f5b20e5cc5b757b3aeef2295fb29d19e0fb6 (
plain)
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
45
46
47
48
49
50
|
#include <iostream>
#include <fstream>
#include "TocLexer.h"
#include "TocParser.h"
#include "toc.h"
#include "repr.h"
#include "repr_get.h"
#include "check.h"
using namespace antlr4;
int main(int argc, const char * argv[])
{
std::ifstream ifs("test.toc");
ANTLRInputStream input(ifs);
TocLexer lexer(&input);
CommonTokenStream tokens(&lexer);
TocParser parser(&tokens);
TocParser::ProgContext * prog = parser.prog();
tree::ParseTree * tree = prog;
if (parser.getNumberOfSyntaxErrors() > 0)
{
std::cerr << "Parsing error" << std::endl;
return 1;
}
std::string s = tree->toStringTree(&parser) + "\n";
//std::cout << "Parse Tree: " << s << std::endl;
Program prg = getProgram(prog);
tocProgram(std::cout, prg);
if (!checkProgram(prg))
std::cerr << "Error" << std::endl;
//std::ofstream ofs("output.c");
//tocProg(ofs, prg);
//ofs.close();
return 0;
}
|