Skip to content

Latest commit

 

History

History
190 lines (142 loc) · 4.09 KB

File metadata and controls

190 lines (142 loc) · 4.09 KB

CHANGES_AND_BUILD

This document captures the implemented work for the RPAL interpreter, plus build, run, and test instructions.

0) Step-by-Step Implementation Plan

  1. Confirm current scanner/parser/AST baseline from existing code and docs.
  2. Implement AST standardization rules and expose a reusable standardizer API.
  3. Implement evaluator runtime: environments, closures, application, tuples, operators, and builtins.
  4. Add a unified CLI entrypoint supporting scanner/parser/ast/st/eval modes.
  5. Wire build system to compile all modules.
  6. Update README and capture complete change/build/run notes in this file.
  7. Build and run provided RPAL test programs; fix gaps found.

Status:

  • Steps 1-7: Completed.

1) Components

Standardizer

Files:

  • src/standardizer.h
  • src/standardizer.cpp

Implements AST to ST conversion rules:

  • let
  • where
  • within
  • and
  • rec
  • fcn_form
  • @
  • tuple-form lambda parameters are preserved for tuple pattern binding

Evaluator

Files:

  • src/evaluator.h
  • src/evaluator.cpp

Implements:

  • Environment chain
  • Closures (lambda)
  • Function application (gamma)
  • Tuple values and tuple indexing by application
  • Tuple construction (tau) and aug
  • Arithmetic (+, -, *, /, **, neg)
  • Comparisons (gr, ge, ls, le, eq, ne)
  • Boolean ops (or, &, not, conditional ->)
  • Builtins:
    • Print
    • Order
    • Conc
    • Stem
    • Stern
    • ItoS
    • Isinteger
    • Istruthvalue
    • Isstring
    • Istuple
    • Isfunction
    • Isdummy
    • Null
  • Recursive definitions through standardized Y*

Unified CLI

File:

  • src/main.cpp

Modes:

  • --scan
  • --parse
  • --ast
  • --st
  • --eval
  • default mode: evaluate

2) Build System

Root Makefile is provided for the lab-required flow:

make
./rpal20 file_name

CMakeLists.txt is also available for local development.

3) Build Instructions

From repository root:

make

This produces:

./rpal20

Alternative CMake build:

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

Output executable:

  • Makefile: ./rpal20
  • Linux/macOS CMake: build/rpal20
  • Windows Visual Studio CMake: build/Release/rpal20.exe

4) Run Instructions

From repository root:

./rpal20 rpal_test_programs/rpal_01

Mode-specific examples:

./rpal20 --scan rpal_test_programs/rpal_01
./rpal20 --ast rpal_test_programs/rpal_01
./rpal20 --st rpal_test_programs/rpal_01
./rpal20 --eval rpal_test_programs/rpal_01

On Windows CMD/PowerShell with the CMake build:

.\build\Release\rpal20.exe rpal_test_programs\rpal_01

5) Tests

Core tests follow the lab naming style:

rpal_test_programs/rpal_01
rpal_test_programs/output01.test

Manual lab-style run:

./rpal20 rpal_test_programs/rpal_01 > output.01
diff output.01 rpal_test_programs/output01.test

Run all tests:

python3 scripts/run_tests.py

All tests now use the same lab-style layout:

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

If output mismatches expected RPAL behavior, inspect AST and ST:

./rpal20 --ast rpal_test_programs/rpal_01
./rpal20 --st rpal_test_programs/rpal_01

6) Notes for Commit

The implementation is structured so commits can be grouped by:

  1. Runtime pipeline (standardizer, evaluator, main)
  2. Build integration (Makefile, CMakeLists.txt)
  3. Tests and docs (rpal_test_programs, scripts, README.md, CHANGES_AND_BUILD.md)

7) Verification

Verified in this branch:

  • CMake/Visual Studio build completes and produces build/Release/rpal20.exe.
  • GCC C++11 compile with -Wall -Wextra -pedantic completes.
  • Tests rpal_01 through rpal_97 pass against output01.test through output97.test.
  • Additional checks cover recursion, tuple-parameter functions, curried functions, string/type builtins, comments, and tuple equality.

The local Windows shell does not have GNU make installed, so the Makefile was syntax-reviewed and its exact GCC compile command was verified manually.