1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//! # AshPaper
//! An inpterpreter for the Esopo language AshPaper conceived by [William Hicks](https://github.com/wphicks).
//! You can read about it and the Esopo project in Willian Hick's own words [here](https://wphicks.github.io/esopo/).
//! Daniel Temkin also wrote about it on esoteric.codes, you can read that [here](https://esoteric.codes/blog/esopo-turing-complete-poetry).
//! And of course the spec! Checkout that out [here](https://github.com/wphicks/Esopo/blob/master/AshPaper/informal_specs.txt).
//!
//! ## How it works
//!
//! You can execute poetry!
//!
//! Let's take this poem that calculates factorials and input in the number of syllables in the title.
//! (I (Shea Newton) learned a lot from reading the poem "other woodwork" by William Hicks)
//! ```txt
//! lovely poem
//!
//!   it is a calculator, like a
//!       poem, is a poem, and finds
//!         factori-
//!           als
//!   The input is the syllAbles
//! in the title, count them, as one counts
//!   (q) what other poem, programs can be writ
//!   (a) anything a Turing
//!     machine-machine-machine
//!     would do
//! re/cur
//!     sion works too, in poems, programs, and this
//!        a lovely.
//! poem or a calculator or nothing
//! how lovely can it be?
//! ```
//! Using this library, you can run it with a program that looked like this:
//! ```rust
//! use std::fs;
//!
//! use ashpaper_plus::Program;
//!
//! pub fn main() {
//!    let contents = "
//!lovely poem
//!
//!  it is a calculator, like a
//!      poem, is a poem, and finds
//!        factori-
//!          als
//!  The input is the syllAbles
//!in the title, count them, as one counts
//!  (q) what other poem, programs can be writ
//!  (a) anything a Turing
//!    machine-machine-machine
//!    would do
//!re/cur
//!    sion works too, in poems, programs, and this
//!       a lovely.
//!poem or a calculator or nothing
//!how lovely can it be?
//!                    ";
//!
//!     let program = Program::create(&contents);
//!     print!("{}", program.execute())
//! }
//! ```
//!
//! And it will produce the output:
//! ```txt
//! 24
//!
//! ```
//!
//! unlike the original, you can also install the binary from this crate
//! (you need to enable the cli feature so the executable is built)
//! ```bash
//! cargo install --features cli ashpaper-plus
//! ```
//!
//! ## Some caveats about compliance with the informal spec
//! - It's entirely possible at this point that some of the implementation deviates from the spec in unintended ways. If you spot anything like that, please raise an issue
mod errors;
#[cfg(feature = "jit")]
mod jit;
mod parser;
mod program;
mod rt;
pub use parser::count_syllables;
pub use program::Program;