31 lines
648 B
C++
31 lines
648 B
C++
|
|
|
||
|
|
#include <iostream>
|
||
|
|
#include <fstream>
|
||
|
|
#include <string>
|
||
|
|
#include "antlr4-runtime.h"
|
||
|
|
#include "PlSqlLexer.h"
|
||
|
|
#include "PlSqlParser.h"
|
||
|
|
|
||
|
|
using namespace antlr4;
|
||
|
|
using namespace std;
|
||
|
|
|
||
|
|
string parseInput(string inputFileName){
|
||
|
|
ifstream inputFile (inputFileName);
|
||
|
|
if (inputFile.is_open()) {
|
||
|
|
ANTLRInputStream input(inputFile);
|
||
|
|
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();
|
||
|
|
|
||
|
|
inputFile.close();
|
||
|
|
return tree->toStringTree(&parser);
|
||
|
|
}
|
||
|
|
}
|