Skip to content

Independent scheme #165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

Independent scheme #165

wants to merge 16 commits into from

Conversation

TRK95
Copy link
Contributor

@TRK95 TRK95 commented Aug 10, 2025

This PR adds comprehensive Scheme language support to Source Academy, implementing a complete Scheme Chapter 1 interpreter with direct SCM AST parsing (bypassing JavaScript's ES AST) and full integration with the Source Academy conductor system.

Integration Details:

Feature Flag Configuration:
The Scheme language module is available at:

https://trk95.github.io/scm-slang-pages/dist/index.js
This URL can be used in Source Academy's feature flag system to enable/disable Scheme language support.

Key Features Implemented:

Core Language Features (Scheme Chapter 1):
Variable Definitions: (define x 10) and x → 10
Function Definitions: (define (add x y) (+ x y)) and (add 3 4) → 7
Lambda Expressions: (lambda (x y) (+ x y))
Conditional Statements: (if (> 5 3) "yes" "no") → "yes"
Basic Arithmetic: (+ 3 5), (- 10 3), (* 4 2), (/ 8 2)
Comparisons: (> 5 3), (< 3 5), (= 5 5), (>= 5 5), (<= 3 5)
Boolean Operations: (and #t #f), (or #t #f), (not #f)

Technical Implementation:

  • Direct SCM AST Parsing: Parses Scheme code directly into Scheme-specific AST, avoiding JavaScript ES AST conversion
  • CSE Machine: Complete Control-Stash-Environment machine implementation
  • UMD Module Format: Compatible with browser and Node.js environments
  • Conductor Integration: Full integration with Source Academy's conductor system
  • Environment Persistence: Variables and functions persist across evaluations
  • Error Handling: Comprehensive error reporting with line/column information

Architecture:

Independent Module: Self-contained implementation that can be loaded independently
Feature Flag Ready: Can be enabled/disabled via Source Academy's feature flag system
Extensible Design: Easy to add new Scheme features and chapters

@coveralls
Copy link

coveralls commented Aug 10, 2025

Pull Request Test Coverage Report for Build 16865846198

Details

  • 1 of 7 (14.29%) changed or added relevant lines in 1 file are covered.
  • 13 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+2.0%) to 52.865%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/transpiler/types/nodes/scheme-node-types.ts 1 7 14.29%
Files with Coverage Reduction New Missed Lines %
src/transpiler/types/nodes/scheme-node-types.ts 13 57.21%
Totals Coverage Status
Change from base Build 16762143650: 2.0%
Covered Lines: 1380
Relevant Lines: 2395

💛 - Coveralls

TRK95 added 4 commits August 11, 2025 03:56
…STORE_ENV instruction to properly restore environment after function calls - Fix function parameter binding in CSE machine - Compound functions now work correctly (functions using other functions) - Linear recursion and iteration working properly
…o handle (list) as function call instead of list literal - Fix car/cdr to work with both lists and pairs - Fix pair? to recognize lists as pairs - Fix list? to recognize empty list () as list - Add length function for lists and pairs - Fix quote syntax to parse 'a 'b 'c as symbols
…ct formatting standards - Fix CI pipeline formatting check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants