nom-sql icon indicating copy to clipboard operation
nom-sql copied to clipboard

Add support for comments

Open lovasoa opened this issue 7 years ago • 2 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
;

lovasoa avatar Sep 16 '18 14:09 lovasoa

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.

ms705 avatar Oct 03 '18 22:10 ms705

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;

lovasoa avatar Oct 08 '18 07:10 lovasoa