Search code examples
javacode-generationantlrstringtemplate

ANTLR parser for PL/SQL with target language as Java


Do we have a PL/SQL grammer for Java target yet? I got the one for C#, but need for Java target.

I would like to use this with ANTLR to generate Java using StringTemplates. I've gone through the documentation and have a decent understanding of how to achieve this, just wanted to check if any one has already done this kind of thing.


Solution

  • Well, there's a grammar at the ANTLR site: http://antlr.org/grammar/1279318813752/PLSQL.g

    The author says it doesn't parse the SQL part.

    I don't know what you expect to be able to generate reading just the syntax. You usually need much more than that. See my answer here as to why not: antlr generate ast for c and parse the ast

    EDIT: OP says he wants to translate PL/SQL code to Java. See my answer on what it takes to build a language-to-language translator: What kinds of patterns could I enforce on the code to make it easier to translate to another programming language?