Re: Parsing SQL Statements and retaining comments
- From: AC <user@xxxxxxxxxxxxxx>
- Date: Sat, 24 Mar 2007 15:47:49 GMT
sqlpgmr@xxxxxxxxx wrote:
I'm trying to parse my sql statements and i've to retain the
indentation and the comments in the SQL statements. Currently \n, \t
and \* are parsed as special tokens.
Any help on how to retain the comments and indentation after
parsing ??
Parse all whitespace as well as comments as special tokens.
For comments, see the example java grammar (included with Javacc) for
one way to parse a multiline /*....*/ comment as a single special token.
(It uses lexical states: when tokenizer reaches "/*" it enters state
IN_MULTILINE_COMMENT, and then uses a match-all-chars (<~[]>) 'more'
production to add characters to the token buffer, except when it reaches
"*/", it takes the whole buffer and makes a single special token and
returns the the DEFAULT state. Production order is important, the
match-all-chars production must be after the terminating "*/" production).
Hope his helps!
.
- References:
- Parsing SQL Statements and retaining comments
- From: sqlpgmr
- Parsing SQL Statements and retaining comments
- Prev by Date: Parsing SQL Statements and retaining comments
- Next by Date: How to create postfix operators?
- Previous by thread: Parsing SQL Statements and retaining comments
- Next by thread: How to create postfix operators?
- Index(es):