Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
Last updated: Mon 4 Mar 2024 08:22:03 AEST.
Compiling the PL0 compiler
Sections in blue refer to the compilers used for assignments 2 and 3, so ignore the blue parts when
doing tutorial 4 and assignment 1.
Running the PL0 compiler under IntelliJ
Importing the Project
Download the .zip file containing the compiler from the course web page
Unzip the assignment .zip file to create a directory containing the compiler as a IntelliJ project
Start IntelliJ Idea -- version 2019 (or later) is required to use the supplied run configurations
File > Open
Navigate to the unzipped directory containing the compiler and select the directory
Open
If there is a bar at the top of the code stating "Project SDJ is not defined" then select "Setup
SDK" (on the right of the bar). That will display your available SDKs. Select one that is at least 19
(and Project language level 19) and select OK.
Run Configurations Provided
The compiler IntelliJ project comes with two run configurations.
"PL0_RD" ("PL0_LALR") runs the compiler on whatever file is currently displayed in IntelliJ. It is
recommended that this be a PL0 file -- if it is a Java file the PL0 compiler will still attempt to
parse it but many error messages will ensue as its not valid PL0. You may want to edit this
configuration to change the program parameters, e.g. to add "-s" to turn off static checking
(and everything beyond that) or add "-d" to turn on debugging output.
"Test_RD" ("Test_LALR") runs the PL0 compiler on every test case and compares the output with
that expected. Ticked test cases succeeded and crossed test cases failed.
Compiler options
If a compilation of a PL0 program is successful, the compiler normally runs the interpreter to execute
the generated code. However there are a number of compiler parameters that can change its
behaviour.
The -d option gives a blow-by-blow (very verbose) trace of the recursive descent parsing process (for
assignment 1 compiler) or the shift-reduce parsing process (for assignment 2 and 3 compilers). It also
gives extra debugging output during static checking and interpretation or code generation.
The -t option is useful for debugging problems with the code your compiler generates; it gives a very
verbose blow-by-blow trace of the execution of the code.
To debug the parsing, run the compiler with the "-s" option and perhaps "-d" to get the debugging
output to see what it is doing.
To debug the static checker, run with "-i" and possibly "-d" as well.
To debug the code generation, run with just "-v" to see generated code, and if things go wrong at run
time, try adding "-t" to get a very detailed trace of execution, instruction by instruction; this is where
smaller programs will be easier.