我正在使用“PLSQL.g4”语法文件,我使用ANTLR4工具生成了PLSQLLexer.js和PLSQLParser.js。
现在,我如何向前推进以解析我的SQL查询。(我使用的是nodejs)
Example
Select * from employee where name = 'xxx'; //I want to parse this query
到目前为止,我已编写此代码:
var antlr4 = require('antlr4/index'),
plsqlLexer = require('./PLSQLLexer').PLSQLLexer,
plsqlParser = require('./PLSQLParser').PLSQLParser;
var input = "Select * from employee where name = 'cse'";
var chars = new antlr4.InputStream(input);
var lexer = new plsqlLexer(chars);
var tokens = new antlr4.CommonTokenStream(lexer);
var parser = new plsqlParser(tokens);
parser.buildParseTrees = true;
//Now to generate a tree which method i need to call?
link for PLSQLParser.js使用antlr4生成的解析器
注意:我是ANTLR4的新手