Group Members:
- Mannage K.M.K.K (220384B)
- Jayakody J.A.U.C (220248M)
This project implements a complete interpreter for the RPAL (Right-reference Pascal) programming language as part of the CS 3513 Programming Language course. The interpreter comprises four key components:
- Lexical Analyzer: Tokenizes the input source code based on the lexical rules defined in RPAL_Lex.pdf.
- Parser: Constructs an Abstract Syntax Tree (AST) from the token stream using the grammar rules provided in RPAL_Grammar.pdf.
- AST Standardizer: Transforms the AST into a Standardized Tree (ST) by eliminating syntactic sugar and normalizing expressions for evaluation.
- CSE Machine (Control Stack Environment Machine): Evaluates the ST using functional evaluation semantics to produce the final program output.
- Java Development Kit (JDK): Ensure Java is installed (version compatible with the project, e.g., JDK 8 or higher).
- Make (GnuWin)
-
- Download the GnuWin Make setup and install it.
- Add Make to your system PATH environment variable:
- Open the Start Menu and search for "Environment Variables".
- Click "Edit the system environment variables".
- In the System Properties window, click "Environment Variables".
- Under "System variables", find and select the
Pathvariable, then click "Edit". - Click "New" and add the path to the GnuWin32
bindirectory (e.g.,C:\Program Files (x86)\GnuWin32\bin). - Click OK to close all dialogs.
- Open a new terminal and run:
to verify that
make --version
makeis installed.
-
git clone https://github.com/KevithMannage/programming_language.git
cd programming_languageopen in vscode using code .
Run the RPAL interpreter using the following commands. Replace ./path/to/file/ with the path to your RPAL source file (e.g., program.rpal).
- Evaluate Code and Print Result
java rpal input.txt- Print the Abstract Syntax Tree (AST)
java rpal -ast input.txt- Print the Standardized Tree (ST)
java rpal -st input.txt- Print AST, ST, and Evaluation Result
java rpal -ast -st input.txt- Compile Modified Code Recompile any changed Java files before re-running:
javac ./src/*.java- Running the Program with Input Files in a Different Directory
If the input file is located in a directory other than the root directory, replace input.txt with the relative path to the file, prefixed with ./.
Example:
java rpal ./Test/test_1.txtThe provided makefile allows you to easily compile, run, clean, and test the project.
make allmake runmake cleanEach test target runs the interpreter with a specific test file in the Test directory. For example:
make test1 # Runs java myrpal ./Test/test_1
make test2 # Runs java myrpal ./Test/test_2
...
make test13 # Runs java myrpal ./Test/test_13- Ensure all file paths are correct and point to valid RPAL source files or Java source files.
- The commands assume the Java classpath includes the compiled RPAL interpreter classes.
- If errors occur (e.g., file not found, classpath issues), verify the file paths and Java environment setup.