Fr0sT.Brutal 900 Posted August 10, 2021 16 hours ago, mvanrijnen said: Would be nice to have a common parser what you posted in your startpost, something with a base class which does the basic parsing of the query, and which can be extended in execution functionality . There are tons of various parsers. The problem is the syntax required - everyone could need a different one. Moreover, the more specific parser is, the more efficient it appears. Sometimes you don't even need to write a parser - just define the grammar and generate parser code from it. Alas, I'm not aware of such possibility for Delphi. Share this post Link to post
darnocian 87 Posted August 10, 2021 1 hour ago, Fr0sT.Brutal said: Sometimes you don't even need to write a parser - just define the grammar and generate parser code from it. Alas, I'm not aware of such possibility for Delphi. Do you mean lexer & parser generators like lex&yacc/antlr? Antrl3 has some Delphi support, but Antlr4 hasn't been ported yet. FPC has a TP Lex and TP Yacc - the tools are still available, but the documentation seems to have gone offline. I tried that a while back, but there were too much global state for my liking. Share this post Link to post
Fr0sT.Brutal 900 Posted August 10, 2021 (edited) 3 hours ago, darnocian said: Do you mean lexer & parser generators like lex&yacc/antlr? Yes you're right. Btw RTL has a TParser class but it's intended for reading DFM files. Not a something reusable Edited August 10, 2021 by Fr0sT.Brutal Share this post Link to post
generic 0 Posted August 10, 2021 When you are not able to find a lib that provides the functions you need within delphi, create a webservice and call that from delphi. Also COM server could be a solution for you, when you do not like http. Share this post Link to post
Mike Torrettinni 198 Posted August 10, 2021 12 hours ago, Fr0sT.Brutal said: Sometimes you don't even need to write a parser - just define the grammar and generate parser code from it. Alas, I'm not aware of such possibility for Delphi. Other languages offer such feature? Share this post Link to post
darnocian 87 Posted August 10, 2021 2 hours ago, Mike Torrettinni said: Other languages offer such feature? He was just meaning that in other languages there are more libraries for parser generation… e.g. originally lex and yacc existed for C. flex and bison were the open source equivalents… I personally like antlr as it supports manny languages as targets. Share this post Link to post
darnocian 87 Posted August 10, 2021 9 hours ago, Fr0sT.Brutal said: Btw RTL has a TParser class but it's intended for reading DFM files. Not a something reusable I wasn’t sure if you were referring to the test snippets I posted? in the project I made to illustrate writing the custom parsers, I provided alternative TParser implementations - just thought I’d clarify in case of confusion. Share this post Link to post
Fr0sT.Brutal 900 Posted August 11, 2021 11 hours ago, Mike Torrettinni said: Other languages offer such feature? I'm only aware of C having such generators. 8 hours ago, darnocian said: I wasn’t sure if you were referring to the test snippets I posted? Nope, it was just a note about something slightly related to the subject 🙂 Share this post Link to post
Marat1961 17 Posted September 23, 2021 You can use Coco/R, as I have seen an attributive grammar for a similar sql-like language. Not long ago I made a port on Delphi. I have been using it for a long time and quite actively in my projects. Share this post Link to post