First commit
This commit is contained in:
30
antlr-library.cpp
Normal file
30
antlr-library.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
#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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user