[antlr-interest] A few questions about parsing SQL by PL/SQL.
Felix.徐
ygnhzeus at gmail.com
Thu Mar 1 20:50:35 PST 2012
Hi all,
Does someone has experience using this PL/SQL(
https://github.com/porcelli/plsql-parser) grammar listed on antlr?
I got a few problems while trying to use it to parse a simple SQL string.
1.Am I right to generate the java code of PLSQLLexer.g,PLSQLParser.g,
PLSQLWalker.g in sequence?I got a lot of warnings in this phase.
2.Is there any instruction about how to use the generated class for parsing
a SQL string and walking through it?Here is my code:
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
String source ="SELECT f FROM FS";
ANTLRStringStream input = new ANTLRStringStream(source);
PLSQLLexer lex = new PLSQLLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lex);
PLSQLParser parser = new PLSQLParser(tokens);
try
{
parser.*****();
}
catch (RecognitionException e)
{
e.printStackTrace();
}
}
I don't know which method should be invoked in "*****()".I tried
"parser.select_key();" but got "line 1:0 missing SQL92_RESERVED_SELECT at
'SELECT'".
Is there anything missing?
Thanks very much!
More information about the antlr-interest
mailing list