This is an interpreter for the RPAL programming language, implemented in C++ as part of the CS 3513 - Programming Languages course. It includes a scanner, parser, AST printer, AST standardizer, and evaluator.
- Janidu Pabasara
- Thevindu Fernando
- Scanner using the RPAL lexicon: identifiers, integers, strings, operators, punctuation, comments.
- Parser for RPAL grammar that builds an AST.
- AST preorder dot-indented printer.
- Standardizer that converts AST to ST using RPAL rules:
let,where,within,and,rec,fcn_form, and@. - Evaluator with environments, closures, tuples, recursion, arithmetic, comparisons, boolean operators, and core builtins:
PrintOrderConcStemSternItoSIsinteger,Istruthvalue,Isstring,Istuple,Isfunction,IsdummyNull
Lab/submission build:
makeCMake build, useful for local development:
mkdir build
cd build
cmake ..
cmake --build .Executables:
./rpal20aftermakebuild/rpal20after CMake on Linux/macOSbuild/Release/rpal20.exeafter CMake with Visual Studio on Windows
Default behavior is evaluation:
./rpal20 <file>Other modes:
./rpal20 --scan <file> # token stream
./rpal20 --parse <file> # parse-only validation
./rpal20 --ast <file> # AST in preorder dot-indented format
./rpal20 --st <file> # standardized tree in preorder format
./rpal20 --eval <file> # explicit eval mode./rpal20 ./rpal_test_programs/rpal_01Test inputs and expected outputs follow the lab naming style:
rpal_test_programs/rpal_01
rpal_test_programs/output01.test
Run all tests with:
python3 scripts/run_tests.py- Test programs:
rpal_test_programs/rpal_01throughrpal_97 - Expected outputs:
rpal_test_programs/output01.testthroughoutput97.test
The numbering follows the lab command style, so rpal_14 is checked against output14.test, and so on.
Detailed implementation and change log is in CHANGES_AND_BUILD.md.
