Recent

Author Topic: Comments in TSynAnySyn  (Read 234 times)

linuxfan

  • Jr. Member
  • **
  • Posts: 62
Comments in TSynAnySyn
« on: June 02, 2026, 08:17:19 am »
I am developing and IDE for a language I have invented. And I use TSynAnySyn to hilight the source code. All fine, but I would like to use comments introduced by ";;" (double semicolon) instead of the normal "//" (double slash). The reason is that "//" could be used as operator (integer division? or something else?). Is there a way I can have TSynAnySyn recognize that kind of comment? I also tried to override some methods of TSynAnySyn, but failed. The fact is that FTokenID is private and I can not set it. Is there some other mean? (PS: sorry for the bad formatting, for some reason my browser does not accept Enter and arrow keys... it is written in lazarus with gtk3... :-) )

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12428
  • Debugger - SynEdit - and more
    • wiki
Re: Comments in TSynAnySyn
« Reply #1 on: June 02, 2026, 08:33:39 am »
I don't think there is a way that is meant to be....

If you absolutely must, you can start hacking in "procedure Next" => detect what you need and handle it. But that is very limited, because you can't change the TokenId, or fRange.

If you want to know how a Highlighter works: https://wiki.freepascal.org/SynEdit_Highlighter

That also allows you to very quickly write your own from scratch.



There are other generic HL
- SynFacilSyn (3rd Party / Google). From what I hear very powerful.
- TextMate (using regex) https://wiki.freepascal.org/SynEdit_Highlighter_TextMate


Thaddy

  • Hero Member
  • *****
  • Posts: 19268
  • Glad to be alive.
Re: Comments in TSynAnySyn
« Reply #2 on: June 02, 2026, 11:59:35 am »
https://github.com/t-edson/SynFacilSyn is quite comfortable for your own syntax.
I used it once for NetherPascal here on the forum.
There is good documentation in odt format and you can basically copy over one of the examples and just write  a small xml file with the syntax description.
It is much more configurable than SynAnySyn and just as easy to use.

Very easy to configure single and/or multiline comments as you like.

In your case this would work:
Code: XML  [Select][+][-]
  1. <Comment Start=";;" ></Comment>
This is a single line comment definition.

[edit] do not use: the package SynFacilSyn is currently not in a compilable state with trunk..
I did not know that, until I tried to compile my old example.
« Last Edit: June 02, 2026, 02:53:04 pm by Thaddy »
objects are fine constructs. You can even initialize them with constructors.

linuxfan

  • Jr. Member
  • **
  • Posts: 62
Re: Comments in TSynAnySyn
« Reply #3 on: June 02, 2026, 06:02:32 pm »
Thank you all for the suggestions.

I will try SynFacilSyn, it seems really Facil (easy).


 

TinyPortal © 2005-2018