Skip to content

Prancer - TypeScript tree-walking interpreter for santa-lang with CLI, Web, and Lambda runtimes

License

Notifications You must be signed in to change notification settings

eddmann/santa-lang-prancer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

santa-lang

santa-lang Prancer

Tree-walking interpreter implementation of santa-lang, written in TypeScript.

Overview

santa-lang is a functional, expression-oriented programming language designed for solving Advent of Code puzzles. This TypeScript implementation provides a tree-walking interpreter.

Key language features:

  • First-class functions and closures with tail-call optimization
  • Pipeline and composition operators for expressive data flow
  • Persistent immutable data structures
  • Lazy sequences and infinite ranges
  • Pattern matching with guards
  • Rich built-in function library
  • AoC runner with automatic input fetching

Multiple runtime targets are available: CLI and AWS Lambda.

Architecture

Source Code → Lexer → Parser → Evaluator → Result
                                   ↓
                           Environment (Scopes)
Component Description
Lexer Tokenizes source into keywords, operators, literals
Parser Builds an Abstract Syntax Tree (AST)
Evaluator Tree-walking interpreter that executes the AST
Environment Manages variable bindings and closures across scopes

For detailed implementation internals, see ARCHITECTURE.md.

Installation

Docker

docker pull ghcr.io/eddmann/santa-lang-prancer:cli-latest
docker run --rm ghcr.io/eddmann/santa-lang-prancer:cli-latest --help

Release Binaries

Download pre-built binaries from GitHub Releases:

Platform Artifact
Linux (x86_64) santa-lang-prancer-cli-{version}-linux-amd64
Linux (ARM64) santa-lang-prancer-cli-{version}-linux-arm64
macOS (Intel) santa-lang-prancer-cli-{version}-macos-amd64
macOS (Apple Silicon) santa-lang-prancer-cli-{version}-macos-arm64

AWS Lambda

Lambda layer available: santa-lang-prancer-lambda-{version}.zip

Usage

# Run a solution
santa-cli solution.santa

# Run tests defined in a solution
santa-cli -t solution.santa

# Evaluate inline code
santa-cli -e '1 + 2'

# Interactive REPL
santa-cli -r

Example

Here's a complete Advent of Code solution (2015 Day 1):

input: read("aoc://2015/1")

part_one: {
  input |> fold(0) |floor, direction| {
    if direction == "(" { floor + 1 } else { floor - 1 };
  }
}

part_two: {
  zip(1.., input) |> fold(0) |floor, [index, direction]| {
    let next_floor = if direction == "(" { floor + 1 } else { floor - 1 };
    if next_floor < 0 { break index } else { next_floor };
  }
}

test: {
  input: "()())"
  part_one: -1
  part_two: 5
}

Key language features shown:

  • input: / part_one: / part_two: - AoC runner sections
  • |> - Pipeline operator (thread value through functions)
  • fold - Reduce with early exit support via break
  • test: - Inline test cases with expected values

Building

Requires Bun or use Docker:

# Install dependencies
make lang/install
make cli/install

# Run tests
make lang/test
make cli/test

# Build CLI binaries
make cli/build

# Build web application
make web/build

# Build Lambda layer
make lambda/build

Development

Run make help to see all available targets:

make help          # Show all targets
make shell         # Interactive shell in Docker build environment
make lang/test     # Run language tests
make cli/test      # Run CLI tests
make cli/build     # Build CLI binaries
make web/build     # Build web application
make lambda/build  # Build Lambda layer

Project Structure

├── src/
│   ├── lang/              # Core language library
│   │   ├── lexer/         # Tokenization
│   │   ├── parser/        # AST construction
│   │   ├── evaluator/     # Tree-walking interpreter
│   │   └── runner/        # AoC runner support
│   ├── cli/               # Command-line interface
│   ├── web/               # Web application (Next.js)
│   └── lambda/            # AWS Lambda runtime
└── examples/              # Example AoC solutions

Other Reindeer

The language has been implemented multiple times to explore different execution models and technologies.

Codename Type Language
Comet Tree-walking interpreter Rust
Blitzen Bytecode VM Rust
Dasher LLVM native compiler Rust
Donner JVM bytecode compiler Kotlin
Vixen Embedded bytecode VM C
Prancer Tree-walking interpreter TypeScript

Tooling

Name Description Language
Workbench Desktop IDE Tauri/React
Tinsel Code formatter Zig

License

MIT License - see LICENSE for details.

About

Prancer - TypeScript tree-walking interpreter for santa-lang with CLI, Web, and Lambda runtimes

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages