Docs.rs
  • timi-0.2.1
    • timi 0.2.1
    • Permalink
    • Docs.rs crate page
    • MIT
    • Links
    • Homepage
    • Documentation
    • Repository
    • crates.io
    • Source
    • Owners
    • bollu
    • Dependencies
      • ansi_term ^0.9 normal
      • prettytable-rs ^0.6 normal
      • rand ^0.3 normal
      • rustyline ^1.0.0 normal
    • Versions
    • 64.79% of the crate is documented
  • Platform
    • i686-pc-windows-msvc
    • i686-unknown-linux-gnu
    • x86_64-apple-darwin
    • x86_64-pc-windows-msvc
    • x86_64-unknown-linux-gnu
  • Feature flags
  • docs.rs
    • About docs.rs
    • Badges
    • Builds
    • Metadata
    • Shorthand URLs
    • Download
    • Rustdoc JSON
    • Build queue
    • Privacy policy
  • Rust
    • Rust website
    • The Book
    • Standard Library API Reference
    • Rust by Example
    • The Cargo Guide
    • Clippy Documentation

Crate timi

timi0.2.1

  • All Items

Sections

  • Example - Creating Machine instance from a string

Crate Items

  • Modules

Crates

  • timi

Crate timi

Source
Expand description

a Template Instantiation Machine (TIM) interpreter written in Rust.

TIM is a particular kind of machine used to implement a lazily evaluated functional programming language.

This implementation comes with a parser for the language called as Core, along with an interpreter for Core. This is based on Implementing Functional Languages, a tutorial

§Example - Creating Machine instance from a string

use timi::machine;
use timi::frontend;

let program_str = "main = 1 + 1";
let parsed_program = frontend::string_to_program(program_str).unwrap();

let mut m = machine::Machine::new_from_program(parsed_program).unwrap();

while !m.is_final_state().unwrap() {
  m.step();   
}

//check that the top node on the stack is 1 + 1 == 2
assert_eq!(machine::HeapNode::Num(2), m.heap.get(&m.stack.peek().unwrap()));

Modules§

frontend
Frontend of the interpreter. Tokenization & Parsing is handled here.
ir
Internal Representation (IR) of the machine. Contains the data representation used by the machine.
machine
The machine state is formed out of 4 components: (Stack, Heap, Dump, Globals)
pretty_print
Pretty printing mainly focuses on generating clean and readable output for errors, machine state, etc.

Results

Settings
Help

Query parser error: "Unexpected - (did you mean ->?)".