Opened 15 years ago

Last modified 15 years ago

#1112 closed defect (fixed)

Parser accepts syntax errors in matchcontinue expressions

Reported by: Martin Sjölund Owned by: Martin Sjölund
Priority: normal Milestone:
Component: Version:
Keywords: Cc: Martin Sjölund,

Description

The following expression triggers a parser error for .mo file, but is accepted using loadFile in a script (the resulting function is empty, but does exist).
The bootstrapping branch has a test case for this (MatchCase10).

b := matchcontinue (a)
case i local i then 100; local Integer i; is the proper way to type. Parser should give an error.
end matchcontinue;

martin@vbox:~/dev/Bootstrapping/testsuite/meta$ ./omcd +g=MetaModelica +d=failtrace,matchcase MatchCase10.mo
MatchCase10.mo:7:20-7:30:writable Error: unexpected token: i, parsing resumed at token ';' on line 7, column 30
MatchCase10.mo:8:5-8:22:writable Error: unexpected token: end, parsing resumed at token ';' on line 8, column 22

martin@vbox:~/dev/Bootstrapping/testsuite/meta$ ./omcd +g=MetaModelica +d=failtrace,matchcase MatchCase10.mos
true
1
record SimulationResult

resultFile = "MatchCase10_res.plt"

end SimulationResult;
-1078418808.0
0

Change History (1)

comment:1 by Adrian Pop, 15 years ago

Hi,

The parser function ALWAYS succeeds. Is made to be like that.
It tries to recover at known terminals (; end, etc) and continue
parsing even if a wrong AST is generated.
You need to call getErrorString() after each loadFile()
to find out if there were any parsing errors after the parsing.

Cheers,
Adrian Pop/

Note: See TracTickets for help on using tickets.