You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Stacky is a simple stack-oriented programming language.
7
+
8
+
## Overview
9
+
10
+
Stacky is a stack-oriented, minimal programming language designed for learning how stack machines work. It provides a clear syntax based on common stack machine concepts so you can learn the execution model by writing and running code.
11
+
12
+
## Getting Started
13
+
14
+
### Installation
15
+
16
+
You can try Stacky quickly using the web-based [Stacky Playground](https://stacky-language.github.io/playground):
17
+
18
+
You can also install a CLI tool to run a REPL or execute `.stacky` files via cargo:
19
+
20
+
```bash
21
+
$ cargo install stacky-cli
22
+
```
23
+
24
+
### Hello, World
25
+
26
+
Run the following example:
27
+
28
+
```stacky
29
+
; hello.stacky
30
+
push "hello, world!"
31
+
print
32
+
```
33
+
34
+
In the Stacky Playground, press the Run button to execute the code. From the CLI, run:
35
+
36
+
```bash
37
+
stacky hello.stacky
38
+
```
39
+
40
+
The program should print `hello, world!`.
41
+
42
+
### FizzBuzz
43
+
44
+
Stacky supports a variety of instructions. Here's a slightly more complex example:
45
+
46
+
```stacky
47
+
; let i = 0
48
+
push 0
49
+
store i
50
+
51
+
start:
52
+
53
+
; i++
54
+
load i
55
+
push 1
56
+
add
57
+
store i
58
+
59
+
; if i == 100 return
60
+
load i
61
+
push 100
62
+
eq
63
+
br end
64
+
65
+
; if i % 15 == 0
66
+
load i
67
+
push 15
68
+
mod
69
+
push 0
70
+
eq
71
+
br fizz_buzz
72
+
73
+
; if i % 3 == 0
74
+
load i
75
+
push 3
76
+
mod
77
+
push 0
78
+
eq
79
+
br fizz
80
+
81
+
; if i % 5 == 0
82
+
load i
83
+
push 5
84
+
mod
85
+
push 0
86
+
eq
87
+
br buzz
88
+
89
+
goto other
90
+
91
+
fizz_buzz:
92
+
print "fizz buzz"
93
+
goto start
94
+
95
+
fizz:
96
+
print "fizz"
97
+
goto start
98
+
99
+
buzz:
100
+
print "buzz"
101
+
goto start
102
+
103
+
other:
104
+
load i
105
+
print
106
+
goto start
107
+
108
+
end:
109
+
```
110
+
111
+
### Documentation
112
+
113
+
For more detailed documentation, see: https://stacky-language.github.io/
114
+
115
+
## License
116
+
117
+
This repository is under the [MIT License](./LICENSE).
0 commit comments