-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathhello.cpp
More file actions
31 lines (25 loc) · 703 Bytes
/
hello.cpp
File metadata and controls
31 lines (25 loc) · 703 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
29
30
31
#include <iostream>
#include <fstream>
#include <string>
#include "antlr4-runtime.h"
#include "modelicaLexer.h"
#include "modelicaParser.h"
using namespace antlr4;
using namespace std;
int main(int argc, char *argv[]) {
string line;
ifstream modelicaFile ("example2.txt");
if (modelicaFile.is_open()) {
ANTLRInputStream input(modelicaFile);
modelicaLexer lexer(&input);
CommonTokenStream tokens(&lexer);
tokens.fill();
for (auto token : tokens.getTokens()) {
std::cout << token->toString() << std::endl;
}
modelicaParser parser(&tokens);
tree::ParseTree *tree = parser.stored_definition();
std::cout << tree->toStringTree(&parser) << std::endl;
modelicaFile.close();
}
}