[antlr-interest] Interesting Problem
richard.hensley at mckesson.com
Thu Sep 12 13:16:17 PDT 2002
I have an interesting parsing problem. I want dig certain context free
constructs out of a file, while ignoring all the other constructs in the
file. My specific case is that I have a file with a bunch of SQL in it,
but all I really care about are the create table statements. The create
table statements I'm concerned with can be parsed with the following
: "create" (ID)* "table" ID LPAREN columns RPAREN
: column (COMMA column)*
: name datatype (ID)*
: ( "varchar" (size)*
| "varchar2" (size)*
| "number" (size)*
| "long" ("raw")*
: LPAREN CARDINAL RPAREN
To solve this problem, I'm thinking of using token stream filters, but I
can't look ahead in a token stream filter so that I could recognize when
I'm in a create table statement.
My basic design would be to use a filter that turns on output of tokens
when in a create table statement, and the parser grammar would have a
semantic rule that would turn off token output when the create table
statement has been fully recognized.
Does anybody have any experience with such a thing?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the antlr-interest