Files
old-oracle-parser/example.cpp

33 lines
678 B
C++
Raw Normal View History

2018-02-23 00:40:26 +01:00
#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();
}
}