Recent

Author Topic: SynEdit Implementing New languages  (Read 4300 times)

Saylo_49

  • New Member
  • *
  • Posts: 43
SynEdit Implementing New languages
« 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#, ...
Lazarus 2.0.2 - FPC 3.0.4 - Win32

john horst

  • Jr. Member
  • **
  • Posts: 68
    • JHorst
Re: SynEdit Implementing New languages
« Reply #1 on: March 16, 2019, 12:33:53 am »
http://wiki.lazarus.freepascal.org/SynEdit_Highlighter

I don't know about if anyone is working on newer ones.

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: SynEdit Implementing New languages
« Reply #2 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.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: SynEdit Implementing New languages
« Reply #3 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.

maurobio

  • Hero Member
  • *****
  • Posts: 623
  • Ecology is everything.
    • GitHub
Re: SynEdit Implementing New languages
« Reply #4 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!
« Last Edit: November 03, 2019, 12:25:32 pm by maurobio »
UCSD Pascal / Burroughs 6700 / Master Control Program
Delphi 7.0 Personal Edition
Lazarus 2.0.12 - FPC 3.2.0 on GNU/Linux Mint 19.1, Lubuntu 18.04, Windows XP SP3, Windows 7 Professional, Windows 10 Home

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: SynEdit Implementing New languages
« Reply #5 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

maurobio

  • Hero Member
  • *****
  • Posts: 623
  • Ecology is everything.
    • GitHub
Re: SynEdit Implementing New languages
« Reply #6 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/).

Best regards,
UCSD Pascal / Burroughs 6700 / Master Control Program
Delphi 7.0 Personal Edition
Lazarus 2.0.12 - FPC 3.2.0 on GNU/Linux Mint 19.1, Lubuntu 18.04, Windows XP SP3, Windows 7 Professional, Windows 10 Home

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: SynEdit Implementing New languages
« Reply #7 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.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

maurobio

  • Hero Member
  • *****
  • Posts: 623
  • Ecology is everything.
    • GitHub
Re: SynEdit Implementing New languages
« Reply #8 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,
UCSD Pascal / Burroughs 6700 / Master Control Program
Delphi 7.0 Personal Edition
Lazarus 2.0.12 - FPC 3.2.0 on GNU/Linux Mint 19.1, Lubuntu 18.04, Windows XP SP3, Windows 7 Professional, Windows 10 Home

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: SynEdit Implementing New languages
« Reply #9 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>
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

maurobio

  • Hero Member
  • *****
  • Posts: 623
  • Ecology is everything.
    • GitHub
Re: SynEdit Implementing New languages
« Reply #10 on: November 05, 2019, 01:32:27 am »
Thanks! Please forgive me, I haven't read the docs yet.  ;D
UCSD Pascal / Burroughs 6700 / Master Control Program
Delphi 7.0 Personal Edition
Lazarus 2.0.12 - FPC 3.2.0 on GNU/Linux Mint 19.1, Lubuntu 18.04, Windows XP SP3, Windows 7 Professional, Windows 10 Home

 

TinyPortal © 2005-2018