Author Topic: Adding new language to SE  (Read 314 times)

asandler

  • Senior Community Member
  • Posts: 279
  • Hero Points: 24
Adding new language to SE
« on: May 12, 2018, 06:07:20 pm »
I am trying to add support for TLA+. I found this:
http://blog.slickedit.com/2008/05/tutorial-adding-language-support-to-slickedit/
How accurate this information, today? For example Step 5 refers to _CreateLanguage(), but I don't see this function used anywhere else. I've modified the code a little, leaving only defload(). It did add new language and new file extension, but Color Coding information is empty? Am I doing something wrong?
Thanks

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4175
  • Hero Points: 300
Re: Adding new language to SE
« Reply #1 on: May 13, 2018, 01:56:47 am »
If you want to add a language and color coding for the language, it’s easier to just use the GUI for both of these. You only need to write macro code for tagging and smart indenting.

I haven’t checked the _CreateLanguage function to see if it correctly converts the language options string. The color coding dialog has an import button which supports loading the old VLX profiles if you have one. That format is no where near as powerful as the new color coding XML format.

asandler

  • Senior Community Member
  • Posts: 279
  • Hero Points: 24
Re: Adding new language to SE
« Reply #2 on: May 13, 2018, 12:34:20 pm »
Two follow up questions:
1. What is the most convenient way to export (and import) new language that I added via UI?
2. Is there a simple language that I can reverse engineer to understand how to add new language programmatically (for the sake of tagging and smart indenting)? Presumably if I look at how C or C++ is implemented, it would have too many details, so I need something more compact that I can read.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4175
  • Hero Points: 300
Re: Adding new language to SE
« Reply #3 on: May 13, 2018, 03:11:54 pm »
Use export and choose to export just your new language settings. Importing your support will take two steps. First use import to import what you exported. Then load your macro file support. In the future, you will be able to package this stuff as a plugin and load them in one step.

Adding really good smart editing support is pretty difficult. There isn’t a perfect sample that’s right for all languages for sure. For example, a language like scala where statements are rarely terminated with a semicolon are almost impossible to implement smart indenting without a full statement parser. With a full statement parser, it’s easy. Easier than C++. Writing a full parser like this is a large task even for us.

Is this language very similar to any other language SlickEdit already has support for?

asandler

  • Senior Community Member
  • Posts: 279
  • Hero Points: 24
Re: Adding new language to SE
« Reply #4 on: May 13, 2018, 11:54:59 pm »
Quote
Is this language very similar to any other language SlickEdit already has support for?

To some extent. It's a weird mixture of TeX, some very special set of operators and a bunch of key words like VARIABLE, CONSTANT.
Here's a short example: https://github.com/tlaplus/Examples/blob/master/specifications/SpecifyingSystems/FIFO/Channel.tla
There are many other examples in this repository.
It might be interesting to be able to navigate to predicates defined with '==' operator. I.e. in the example above, to be able to go from inside of Next to Send(d).

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4175
  • Hero Points: 300
Re: Adding new language to SE
« Reply #5 on: May 14, 2018, 01:15:10 am »
This language is quite a bit different. Looks like it’s two languages (PlusCal and TLA+). I think you need to define support for two languages to do this right. That way PlusCal is simply an embedded language referenced by your TLA+ color coding profile. The color coding for this isn’t hard to do once you know this trick. Define two color coding profiles and have TLA+ reference the other. If you get that far, I can give you pictures of the GUI color coding settings for defining “(* —“ ... ”*)” which will reference the PlusCal color coding profile.

I think the pascal smart indenting may be the best example for PlusCal (see pascal_enter and pascal_space). Since TLA+ doesn’t have an easy statement terminator, there really won’t be any sample code that will help a lot. You could do nothing or gut the pascal code and search for an operator to indent when you press enter.

For tagging, it’s definitely possible to pick up some symbols with regex searches in a proc_search function. You’ve got two languages here though.

asandler

  • Senior Community Member
  • Posts: 279
  • Hero Points: 24
Re: Adding new language to SE
« Reply #6 on: May 15, 2018, 12:23:04 am »
I am not particularly interested in PlusCal. It is more programmer friendly language than TLA+, but all it allows you to do is to generate TLA+ spec for your model. I am writing in TLA+ directly.

If you were ever to officially support TLA+, you'd probably have to support PlusCal as well.

Thanks for the tip regarding Pascal. I'll take a look.