33 lines
678 B
C++
33 lines
678 B
C++
|
|
|
||
|
|
#include <iostream>
|
||
|
|
#include <fstream>
|
||
|
|
#include <string>
|
||
|
|
#include "antlr4-runtime.h"
|
||
|
|
#include "PlSqlLexer.h"
|
||
|
|
#include "PlSqlParser.h"
|
||
|
|
|
||
|
|
using namespace antlr4;
|
||
|
|
using namespace std;
|
||
|
|
|
||
|
|
int main(int argc, char *argv[]) {
|
||
|
|
ifstream modelicaFile ("example-input.txt");
|
||
|
|
if (modelicaFile.is_open()) {
|
||
|
|
ANTLRInputStream input(modelicaFile);
|
||
|
|
PlSqlLexer lexer(&input);
|
||
|
|
CommonTokenStream tokens(&lexer);
|
||
|
|
|
||
|
|
tokens.fill();
|
||
|
|
for (auto token : tokens.getTokens()) {
|
||
|
|
std::cout << token->toString() << std::endl;
|
||
|
|
}
|
||
|
|
|
||
|
|
PlSqlParser parser(&tokens);
|
||
|
|
tree::ParseTree *tree = parser.sql_script();
|
||
|
|
|
||
|
|
std::cout << tree->toStringTree(&parser) << std::endl;
|
||
|
|
modelicaFile.close();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|