modelica-tools / atom-language-modelica

Modelica language support for the atom editor
https://atom.io/packages/language-modelica
Other
8 stars 4 forks source link

Add snippets for ModelicaScript #34

Closed lochel closed 7 years ago

thorade commented 7 years ago

Do OpenModelica and Dymola use the same scripting language? What about other tools?

lochel commented 7 years ago

No, unfortunately there is no standardized Modelica scripting language. Each tool vendor does it differently.

bilderbuchi commented 7 years ago

I must admit, I haven't used Modelicascript much until now, but is it really designed in such a way that you have to append getErrorString() to every command? How did that situation arise? It doesn't feel very elegant/useful...

lochel commented 7 years ago

Well, I agree. However, I would really recommend to do it like that, because otherwise it could easily happen that you will miss some errors. If you don't want to have the getErrorString(); statement after a command, you could just override it. Therefore, it will be automatically selected. Just hit the tab key to jump right behind the getErrorString(); statement or type whatever you want to override it with.

bilderbuchi commented 7 years ago

thank you. it was not meant as a criticism of the snippets or that I don't want it, it just surprised me, as I've never seen this design/necessity before in other languages. It looks very cumbersome.

lochel commented 7 years ago

it just surprised me, as I've never seen this design/necessity before in other languages. It looks very cumbersome.

I totally agree.

lochel commented 7 years ago

I've cleaned up this PR and fixed the getErrorString snippet. If no one complains, I would be happy if we could merge this.

thorade commented 7 years ago

My only complaint is that this is specific to OpenModelica, so I am not sure whether this should be included in a "general" Modelica package. Plus, I don't know who should decide such things, as there is no official maintainer. To be pragmatic, this could be included here until someone wants to include Dymola-mos-script instead. Once that happens, the scripting language grammar+snippets for each tool have to be moved into independent packages (or someone suggests an alternative solution).

If nobody complains, I would merge this later today or tomorrow and publish another release.

lochel commented 7 years ago

Well, as I remember correctly the entire repository is based on my OpenModelica inspired atom extension. Thus, also the currently available ModelicaScript snippets are OpenModelica specific. I designed the original package mainly for OpenModelica/MetaModelica development. So maybe we should split up this development into a Modelica and a OpenModelica package. However, then we would have even less contributions to both of them …

lochel commented 7 years ago

It would be quite nice if one could add some configuration options to the package settings to select a specific Modelica tool. Then we could just have a single package providing ModelicaScripting for different tools. However, as long as there is no request we could just keep it as it is.

bilderbuchi commented 7 years ago

maybe you can put more details in the language scope (i.e. instead of .source.modelicascript, you could have one set with .source.modelicascript.OM and one for .source.modelicascript.dymola, with some toggle for the correct grammar of a .mos file?

thorade commented 7 years ago

Saying that the entire repository is based on your extension is of course not correct, as the original Modelica grammars were written by Raphael and Boris and then there are also the contributions by Tom, and all these are not tool specific. So I assume you are talking about the modelicascript grammar that is already included (and that I forgot about in my previous comments). As that is indeed OpenModelica specific already, I am fine with also having OpenModelica specific snippets. And once someone contributes a scripting language grammar+snippets for another tool, the scripting languages either have to be split off into a different package, or some kind of switch has to be implemented.

lochel commented 7 years ago

Saying that the entire repository is based on your extension is of course not correct, as the original Modelica grammars were written by Raphael and Boris and then there are also the contributions by Tom, and all these are not tool specific.

Sure, that is completely true.

And once someone contributes a scripting language grammar+snippets for another tool, the scripting languages either have to be split off into a different package, or some kind of switch has to be implemented.

I would like to have a switch to select a specific tool. However, I don’t know how to do that. As I said, we could think about it once someone requests this.

bilderbuchi commented 7 years ago

I don’t know how to do that

did you see my comment above? Would that be a feasible approach? I don't know if you can nest language scopes like that, and if that works seamlessly with the rest of the grammar.

thorade commented 7 years ago

@bilderbuchi that looks like it could work, but currently we only have a grammar+snippets for OM scripts, so switching is currently not really helpful.

bilderbuchi commented 7 years ago

of course not, but if that approach works this PR could be merged as-is, and an "easy" path for extending to further dialects would be available (so you could put that info in a note for interested dymola contributors, or whatnot).

thorade commented 7 years ago

Let's try the switching in a new branch & pull request and merge this as it is for now.

lochel commented 7 years ago

@thorade Thanks for the new release.