andreaspirklbauer / Oberon-enhanced-Oberon07-compiler

Enhanced Oberon-07-compiler for the Project Oberon 2013 operating system
5 stars 0 forks source link

Compiler bug ? #1

Closed markmpx closed 5 years ago

markmpx commented 5 years ago

Andreas,

I am unsure why the following code does not compile on your compiler. Any ideas ?

MODULE Soundex;

CONST iterations = 100000;

PROCEDURE SoundexIf(ch: CHAR): INTEGER; VAR value: INTEGER; BEGIN IF (ch = "A") OR (ch = "E") OR (ch = "I") OR (ch = "O") OR (ch = "U") OR (ch = "H") OR (ch = "W") OR (ch = "Y") THEN value := 0 ELSIF (ch = "B") OR (ch = "F") OR (ch = "P") OR (ch = "V") THEN value := 1 ELSIF (ch = "C") OR (ch = "G") OR (ch = "J") OR (ch = "K") OR (ch = "Q") OR (ch = "S") OR (ch = "X") OR (ch = "Z") THEN value := 2 ELSIF (ch = "D") OR (ch = "T") THEN value := 3 ELSIF (ch = "L") THEN value := 4 ELSIF (ch = "M") OR (ch = "N") THEN value := 5 ELSIF (ch = "R") THEN value := 6 END; RETURN value; END SoundexIf;

END Soundex.

andreaspirklbauer commented 5 years ago

Dear Mark,

this has nothing to do with the enhanced FPGA Oberon-07 compiler. The official Oberon-07 compiler in FPGA Oberon, as published on www.projectoberon.com, issues the same error message.

According to section 4 of https://www.inf.ethz.ch/personal/wirth/Oberon/Oberon07.pdf, the result specification (i.e. the RETURN statement) is now syntactically a part of the procedure declaration, and vanishes as an independent statement form.

Therefore, if you remove the last ";" after the RETURN statement, it will work.

Regards, Andreas

markmpx commented 5 years ago

Thanks very much.