nom-sql
nom-sql copied to clipboard
Add support for comments
It would be nice to be able to parse SQL statements with comments in them.
Example
create--blah blah
table--blah blah
tt--blah blah
(--blah blah
x--blah blah
)--blah blah
;
Agreed -- and support for /* ... */-style comments would also be nice.
The best way to do this is perhaps to pre-process the entire input string with a parse rule (or regex) that removes all comments before running through the normal parser sequence.
I'll try to implement this when I get a chance -- probably not for another two weeks or so, though.
I'm not sure this can be done with a simple input preprocessing rule. How would you handle cases such as :
select '
-- this is not an SQL comment
';
or
INSERT INTO t VALUES ('/*', '*/');
or
se/**/lect 0;