#interpreter #graph #semantic #swamp #abstract #debugging #expression #node #tree-walking #asg

swamp-eval

Simple tree-walking interpreter for executing the Swamp Abstract Semantic Graph (ASG) from swamp-semantic. Primarily for debugging/testing, not performance.

8 releases

Uses new Rust 2024

0.1.16 Apr 7, 2025
0.1.15 Apr 1, 2025
0.1.13 Mar 30, 2025
0.0.14 Apr 1, 2025

#387 in Science


Used in 5 crates (2 directly)

MIT license

295KB
6.5K SLoC

Swamp Evaluator (Interpreter)

A simple tree-walking interpreter for the Swamp programming language, designed to execute the Abstract Semantic Graph (ASG) produced by swamp-semantic.

Overview

This crate provides a straightforward way to run Swamp code by directly interpreting its semantic representation after parsing and semantic analysis have been completed. It walks the swamp_semantic::Expression tree and evaluates each node according to Swamp's operational semantics.

Note: This is a basic interpreter intended primarily for debugging. It is not optimized for performance. The long-term plan is for execution to be handled by a more performant bytecode Virtual Machine (VM), at which point this interpreter may be deprecated or removed.

Key Features

  • Executes ASG: Directly interprets the output of swamp-analyzer.
  • Tree-Walking: Evaluates expressions recursively by traversing the semantic tree.
  • Debugging/Testing: Useful for verifying the correctness of the semantic analysis phase and understanding execution flow without needing the full VM.
  • Simplicity: Aims for correctness over speed.

Installation

[dependencies]
swamp-eval = "0.1.16"

License

This project is licensed under the MIT License - see the LICENSE file for details.

Copyright (c) Peter Bjorklund. All rights reserved. https://github.com/swamp/swamp

Dependencies

~515KB