Skip to content

Commit f224504

Browse files
committed
add: README
1 parent 50de3f2 commit f224504

File tree

4 files changed

+259
-6
lines changed

4 files changed

+259
-6
lines changed

README.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<p align="center">
2+
<img width="180" src="https://github.com/stacky-language/stacky/docs/images/stacky.svg" alt="Stacky logo">
3+
</p>
4+
5+
# Stacky
6+
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).

README_JA.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<p align="center">
2+
<img width="180" src="https://github.com/stacky-language/stacky/docs/images/stacky.svg" alt="Stacky logo">
3+
</p>
4+
5+
# Stacky
6+
Stacky is a simple stack-oriented programming language
7+
8+
## 概要
9+
10+
Stackyはスタックマシンの学習目的で設計された、スタック指向のシンプルなプログラミング言語です。一般的なスタックマシンに基づく明快な構文を備え、実際にコードを書きながらその動作原理を学ぶことができるようになっています。
11+
12+
## Getting Started
13+
14+
### インストール
15+
16+
Web上で動作する[Stacky Playground](https://stacky-language.github.io/playground)から簡単に試すことができます。
17+
18+
また、REPLや`.stacky`ファイルを実行するためのCLIツールをcargoからインストールできます。
19+
20+
```bash
21+
$ cargo install stacky-cli
22+
```
23+
24+
### Hello, World
25+
26+
まずは以下のコードを実行してみましょう。
27+
28+
```stacky
29+
; hello.stacky
30+
push "hello, world!"
31+
print
32+
```
33+
34+
Stacky Playgroundの場合はRunボタンを押してコードを実行します。CLIの場合は以下のコマンドを実行します。
35+
36+
```stacky
37+
stacky hello.stacky
38+
```
39+
40+
コードを実行すると`hello, world!`という文字列が出力されるはずです。
41+
42+
### FizzBuzz
43+
44+
Stacky言語はさまざまな命令をサポートしています。もう少し複雑な例を見てみましょう。
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+
### ドキュメント
112+
113+
より詳細なドキュメントは[こちら](https://stacky-language.github.io/)で確認できます。
114+
115+
## ライセンス
116+
117+
このリポジトリは[MIT License](./LICENSE)の下で公開されています。

docs/images/stacky.svg

Lines changed: 6 additions & 0 deletions
Loading

fizzbuzz.stacky

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,38 @@
1+
; let i = 0
2+
push 0
3+
store i
4+
15
start:
26

3-
; input
4-
read
5-
convert int
7+
; i++
8+
load i
9+
push 1
10+
add
611
store i
712

8-
; i % 15 == 0
13+
; if i == 100 return
14+
load i
15+
push 100
16+
eq
17+
br end
18+
19+
; if i % 15 == 0
920
load i
1021
push 15
1122
mod
1223
push 0
1324
eq
1425
br fizz_buzz
1526

16-
; i % 3 == 0
27+
; if i % 3 == 0
1728
load i
1829
push 3
1930
mod
2031
push 0
2132
eq
2233
br fizz
2334

24-
; i % 5 == 0
35+
; if i % 5 == 0
2536
load i
2637
push 5
2738
mod
@@ -47,3 +58,5 @@ other:
4758
load i
4859
print
4960
goto start
61+
62+
end:

0 commit comments

Comments
 (0)