Hi,
I am preparing to write a lot of SQL files, which are to be processed by an application. Depending on the database, there are slight differences. So, the worst case would be to have varios versions of all files, depending on the database vendor.
My current idea to simplify that process (and the future maintenance of those files) would be not to read those files directly, but to have some kind of macro processor (think C preprocessor) in front, so that my input files could look like
$if mysql
$idtype() := BIGINT NOT NULL PRIMARY KEY $:
$varchar(length) := VARCHAR(${length}) $:
$blobtype() := MEDIUM BLOB $:
$else if oracle
$idtype() := BIGINT NOT NULL PRIMARY KEY $:
$varchar(length) := VARCHAR(${length}) $:
$blobtype() := BLOB $:
...
$endif
CREATE TABLE foo (id ${idtype}, name varchar(64), contract ${blobtype})
Now, to my questions:
1.) Is anybody aware of something similar that already exists, and could be reused?
2.) Any recommendations on how to design the language so that the creation of an AntLR grammar is easy?
3.) Would it be possible to integrate support for something like #include <filename> into a a TokenStream?
Thanks,
Jochen