Can't you determine a new case by looking for ":"? (which would end the previous case)
That is part of the problem. The parser sees the integer for the case number and thinks it is starting a new expression and then it sees the ':' and that doesn't belong.
Other languages have problems with the 'dangling' IF ELSE. This occurs when
IF expr stmt IF expr stmt ELSE stmt
Does the else go with the first or second IF. ST makes this easy because there is an END_IF which makes it clear. I am suffering the from the same problem but now it is a CASE OF statement.
Couldn't you "just" extend the IEC spec. and implement some of the features that it lacks?
No, I am kind of a purist.
Wouldn't it still conform to the IEC spec?
No.
The Yacc and Bison parser generators are 'standard' tools but they aren't very good. I previous compiler writer didn't use Yacc or Bison and he rolled his own parser just to avoid these problems.
My IL will have the ability to do more complex expressions since it will borrow from the ST compiler. IL doesn't say how indirect address should be implemented. These kind of things drive me nuts as it is such an obvious oversight. So I am going to allow ST expressions as the operand.
Doing all the indirect addressing in IL would be messy. I see this as one of the biggest weaknesses of Siemens' STL. Too much time/effort is spent on how to do the indirect addressing.
I will write again when I have more progress. The point is that the key words like END_CASE, END_IF and begin and end in Pascal make life much easier for the compiler writer and without them it is hard to define a grammar that is easy to parse.