Skip to content

Commit cd5b9de

Browse files
committed
zz
1 parent a272576 commit cd5b9de

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

docs/public/st0048-01.jpg

23 KB
Loading

docs/smalltalk/st0048.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# 凹语言图书: µGo语言实现
2+
3+
- 时间:2024-09-05
4+
- 撰稿:凹语言 开发组
5+
- 转载请注明原文链接:[https://wa-lang.org/smalltalk/st0048.html](https://wa-lang.org/smalltalk/st0048.html)
6+
7+
---
8+
9+
本书尝试以凹语言实现 µGo 编译器为线索,以边学习边完善的自举方式实现一个玩具语言。
10+
11+
![](/st0048-01.jpg)
12+
13+
## Why: 挖坑的起因
14+
15+
- 因为坑就在那里
16+
- 挖坑的工具差不多齐全了
17+
- 为了启动 [凹语言](https://github.com/wa-lang/wa) 的热身项目
18+
- 凹语言项目已过5年, 完成了当初不做玩具车的目标, 是时候向凹语言迁移了
19+
-
20+
21+
## What: µGo 例子
22+
23+
```go
24+
import "libc"
25+
import "libc.math" => m
26+
27+
const Pi = 3.14
28+
const Pi_2 = Pi * 2
29+
30+
type MyInt :int
31+
32+
global x = println(1 + 2*(3+4) + -10 + double(50))
33+
34+
func println() => int
35+
36+
func main => int {}
37+
```
38+
39+
## Output: 输出的目标格式
40+
41+
为了跨平台和方便测试,输出LLVM汇编代码,如果以后可能会增加WASM文件。
42+
43+
该书为开源图书,欢迎参与共建。

0 commit comments

Comments
 (0)