[fpc-pascal] Re: Very odd case parsing problem

leledumbo leledumbo_cool at yahoo.co.id
Sun Dec 29 02:23:33 CET 2013


> I can fix that either by putting a semicolon before the else- which I
believe is strictly incorrect

Nope, that's correct. Take a look at the syntax diagram for case statement
here:
http://www.freepascal.org/docs-html/ref/refsu50.html

As you can see, each "case" is terminated by ";". From the parser point of
view, your code is exactly parsed as:

try
  case parseCommand(selector) of 
    help: begin 
    end; 
    help_: begin 
    end; 
    quit_: if High(lexemeListArray) = 1 then begin 
    end else <there should be a statement here> <there should be a semicolon
here>
  end // line 323 
finally 
end;

So that else after begin-end pair of the if statement becomes the else of
the if statement, not the case statement.



--
View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Very-odd-case-parsing-problem-tp5717723p5717724.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.



More information about the fpc-pascal mailing list