OpenModelica / OpenModelica

OpenModelica is an open-source Modelica-based modeling and simulation environment intended for industrial and academic usage.
https://openmodelica.org
Other
816 stars 305 forks source link

OMEdit quoted identifiers breaking highlighting #12266

Open AnHeuermann opened 5 months ago

AnHeuermann commented 5 months ago

Description

Quoted identifiers are breaking the syntax highlighting.

Steps to Reproduce

Insert in the text view of OMEdit

model QuotedIdentifier
  Real 'a"b';
  Real 'c d';
  Real 'e"f g';
  Real 'h\'i //j';
  Real '\\\\\'';
  Real '';
  Real '*/ no code injection';
  Real '\'';
equation
  der('a"b') = 1;
  der('c d') = -1;
  der('e"f g') = 2;
  der('h\'i //j') = -2;
  der('\\\\\'') = 3;
  der('') = -3;
  der('*/ no code injection') = 4;
  der('\'') = -4;
end QuotedIdentifier;

grafik

Expected Behavior

Something like this:

grafik

Version and OS

casella commented 5 months ago

@adeas31 as I understand you should ignore " and // in the syntax highlighting logic if they are inside a Q-IDENT.

casella commented 5 months ago

Oops, I ran Check on @AnHeuermann's provided model and I got this error:

[1] 23:37:41 Syntax Error
[M: 2:11-2:11]: Lexer got ''a"' but failed to recognize the rest: 'b';
  Real '

So it looks like putting comments and literal string delimiters in Q-IDENTS also breaks the lexer, not only syntax highlighting.

AnHeuermann commented 5 months ago

I fixed that yesterday and added the above model as a test. Maybe try again or is it a Windows thing?

casella commented 5 months ago

I guess I should try with a new nightly build 😅

casella commented 5 months ago

OK with the new nightly the lexer issue is fixed. The syntax highlighting issue is still there. BTW, I ran the model and I also go

Process crashed Simulation process failed. Exited with code 0xffffffffc0000005.
Failed to parse QuotedIdentifier_info.json
Expected ']', got: b'"],"uses":["$START 
Process crashed

@AnHeuermann would you mind having a look at that?

AnHeuermann commented 5 months ago

I'll have a look.