Skip to content

Commit b269682

Browse files
committed
Add readme, metadata and license
1 parent 738bb53 commit b269682

File tree

4 files changed

+206
-5
lines changed

4 files changed

+206
-5
lines changed

Cargo.toml

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
[package]
22
name = "pancakestack"
33
version = "0.1.0"
4+
description = "Rust implementation of the Pancake Stack esoteric programming language."
5+
readme = "README.md"
6+
repository = "https://github.com/OpenByteDev/pancakestack"
7+
license = "MIT"
48
authors = ["OpenByte <[email protected]>"]
59
edition = "2018"
10+
keywords = ["pancake", "stack", "esoteric", "parser", "interpreter"]
611

712
[dependencies]
8-
"regex" = "*"
9-
"lazy_static" = "*"
10-
"unicode-segmentation" = "*"
13+
"regex" = "1.3"
14+
"lazy_static" = "1.4"
15+
"unicode-segmentation" = "1.6"
1116

1217
[dev-dependencies]
1318
criterion = "0.3"

LICENSE

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MIT License
2+
3+
Copyright (c) OpenByte <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+189
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
# Pancake Stack
2+
3+
[![crates.io](https://img.shields.io/crates/v/pancakestack.svg)](https://crates.io/crates/pancakestack)
4+
[![Documentation](https://docs.rs/pancakestack/badge.svg)](https://docs.rs/pancakestack)
5+
[![MIT](https://img.shields.io/crates/l/pancakestack.svg)](./LICENSE)
6+
7+
This is a Rust implementation of the [Pancake Stack](https://esolangs.org/wiki/Pancake_Stack) esoteric programming language. This crate includes a parser and an interpreter.
8+
9+
> Pancake Stack is a stack-based esoteric programming language created by User [JWinslow23](https://esolangs.org/wiki/User:JWinslow23) in [2013](https://en.wikipedia.org/wiki/2013), in which programs require you to manipulate a stack of [pancakes](https://i.ytimg.com/vi/FLd00Bx4tOk/maxresdefault.jpg).
10+
11+
## Usage
12+
13+
To use pancakestack, first add this to your Cargo.toml:
14+
```toml
15+
[dependencies]
16+
"pancakestack" = "0.1.0"
17+
```
18+
19+
## Crate Examples
20+
21+
This examples shows how to run a `.pancake` file using `stdin()` as input and `stdout()` as output.
22+
```rust
23+
let file = File::open("example.pancake").unwrap();
24+
pancakestack::run_program_from_read(file, std::io:stdin(), std::io:stdout()).unwrap();
25+
```
26+
27+
This examples shows how to run a `.pancake` file with strings as input and output.
28+
```rust
29+
let file = File::open("example.pancake").unwrap();
30+
let input = b"some input";
31+
let mut output_buf = Vec::new();
32+
pancakestack::run_program_from_read(file, &input[..], &mut output_buf).unwrap();
33+
let output = str::from_utf8(&output_buf).unwrap();
34+
```
35+
36+
This examples shows how to parse and run a `.pancake` script using `stdin()` as input and `stdout()` as output.
37+
```rust
38+
let file = File::open("example.pancake")?;
39+
let input = b"some input";
40+
let mut output_buf = Vec::new();
41+
pancakestack::run_program_from_read(file, &input[..], &mut output_buf).unwrap();
42+
let output = str::from_utf8(&output_buf).unwrap();
43+
44+
let mut file = File::open("example.pancake").unwrap();
45+
let mut program_str = String::new();
46+
file.read_to_string(&mut program_str).unwrap();
47+
48+
let program = pancakestack::parse_program_str(&program_str);
49+
pancakestack::run_program(&program, std::io:stdin(), std::io:stdout()).unwrap();
50+
51+
```
52+
53+
This examples shows how to construct a script from commands and running it.
54+
```rust
55+
use pancakestack::command::*;
56+
57+
let program = vec![
58+
BorrowedCommand::PutThisPancakeOnTop("test"),
59+
BorrowedCommand::ShowMeAPancake,
60+
BorrowedCommand::EatAllOfThePancakes
61+
];
62+
pancakestack::run_program(&program, std::io:stdin(), std::io:stdout()).unwrap();
63+
```
64+
65+
## Language Syntax
66+
67+
The pancake stack starts out as empty.
68+
| Code | Meaning |
69+
| ---- | ------- |
70+
| Put this X pancake on top! | Push the word length of X on top of the stack, i.e. "wonderful" would push 9. |
71+
| Eat the pancake on top! | Pop the top value off of the stack, and discard it. |
72+
| Put the top pancakes together! | Pop off the top two values, add them, and push the result. |
73+
| Give me a pancake! | Input a number value and push it on the stack. |
74+
| How about a hotcake? | Input an ASCII value and push it on the stack. |
75+
| Show me a pancake! | Output the top value on the stack as an ASCII character, but don't pop it. |
76+
| Take from the top pancakes! | Pop off the top two values, subtract the second one from the first one, and push the result. |
77+
| Flip the pancakes on top! | Pop off the top two values, swap them, and push them back. |
78+
| Put another pancake on top! | Pop off the top value and push it twice. |
79+
| [label] | Defines a label to go back to (Can also define a comment, if needed). When you go back to the label, it goes to the line number (1 indexed) of the top value of the stack when the label was defined. |
80+
| If the pancake isn't tasty, go over to "label". | Go to label [label] if the top value is 0. |
81+
| If the pancake is tasty, go over to "label". | Same as above, except go if the top value is not 0. |
82+
| Put syrup on the pancakes! | Increment all stack values. |
83+
| Put butter on the pancakes! | Increment only the top stack value. |
84+
| Take off the syrup! | Decrement all stack values. |
85+
| Take off the butter! | Decrement only the top stack value. |
86+
| Eat all of the pancakes! | Terminate the program. |
87+
88+
## Language Examples
89+
90+
### Hello World!
91+
```pancake
92+
Put this heavenly pancake on top!
93+
Put another pancake on top!
94+
Put another pancake on top!
95+
Put another pancake on top!
96+
Put another pancake on top!
97+
Put another pancake on top!
98+
Put another pancake on top!
99+
Put another pancake on top!
100+
Put syrup on the pancakes!
101+
Put the top pancakes together!
102+
Put the top pancakes together!
103+
Put the top pancakes together!
104+
Put the top pancakes together!
105+
Put the top pancakes together!
106+
Put the top pancakes together!
107+
Put the top pancakes together!
108+
Show me a pancake!
109+
Put this appetizing pancake on top!
110+
Put this delectable pancake on top!
111+
Put this delicious pancake on top!
112+
Put the top pancakes together!
113+
Put the top pancakes together!
114+
Put the top pancakes together!
115+
Show me a pancake!
116+
Put this wonderful pancake on top!
117+
Take off the syrup!
118+
Put the top pancakes together!
119+
Show me a pancake!
120+
Show me a pancake!
121+
Put this rich pancake on top!
122+
Take off the butter!
123+
Put the top pancakes together!
124+
Show me a pancake!
125+
Put this delightful pancake on top!
126+
Put this dainty pancake on top!
127+
Put the top pancakes together!
128+
Put another pancake on top!
129+
Put the top pancakes together!
130+
Show me a pancake!
131+
Put this tasty pancake on top!
132+
Put another pancake on top!
133+
Put another pancake on top!
134+
Put another pancake on top!
135+
Put another pancake on top!
136+
Put another pancake on top!
137+
Put another pancake on top!
138+
Put another pancake on top!
139+
Put another pancake on top!
140+
Put another pancake on top!
141+
Put another pancake on top!
142+
Put the top pancakes together!
143+
Put the top pancakes together!
144+
Put the top pancakes together!
145+
Put the top pancakes together!
146+
Put the top pancakes together!
147+
Put the top pancakes together!
148+
Put the top pancakes together!
149+
Put the top pancakes together!
150+
Put the top pancakes together!
151+
Put the top pancakes together!
152+
Put the top pancakes together!
153+
Show me a pancake!
154+
Eat the pancake on top!
155+
Show me a pancake!
156+
Put this good pancake on top!
157+
Take off the butter!
158+
Put the top pancakes together!
159+
Show me a pancake!
160+
Put this divine pancake on top!
161+
Flip the pancakes on top!
162+
Take from the top pancakes!
163+
Show me a pancake!
164+
Put this pleasant pancake on top!
165+
Flip the pancakes on top!
166+
Take from the top pancakes!
167+
Show me a pancake!
168+
Put this mouthwatering pancake on top!
169+
Put this scrumptious pancake on top!
170+
Put this enjoyable pancake on top!
171+
Put the top pancakes together!
172+
Put the top pancakes together!
173+
Show me a pancake!
174+
Eat all of the pancakes!
175+
```
176+
177+
### Cat
178+
```pancake
179+
Put this old pancake on top!
180+
[CAT]
181+
Eat the pancake on top!
182+
How about a hotcake?
183+
Show me a pancake!
184+
If the pancake is tasty, go over to "CAT".
185+
Eat all of the pancakes!
186+
```
187+
188+
## License
189+
Licensed under MIT license ([LICENSE](./LICENSE) or http://opensource.org/licenses/MIT)

src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#[macro_use]
22
extern crate lazy_static;
33

4-
// https://esolangs.org/wiki/Pancake_Stack
5-
64
mod command;
75
mod interpreter;
86

0 commit comments

Comments
 (0)