[antlr-interest] Would antlr be suited for this task?

Randall R Schulz rschulz at sonic.net
Fri Oct 10 13:16:10 PDT 2008


On Friday 10 October 2008 12:45, Gary Rosales wrote:
> Hi,
>
>
>
> I am a newbie with ANTLR but I have a question that it's been itching
> me to ask for a while. I am in a project where we are migrating a
> bunch of c code that has embedded SQL (E/SQL from Informix) to c code
> that has also embedded SQL but in another format (Pro*C from Oracle).
> The Informix c code (ec files) is full of non-ANSI 92 SQL that needs
> to be converted, this code is inside strcpy, sprintf, strcat, and so
> on. For instance, code fragments like:
>
> ...
>
> there are many fragments like this (but they are longer and more
> complex).

I surely hope that as part of your conversion you turn those into 
PreparedStatement instances!


> There is already a tool that does this that it's provided by Oracle,
> but it's incomplete because it doesn't work on cases like the example
> I just gave. So we do use the tool; the tool takes care of other
> embedded sql that it's not within strings variables but, would it be
> possible to create a compiler to transform the dynamic sql that it's
> generated in the variables. There are many files that use definitions
> on other files (macros and such) that are used  for the business
> logic in the dynamic sql, so the compiler would have to link the
> files and do semantic checking. Is this feasible? The approach we
> have right now is using a custom framework with match and replace
> files for the source, it's quite tedious and I 'd love to hear of a
> better way to do this. I would think it's possible but I'd rather ask
> people who have much more experienced than me with compiler creation
> and ANTLR.

I have not actually used this feature, but JetBrains (formerly 
IntellifJ) IDEA has something called "structural search and replace" 
which may do what you need. I suggest you search on their site for that 
feature and, perhaps, ask in the IntelliJ IDEA Community Forum whether 
this can be done:

- IntelliJ IDEA Forums
  <http://www.intellij.net/forums/category.jspa?categoryID=8>

- IDEA Community Forum (general questions)
  <http://www.intellij.net/forums/forum.jspa?forumID=27>


I know IDEA isn't cheap, but my guess it buying, installing and learning 
to use it enough for this task would be cheaper than the cost an 
engineer's time required to create a purpose-built solution.


> Thank you for your help.
>
> Gary Rosales


Randall Schulz


More information about the antlr-interest mailing list