Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#2096 closed enhancement (invalid)

Lexer message could be clearer

Reported by: maltel Owned by: sjoelund.se
Priority: normal Milestone: 1.9.0
Component: Parser Version: trunk
Keywords: Cc:

Description

This (incorrect) model gives a confusing error message:

model linearOscillator
equation
  when a && b && c then
  end when;
end linearOscillator;
[39] 09:07:12 Syntax error(s) in model afd
afd(3): Lexer failed to recognize '&& b && c t' afd(3): Lexer failed to recognize '& b && c th' afd(3): Lexer failed to recognize '&& c then ' afd(3): Lexer failed to recognize '& c then '

It seems to try different scopes of parsing, and then just accumulates the messages in a confusing way without line breaks.

In an ideal world, this would say something like

"Please use \"and\" for the logical and function on line 3, not \"&&\"."

but something like this is probably more likely/possible:

afd(3): Lexer failed to recognize '&& b && c t'
afd(3): Lexer failed to recognize '& b && c th'
afd(3): Lexer failed to recognize '&& c then '
afd(3): Lexer failed to recognize '& c then '
afd(3): There seems to be a syntax error on line 3.

So, basically adding line breaks in the error message, and telling the user with a clear wording where it finally gave up would be helpful.

Change History (4)

comment:1 Changed 12 years ago by perost

  • Component changed from Frontend to Parser
  • Owner changed from somebody to sjoelund.se

It would be helpful if you could detail the steps to reproduce this. The reason I ask is because if I just run the model through the compiler I get each error message on it's own line, along with filename, line, and column. So while I agree that the error could be better, it can't reproduce the lack of formatting you experienced.

comment:2 Changed 12 years ago by maltel

  • Resolution set to invalid
  • Status changed from new to closed

You are correct, there are indeed "\n"-s in the message. This was a fault on (our) display side, which did not handle line breaks.

Sorry for the incorrect bug report, closing as invalid.

comment:3 Changed 12 years ago by sjoelund.se

Added your ideal world examples to the lexer in r15386.

$ cat a.mo && omc a.mo
model linearOscillator
equation
  when ! a && b || c then
  end when;
end linearOscillator;
/home/marsj/trunk/build/bin/omc 1.9.0 beta4+dev (r15328)
Error processing file: a.mo
[a.mo:3:8-3:9:writable] Error: Please use 'not' for logical not since '!' is not a valid Modelica construct.
[a.mo:3:12-3:14:writable] Error: Please use 'and' for logical and since '&&' is not a valid Modelica construct.
[a.mo:3:17-3:19:writable] Error: Please use 'or' for logical or since '||' is not a valid Modelica construct.

# Error encountered! Exiting...
# Please check the error message and the flags.

Execution failed!

Please tell me if you think a different language for the error-messages would be easier to understand.

comment:4 Changed 12 years ago by maltel

That is a very nice improvement, thanks!

Note: See TracTickets for help on using tickets.