Programming => Packages and Libraries => SynEdit => Topic started by: jcmontherock on September 09, 2021, 09:13:46 pm
Title: Parsing SQL scripts with SynHighlighterSQL
Post by: jcmontherock on September 09, 2021, 09:13:46 pm
I try to parse a sql file containing several scripts. I am using SynHighlighterSQL. Every tests I did, were OK, except one thing: the hash char (#) is not taken in account. This char is used for comments in dialect MySQL. The parser give me ox23 (that's ok) fort token value and tkUnknown for token type. This character has not been defined in procedure TSynSQLSyn.MakeMethodTables.
I am using W10/64 with Lazarus 220Rc1.
Title: Re: Parsing SQL scripts with SynHighlighterSQL
Post by: jcmontherock on September 24, 2021, 03:33:25 pm
Finally, I copied SynHilighterSQL in the project directory and I changed the following:
Title: Re: Parsing SQL scripts with SynHighlighterSQL
Post by: devEric69 on October 09, 2021, 01:53:16 pm
Well, just for the information, if you still have a\some troubles to parse and then check the SQL grammar of your scripts, there is also the fpsqlparser unit (fcl-db package).
Title: Re: Parsing SQL scripts with SynHighlighterSQL
Post by: Edson on October 09, 2021, 05:44:04 pm
Better use SynFacilSyn: https://github.com/t-edson/SynFacilSyn
It's a good lexer and well documented. Check section 5.20 of documentation: "Using the highlighter as lexical analyzer - syntactic". There you will find a basic scanner loop:
Moreover, if you use SynFacilSyn and SynEdit, then you can easily implement code completion using SynFacilCompletion: https://github.com/t-edson/SynFacilCompletion