Recent

Author Topic: Parse SQL for comments  (Read 8822 times)

Edson

  • Hero Member
  • *****
  • Posts: 1330
Re: Parse SQL for comments
« Reply #15 on: May 18, 2016, 09:09:02 pm »
how can I find out what is these commands that it will show is comment or not

It's easy. Just replace the line:
Code: Pascal  [Select][+][-]
  1. ShowMessage(txt);
by:
Code: Pascal  [Select][+][-]
  1. if lastIsComment then ShowMessage('Comment:' + txt) else ShowMessage('Command:' + txt);

Consider that according this code, everything between comments are considered commands, no matter if it's one or multiple SQL sentences.

Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Edson

  • Hero Member
  • *****
  • Posts: 1330
Re: Parse SQL for comments
« Reply #16 on: May 18, 2016, 09:20:36 pm »
a quick question and it seems it is not really about your work and its about SynEdit, why scroll of component seems slow and not smooth as Lazarus editor itself?

I don't notice the difference. Maybe Martin can give us some additional information.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12984
  • FPC developer.
Re: Parse SQL for comments
« Reply #17 on: May 18, 2016, 09:43:04 pm »
Thank you very much for the demo.
It seems maybe Im missing something but how can I find out what is these commands that it will show is comment or not, it now make it parted very good but how can I find out which one of them is runable and with one is comment?

@marcov: how?

My point was that a standard SQL parser won't be any good for parsing sql statements separated by comments only, since that is not valid SQL, and the way you want to fix it (valid SQL separated by commas) happens in two different layers (comments are killed already in the lexer but valid sql is only determined in the parser)

So you will need something custom you probably won't find ready-made. Smartest is to try to find some own set of heuristics to fix it (if comment on new line, and line before is like ... then insert ; or something like it). Parsing theory won't really help you here.

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: Parse SQL for comments
« Reply #18 on: May 18, 2016, 10:22:09 pm »
Thanks to you two especially Edson for the demo, now I have something that I can work with.
@marcov, Thank you so much for helping me everyday, I always use your helps ;)

 

TinyPortal © 2005-2018