[antlr-interest] unexpected behavior in splitter grammar

Scherer Markus markus.scherer at inet-logistics.com
Thu Jun 24 07:23:24 PDT 2010


Hi everyone!

I am currently working on a grammar, that converts SQL*PLUS scripts in JDBC compatible statements.
Basically I am separating the different statements in

* normal SQL statements (to be JDBC compatible, the trailing semicolon must be removed)
* PL/SQL statements (or more precise: statement that require a trailing “END;”)
* comments (I keep them for metadata or something)

Furthermore, the SQL*PLUS specific “/” is recognized.

I simply tried imitate the behavior of multiline-comments, since I am for now not interested in the inner structure of the statements, however the appended grammar yields many errors like the following while parsing

line 4:27 mismatched character 'e' expecting set null
line 4:29 no viable alternative at character 't'
line 4:30 mismatched character ';' expecting set null
line 5:7 mismatched character 'R' expecting set null

Besides of this, the grammar does what I want it to do, but I don’t really trust it.
I appended a test-file, that gets recognized the way I want.

Thanks,
Markus

PS: Since PL/SQL can have nested BEGIN…END-blocks I will have to include a mechanism to count  the BEGINs and ENDs. I am thinking about a counter, that gets incremented, when the lexer finds a BEGIN and decrements when it finds an END. Would you recommend this or do you know a better way?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PLSQLSplitter.g
Type: application/octet-stream
Size: 2471 bytes
Desc: PLSQLSplitter.g
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20100624/5bff76c5/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.sql
Type: application/octet-stream
Size: 356 bytes
Desc: test.sql
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20100624/5bff76c5/attachment-0001.obj 


More information about the antlr-interest mailing list