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
/// # 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 n 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 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
/// extern crate ashpaper;
///
/// use std::fs;
///
/// 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?
///                    ";
///    match ashpaper::program::execute(&contents) {
///        Ok(res) => print!("{}", res),
///        Err(e) => eprintln!("{}", e),
///    }
/// }
/// ```
///
/// And it will produce the output:
/// ```txt
/// 24
/// ```
///
/// ## Some caveats about compliance with the informal spec
/// - It's entirely possible at this point that some of my implementation deviates from the spec in unintended ways. If you spot anything like that, please raise an issue :heart: :heart:
/// - The alliteration and rhyming rules are still unimplemented.
extern crate pest;
#[macro_use]
extern crate pest_derive;
extern crate wordsworth;
mod error;
pub mod program;
pub use error::Error;