[antlr-interest] How To ... Code Beautifier for PL/SQL

shmuel siegel antlr at shmuelhome.mine.nu
Wed Jan 24 09:21:18 PST 2007


Mark Vilrokx wrote:
> Hi,
>
> I am rather new to ANTLR and the whole compiler scene but I wasn't 
> planning on writing a compiler.  I am actually trying to write a Code 
> Beautifier and and Automatic Code Analyzer.  When I set out on this 
> project, I was planning on writing my own code (perl) and using 
> regular expressions, however, I soon found out that this is way to 
> complex and it started to resemble a ... parser.  So I started 
> investigating ANTLR and other tools like JavaCC to see what they can 
> do for me. 
>
> Can someone please confirm whether ANTLR would be a good tool to write 
> my Code Beautifier and Code Analyzer?
>
> I have been playing around with ANTLR and it all makes quite a lot of 
> sense using the example on how to get started, but my problem is I am 
> writing a parser for an existing language PL/SQL and I don't know how 
> to ... begin.  The Lexar and Parsar in the end will probably be HUGH, 
> but I want to start small.  E.g. to start with I only want to 
> "recognize" the start and end of the PL/SQL function or procedure and 
> ignore the bit in the middle.  Then, later, I want to add some more to 
> the lexer and parser to recognize the declare section etc, slowly 
> building up the lexer and parser.  Is this possible?  Any examples?
>
> Cheers,
> Mark.

I don't see that you were answered so I will venture a superficial 
response. I think that ANTLR is as good or better of a tool for what you 
are doing as any other parser generator. It is definitely better than 
using perl regular expressions. You should know that you will run into 
problems when you start dealing with unreserved keywords. The lexer 
might also give you problems unless it is easy to recognize when you 
switch between SQL and PL.





More information about the antlr-interest mailing list