Skip to content

Repository files navigation

RPAL Interpreter

RPAL Interpreter Banner

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.

Collaborators

  • Janidu Pabasara
  • Thevindu Fernando

Features

  • 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:
    • Print
    • Order
    • Conc
    • Stem
    • Stern
    • ItoS
    • Isinteger, Istruthvalue, Isstring, Istuple, Isfunction, Isdummy
    • Null

Build

Lab/submission build:

make

CMake build, useful for local development:

mkdir build
cd build
cmake ..
cmake --build .

Executables:

  • ./rpal20 after make
  • build/rpal20 after CMake on Linux/macOS
  • build/Release/rpal20.exe after CMake with Visual Studio on Windows

CLI Modes

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

Example

./rpal20 ./rpal_test_programs/rpal_01

Test Runner

Test 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

Tests

  • Test programs: rpal_test_programs/rpal_01 through rpal_97
  • Expected outputs: rpal_test_programs/output01.test through output97.test

The numbering follows the lab command style, so rpal_14 is checked against output14.test, and so on.

Project Notes

Detailed implementation and change log is in CHANGES_AND_BUILD.md.

About

A high-performance RPAL interpreter designed for functional language analysis, implementing lexical scanning, Abstract Syntax Tree (AST) construction, standardization (ST), and CSE machine evaluation.

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages