Compiler/code generator: Difference between revisions

Content added Content deleted
(Added Algol 68)
(→‎{{header|ALGOL 68}}: Added some notes.)
Line 261: Line 261:
=={{header|ALGOL 68}}==
=={{header|ALGOL 68}}==
Based on the Algol W sample. This generates .NET IL assembler code which can be compiled with the .NET ilasm assembler to generate an exe that can be run under Windows (and presumably Mono though I haven't tried that).
Based on the Algol W sample. This generates .NET IL assembler code which can be compiled with the .NET ilasm assembler to generate an exe that can be run under Windows (and presumably Mono though I haven't tried that).
<br>
Apart from the namespace, class and method blocks surrounding the code, the main differences between IL and the task's assembly code are: no "compare-le", "compare-ge", "compare-ne", "prts", "prtc", "prti" and "not" instructions, symbolic labels are used and symbolic local variable names can be used. Some IL instructions have different names, e.g. "stloc" instead of "store". The "prt*" instructions are handled by calling the relevant System.Out.Print method. The compare and "not" instructions are handled by generating equivalent instruction sequences. As noted in the code, the generated IL is naive - the sample focuses on simplicity.
<lang algol68># RC Compiler code generator #
<lang algol68># RC Compiler code generator #
COMMENT
COMMENT
Line 269: Line 271:
(Note ilasm may not be in the PATH by default(
(Note ilasm may not be in the PATH by default(


Note: The generated IL is *very* naiive
Note: The generated IL is *very* naive
COMMENT
COMMENT