{"id":28202048,"url":"https://github.com/m1llerf/racket-interpreter","last_synced_at":"2026-01-31T22:36:02.925Z","repository":{"id":267358534,"uuid":"877537167","full_name":"M1llerF/Racket-Interpreter","owner":"M1llerF","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-09T21:26:53.000Z","size":90,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-19T19:00:44.869Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Racket","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/M1llerF.png","metadata":{"files":{"readme":"docs/README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-23T20:25:27.000Z","updated_at":"2024-12-09T21:26:57.000Z","dependencies_parsed_at":"2024-12-09T22:29:07.981Z","dependency_job_id":"2e6cce7c-87ee-49de-b7dd-b03a68ce42cd","html_url":"https://github.com/M1llerF/Racket-Interpreter","commit_stats":null,"previous_names":["m1llerf/racket-interpreter"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/M1llerF/Racket-Interpreter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/M1llerF%2FRacket-Interpreter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/M1llerF%2FRacket-Interpreter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/M1llerF%2FRacket-Interpreter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/M1llerF%2FRacket-Interpreter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/M1llerF","download_url":"https://codeload.github.com/M1llerF/Racket-Interpreter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/M1llerF%2FRacket-Interpreter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28958345,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T22:20:19.638Z","status":"ssl_error","status_checked_at":"2026-01-31T22:18:07.061Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-16T23:13:56.370Z","updated_at":"2026-01-31T22:36:02.920Z","avatar_url":"https://github.com/M1llerF.png","language":"Racket","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Racket Interpreter for a Subset of Racket\n\n## Overview\nThis project implements an interpreter in Racket for a subset of the Racket language itself. The primary function, `startEval`, serves as the entry point for evaluating expressions. The interpreter handles various Racket constructs including arithmetic operations, conditionals, lambdas, and list operations.\n\n## Features\nThe interpreter supports the following constructs:\n- **Constants and Variables**: Evaluation of numbers, symbols, and quoted expressions.\n- **Arithmetic Operators**: `+`, `-`, `*`, `/` (binary operators only).\n- **Relational Operators**: `equal?`, `=`, `\u003c`, `\u003e`, `\u003c=`, `\u003e=`.\n- **List Operations**: `car`, `cdr`, `cons`, and `pair?`.\n- **Conditionals**: The `if` construct.\n- **Lambda Expressions**: Function definitions and closures.\n- **Function Applications**: Invoking functions with arguments.\n- **Local Bindings**: `let` and `letrec` constructs for variable scoping.\n\n## Code Organization\nThe project consists of:\n1. **Core Interpreter (`interpreter.rkt`)**: Implements the `startEval` function with evaluation rules for various constructs.\n2. **Test Suites**:\n   - `arithmetic-tests.rkt`: Tests for arithmetic operations.\n   - `relational-tests.rkt`: Tests for relational operators.\n   - `list-operations-tests.rkt`: Tests for list operations.\n   - `if-statement-tests.rkt`: Tests for conditionals.\n   - `lambda-tests.rkt`: Tests for lambda expressions and applications.\n   - `local-binding-tests.rkt`: Tests for `let` and `letrec` bindings.\n   - `interpreter-tests.rkt`: General tests covering constants, quoting, and recursive constructs.\n\n## Key Data Structures\n- **Environment**: The interpreter uses an environment represented as an association list (`alist`) to map symbols to their values.\n- **Closures**: Lambda expressions are evaluated into closures, which encapsulate parameters, body, and the environment in which they were defined.\n- **Promises**: Used to support `letrec` with delayed evaluation.\n\n## Limitations\n1. **No Optional or Keyword Arguments**: Lambda expressions only support positional arguments.\n2. **Single Expression Bodies**: Constructs like `let` and `lambda` allow only one expression in their body.\n3. **No Side Effects**: The interpreter does not support operations with side effects, adhering to functional programming paradigms.\n4. **Division by Zero**: Explicitly handled with errors but without sophisticated error recovery.\n\n## Testing\nComprehensive tests are provided for each construct. Key highlights:\n- **Arithmetic**: Verifies support for BEDMAS and edge cases like division by zero.\n- **Lambdas**: Tests include nested and higher-order functions.\n- **Local Bindings**: Covers shadowing, recursive definitions, and interdependent bindings.\n- **Conditionals**: Includes simple and nested `if` statements.\n- **List Operations**: Tests `car`, `cdr`, `cons`, and pair predicates.\n\nSample outputs for recursive constructs:\n- **Factorial (using `letrec`)**:\n  ```racket\n  (startEval '(letrec ((fact (lambda (x) (if (= x 0) 1 (* x (fact (- x 1))))))) (fact 10)) '())\n  ```\n  Expected result: `3628800`.\n\n## How to Run\n1. Install Racket (version X or higher) and ensure the `rackunit` library is available.\n2. Load the `interpreter.rkt` file into Racket to evaluate expressions:\n   ```racket\n   (require \"interpreter.rkt\")\n   (startEval '(\u003cexpression\u003e) \u003cenvironment\u003e)\n   ```\n3. To run all tests:\n   ```sh\n   racket all-tests.rkt\n   ```\n   This executes a unified test suite combining all individual tests.\n4. To test specific features, run individual test files:\n   ```sh\n   racket arithmetic-tests.rkt\n   racket list-operations-tests.rkt\n   ```\n\n## Dependencies\n- **Racket**: Version X or higher.\n- **rackunit**: For running test suites.\n\n## Acknowledgments\nThis project was implemented as part of an academic course to explore interpreter design and functional programming principles. Special thanks to the instructor for the structured guidelines.\n\n## License\nAll Rights Reserved\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm1llerf%2Fracket-interpreter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fm1llerf%2Fracket-interpreter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm1llerf%2Fracket-interpreter/lists"}