Board index » delphi » Re: Quick SQL parser

Re: Quick SQL parser


2006-04-04 11:24:17 AM
delphi76
Dennis Landi writes:
Quote
I would like to write a method like:

GetTableNamesFromQuery(q_str:string; var tblNames:TStringlist);
You might want to look at what the VCL already has for this in
DBExpr.pas or DB.pas ... something like that.
--
John Kaster blogs.borland.com/johnk
Features and bugs: qc.borland.com
Get source: cc.borland.com
If it is not here, it is not happening: ec.borland.com
 
 

Re: Quick SQL parser

Dennis Landi writes:
Quote
I wonder if anyone in this group has some sql parsing code they would
be willing to share.
Sorry, should have read the whole thread first. Never mind!
--
John Kaster blogs.borland.com/johnk
Features and bugs: qc.borland.com
Get source: cc.borland.com
If it is not here, it is not happening: ec.borland.com
 

Re: Quick SQL parser

John Kaster (Borland) writes:
Quote
You might want to look at what the VCL already has for this in
DBExpr.pas or DB.pas
That's what I figured, too. There should be something that can do what
he wants; I am yet to investigate it completely.
--
Dave Nottage [TeamB]
Have questions?: www.catb.org/~esr/faqs/smart-questions.html
Want answers?: support.borland.com
 

Re: Quick SQL parser

Dave Nottage [TeamB] writes:
Quote
That's what I figured, too. There should be something that can do what
he wants; I am yet to investigate it completely.
Or just write it :)
If there is something Delphi excels at, it is writing string parsers.
--
Ingvar Nilsen
www.ingvarius.com
 

Re: Quick SQL parser

Quote
If there is something Delphi excels at, it is writing string parsers.
Actually, that is not true. Functional languages are far and away the easiest
way I have come across to do that sort of thing.
Hand-writing recursive descent parsers is not that difficult if you can define
the grammar in BNF though.
(I think "string parser" is redundant, BTW. Just "parser" is probably sufficient
<g>)
Cheers,
Jim Cooper
_____________________________________________
Jim Cooper XXXX@XXXXX.COM
Skype : jim.cooper
Tabdee Ltd www.tabdee.ltd.uk
TurboSync - Connecting Delphi to your Palm
_____________________________________________
 

Re: Quick SQL parser

Jim Cooper writes:
Quote


>If there is something Delphi excels at, it is writing string
>parsers.

Actually, that is not true.
Using "true" and "false" in this context will never be.. eh.. true <g>
Quote
Functional languages are far and away the
easiest way I have come across to do that sort of thing.
Yes, but I may have come across different things than you!
I know what you mean. But I still admire the development speed one
achieve with Delphi even if "modern" languages have strings as objects
with built in methods etc.
One thing I really like is Delphi treating chars the same way as
strings in many ways and the ability to type in the ASCII value of a
character directly, like 'This is the first line,'#13#10'this is the
second'
With an academic approach to programming tasks, Delphi may perhaps lose
today, in real practical life, I feel it often is a real winner, also
D7 still.
FTR, I program very much in VS 2005 and C# these days.
Quote
Hand-writing recursive descent parsers is not that difficult if you
can define the grammar in BNF though.
Huh? What is BNF? I might know what is is, but the acronym is
unfamiliar!
--
Ingvar Nilsen
www.ingvarius.com
 

Re: Quick SQL parser

On Mon, 03 Apr 2006 09:11:56 -0400, Dennis Landi
<XXXX@XXXXX.COM>writes:
Quote
GetTableNamesFromQuery(q_str:string; var tblNames:TStringlist);
Not directly related, but we're in non tech so ;)
I'm not picking on you specifically Dennis, but I would like to know why
do so many put "var" in front of objects like that? To me, that is bad
design. The stringlist should be created by the caller and not
modified by the method. Or did I miss something big?
- Asbjørn
 

Re: Quick SQL parser

Lord Crc writes:
Quote
On Mon, 03 Apr 2006 09:11:56 -0400, Dennis Landi
<XXXX@XXXXX.COM>writes:

