borischumichev / modelicasublimetextpackage Goto Github PK
View Code? Open in Web Editor NEWSyntax definitions for the Modelica language
License: MIT License
Syntax definitions for the Modelica language
License: MIT License
In some cases a semicolon in the annotation is wrongly detected as ending the annotation.
http://bit.ly/1k6XR3U
As a fix, only assume you found the end of the annotation if you found a semicolon with a parantheses before it.
within Modelica.Thermal;
package HeatTransfer
"Library of 1-dimensional heat transfer with lumped elements"
annotation (version="1.1", versionDate="2005-06-13",
preferedView="info", Icon(
Polygon(points=[-54, -6; -61, -7; -75, -15; -79, -24; -80, -34; -78, -42;
-73, -49; -64, -51; -57, -51; -47, -50; -41, -43; -38, -35; -40,
-27; -40, -20; -42, -13; -47, -7; -54, -5; -54, -6], style(color=10,
fillColor=8)),
Polygon(points=[-75, -15; -79, -25; -80, -34; -78, -42; -72, -49; -64, -
51; -57, -51; -47, -50; -57, -47; -65, -45; -71, -40; -74, -33; -76,
-23; -75, -15; -75, -15], style(color=0, fillColor=9)),
Polygon(points=[39, -6; 32, -7; 18, -15; 14, -24; 13, -34; 15, -42; 20, -
49; 29, -51; 36, -51; 46, -50; 52, -43; 55, -35; 53, -27; 53, -20;
51, -13; 46, -7; 39, -5; 39, -6], style(color=9, fillColor=8)),
Polygon(points=[18, -15; 14, -25; 13, -34; 15, -42; 21, -49; 29, -51; 36,
-51; 46, -50; 36, -47; 28, -45; 22, -40; 19, -33; 17, -23; 18, -
15; 18, -15], style(color=0, fillColor=9)),
Polygon(points=[-9, -23; -9, -10; 18, -17; -9, -23], style(
color=42,
fillColor=42,
fillPattern=1)),
Line(points=[-41, -17; -9, -17], style(color=42, thickness=2)),
Line(points=[-17, -40; 15, -40], style(color=42, thickness=2)),
Polygon(points=[-17, -46; -17, -34; -40, -40; -17, -46], style(
color=42,
fillColor=42,
fillPattern=1))));
end HeatTransfer;
Thanks for sharing this Package, I just installed Sublime and your Package, maybe I will completely switch from Notepad++.
I found one small problem: If there is a semicolon in the annotation(Documentation(info
then the highlighting as comment is turned off for the following lines.
See this Lightshow example:
http://bit.ly/1LEnEHJ
or just the code below:
within ;
model SurfaceToAir "cool model"
Modelica.Electrical.Analog.Basic.Resistor inRes[3,3];
Modelica.Electrical.Analog.Basic.Resistor outRes[3,3];
equation
for j in 1:3 loop
for k in 1:3 loop
if inRes[j,k].R > 0 then
outRes[j,k].R = Modelica.Math.cos(inRes[j,k].R - inRes[k,j].R);
elseif inRes[j, k].R > 2 then
outRes[j,k].R = Modelica.Math.cos( inRes[j,k].R - inRes[k,j].R);
elseif inRes[j, k].R > 3 then
outRes[j,k].R = Modelica.Math.sin(inRes[j, k].R - inRes[k,j].R);
else
outRes[j,k].R = 0;
end if;
end for;
end for;
annotation (uses(Modelica(version="3.2.1")));
end SurfaceToAir;
This package could also register .mof extension. Currently I manually tell sublime to use Modelica synatax highlight for dsmodel.mof file.
constraint
and optimization
should be keywords, like equation
and algorithm
are.
These terms are used in optimization. See here for details.
Just curious.
Thanks
You could add two more snippets:
while
/* */
block commentenumeration
should be a highlighted keyword, in the storage.type
context.
Modelica language allows for qualifying parameters as inner
or outer
, but this package does not highlight them.
As pointed out by @tbeu in modelica-3rdparty/Modelica_DeviceDrivers#77 the closing parantheses in the enumeration is not highlighted correctly.
Also see http://bit.ly/1ynaPQT
Just an idea:
As your package is also used for the github syntax highlight,
you could mention that somewhere and possibly add a link to
https://github.com/github/linguist
and especially to Lightshow:
https://github-lightshow.herokuapp.com/
https://github.com/github/linguist/blob/master/CONTRIBUTING.md#fixing-syntax-highlighting
The Modelica spec allows QIdent strings with S-Escape as variable names,
but they are not highlighted correctly.
See this gist for an example:
https://gist.github.com/thorade/133928e8476df5ca3bb6591bacfcc937
Currently, normal strings are highlighted in the same color as the documentation string that can be given at the end of every variable declaration.
parameter String myString="some text" "documentation string";
Here is another example: http://bit.ly/1LNTK7t
One could discuss, whether the documentation string should rather have the same color as comments.
See fix in pull request: #16
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.