Lazarus

Programming => Packages and Libraries => SynEdit => Topic started by: Saylo_49 on March 15, 2019, 08:34:09 pm

Title: SynEdit Implementing New languages
Post by: Saylo_49 on March 15, 2019, 08:34:09 pm
Hello everyone  :)  :) :)
I have a few questions about SynEdit component

1/ The code folding feature for each language
Is it implemented in the SynEdit main component (The editor) OR it is implemented in the Language highlighting units (The highlighters)

2/ Does anyone trying or working actually on adding highlighters for new languages, like Go, Groovy, Elixir, Swift, F#, ...
Title: Re: SynEdit Implementing New languages
Post by: john horst on March 16, 2019, 12:33:53 am
http://wiki.lazarus.freepascal.org/SynEdit_Highlighter (http://wiki.lazarus.freepascal.org/SynEdit_Highlighter)

I don't know about if anyone is working on newer ones.
Title: Re: SynEdit Implementing New languages
Post by: Edson on March 16, 2019, 04:22:57 am
1/ The code folding feature for each language
Is it implemented in the SynEdit main component (The editor) OR it is implemented in the Language highlighting units (The highlighters)

2/ Does anyone trying or working actually on adding highlighters for new languages, like Go, Groovy, Elixir, Swift, F#, ...

1) Code folding is implemented in highlighters.
2) Yes. I remember some people have implemented new custom highlighters. I did too.

If you want to create highlighters for new languages, you can use my scriptable highlighter https://github.com/t-edson/SynFacilSyn
It includes blocks definition and code folding.
Title: Re: SynEdit Implementing New languages
Post by: Martin_fr on March 16, 2019, 05:21:53 am
The link John posted is a tutorial.
The sample sources are in the lazarus install folder, in the subfolder examples.
Title: Re: SynEdit Implementing New languages
Post by: maurobio on November 03, 2019, 12:21:34 pm
Hi,

I intend to use the SynAnySyn component for implementing syntax highlighting for R. Has someone already done that? Should SynFacilSyn be a better alternative? It really looks great!

Thanks!
Title: Re: SynEdit Implementing New languages
Post by: Martin_fr on November 03, 2019, 12:26:01 pm
SynAnySyn is probably slow (i.e. if you get to have 10000 lines).
It is more a sample / proof of concept.

If SynFacilAny works for you => good.

Otherwise look at the tutorial to write your own https://wiki.lazarus.freepascal.org/SynEdit_Highlighter
Title: Re: SynEdit Implementing New languages
Post by: maurobio on November 03, 2019, 12:39:19 pm
Thanks again, @Martin_fr! As far as I can see, SynFacilAny seems to be simple and fast. In fact, in my case even SynAnySyn would do, as R scripts are typically very small, so speed is not a concern.

I really see no need to create a specific highlighter, as R is a simple language with just a few reserved words (https://www.datamentor.io/r-programming/reserved-words/ (https://www.datamentor.io/r-programming/reserved-words/)).

Best regards,
Title: Re: SynEdit Implementing New languages
Post by: Edson on November 04, 2019, 06:23:33 am
SynFacilSyn is probably the best option for creating new highlighters in SynEdit, because:

* It's fast, flexible and simple.
* It's well documented.
* It can define code folding too.
* It can be used as lexer.
* It can include code-completion if you migrate later to SynFacilCompletion.
Title: Re: SynEdit Implementing New languages
Post by: maurobio on November 04, 2019, 03:48:29 pm
@Edson,

Yes, thanks! And I would add the convenience of configuring keywords by means of a simple XML file.

BTW, is there a way to make the highlighter case-sensitive? For example, suppose I have a command language with such commands as: *OUTPUT FILE output.txt, where *OUTPUT FILE is a command and output.txt is a command parameter. How to tell the highlighter to recognize (and highlight) only the words in UPPER CASE?

Cheers,
Title: Re: SynEdit Implementing New languages
Post by: Edson on November 05, 2019, 12:56:07 am
BTW, is there a way to make the highlighter case-sensitive? For example, suppose I have a command language with such commands as: *OUTPUT FILE output.txt, where *OUTPUT FILE is a command and output.txt is a command parameter. How to tell the highlighter to recognize (and highlight) only the words in UPPER CASE?

According to documentation, you can use parameter "CaseSensitive":

Code: XML  [Select][+][-]
  1. <Language name="pascal" ext="pas pp" CaseSensitive="TRUE">
  2.  
  3. </Language>
Title: Re: SynEdit Implementing New languages
Post by: maurobio on November 05, 2019, 01:32:27 am
Thanks! Please forgive me, I haven't read the docs yet.  ;D
TinyPortal © 2005-2018