>GetTableNamesFromQuery(q_str:string; var tblNames:TStringlist);

Not directly related, but we're in non tech so ;)

I'm not picking on you specifically Dennis, but I would like to know why
do so many put "var" in front of objects like that? To me, that is bad
design. The stringlist should be created by the caller and not
modified by the method. Or did I miss something big?
You can modify the stringlist as much as you want, regardless of the
"var", tblNames is a dereferenced pointer to the TStringList instance
so "var" in this case has no meaning as far as I can tell, "var" in
front of objects serve no purpose at all.
Or?
--
Ingvar Nilsen
www.ingvarius.com
 

Re: Quick SQL parser

"Ingvar Nilsen" <XXXX@XXXXX.COM>wrote in news:44326b00$1
@newsgroups.borland.com:
Quote
Huh? What is BNF? I might know what is is, but the acronym is
unfamiliar!
www.garshol.priv.no/download/text/bnf.html
Backus-Naur notation (more commonly known as BNF or Backus-Naur Form) is
a formal mathematical way to describe a language, which was developed by
John Backus (and possibly Peter Naur as well) to describe the syntax of
the Algol 60 programming language.
--
Iman
 

Re: Quick SQL parser

Ingvar Nilsen writes:
Quote
Huh? What is BNF? I might know what is is, but the acronym is
unfamiliar!
Backus-Naur form, en.wikipedia.org/wiki/Backus-Naur_form
--
Anders Isaksson, Sweden
BlockCAD: web.telia.com/~u16122508/proglego.htm
Gallery: web.telia.com/~u16122508/gallery/index.htm
 

Re: Quick SQL parser

"Ingvar Nilsen" <XXXX@XXXXX.COM>wrote in
Quote
so "var" in this case has no meaning as far as I can tell, "var" in
front of objects serve no purpose at all.
Or?
I've never really investigated it, but I think putting var in front of
an object is like passing a pointer to a pointer. I have not made any
effort to retain that kind of thinking from my C days.
--
Iman
 

Re: Quick SQL parser

Ingvar Nilsen writes:
Quote
You can modify the stringlist as much as you want, regardless of the
"var", tblNames is a dereferenced pointer to the TStringList instance
so "var" in this case has no meaning as far as I can tell, "var" in
front of objects serve no purpose at all.
Or?
It has a meaning, just not one you're likely to use. You can modify
the reference without affecting the caller. Whereas with var you modify
the caller's reference.
I tend to use const for object references.
--
Craig Stuntz [TeamB] ?Vertex Systems Corp. ?Columbus, OH
Delphi/InterBase Weblog : blogs.teamb.com/craigstuntz
Borland newsgroup denizen Sergio González has a new CD of
Irish music out, and it is good: tinyurl.com/7hgfr
 

Re: Quick SQL parser

SupportX writes:
Quote
Well, if getTableNamesFromQuery was a function returning success of
failior, it may be logical to create tblNames only if function
succeedes, thus the var.
That is what "out" is for.
--
Ingvar Nilsen
www.ingvarius.com
 

Re: Quick SQL parser

Craig Stuntz [TeamB] writes:
Quote
It has a meaning, just not one you're likely to use. You can modify
the reference without affecting the caller.
Ok, maybe that serves a purpose, I cannot remember using it, but since
I don't use neither const nor var for objects, I am free to do it the
day I find it useful <g>
Quote
Whereas with var you modify the caller's reference.
I cannot remember having done that, if, then very very seldom
Quote
I tend to use const for object references.
Totally superfluous if you ask me. Do you? Ask me that is :-)
--
Ingvar Nilsen
www.ingvarius.com
 

Re: Quick SQL parser

SupportX writes:
Quote
>
>That is what "out" is for.
>

True. but many old-timers still use var. I may be wrong but "out" did
not exist in the early versions of TP or even Delphi.
It came with D3 (?)
--
Ingvar Nilsen
www.ingvarius.com