Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/wa-lang/man
Browse files Browse the repository at this point in the history
  • Loading branch information
3dgen committed Apr 10, 2024
2 parents 725837f + 2999f2d commit 3b9e02f
Show file tree
Hide file tree
Showing 28 changed files with 855 additions and 32 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/book.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: mdbook
name: mnbook
on:
push:
branches:
Expand All @@ -18,11 +18,13 @@ jobs:
- name: Git checkout
uses: actions/checkout@v2

- name: Setup mdBook
uses: peaceiris/actions-mdbook@v1
- name: Set up Go
uses: actions/setup-go@v2
with:
mdbook-version: '0.4.10'
# mdbook-version: 'latest'
go-version: 1.21

- run: go version
- run: go install github.com/wa-lang/mnbook@latest

- run: make build

Expand Down
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# go install github.com/wa-lang/mnbook@latest

default:
mdbook serve
mnbook serve

build:
-rm book
mdbook build
mnbook build
make -C en build
-rm book/.gitignore
-rm -rf book/.git

deploy:
-rm book
mdbook build
mnbook build
make -C en build
-rm book/.gitignore
-rm -rf book/.git
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Wa-lang's Manual

![](en/cover.png)
<img width="520px" height="660px" src="en/cover.svg" />

- Online manual:[https://wa-lang.github.io/man/en/](https://wa-lang.github.io/man/en/)
- Online manual(Chinese):[https://wa-lang.org/man/](https://wa-lang.org/man/)
- Github Repo: [https://github.com/wa-lang/man](https://github.com/wa-lang/man)

# 凹语言手册

![](cover.png)
<img width="520px" height="660px" src="cover.svg" />

- 在线地址:[https://wa-lang.org/man/](https://wa-lang.org/man/)
- 在线地址(英文):[https://wa-lang.github.io/man/en/](https://wa-lang.github.io/man/en/)
Expand Down
2 changes: 1 addition & 1 deletion chs/1.安装及入门/1.1.你好凹语言.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func add(a: i32, b: i32) => i32 {
}
```

其中`//`开始的是行注释,`import`关键字导入了2个包准库的包`global`关键字定义了一个全局变量,并给了2023的初始值。`func`关键字定义了`main`函数和`add`函数。`main`函数是程序的入口,其中通过内置的`println`函数打印了“你好,凹语言!”,同时使用`fmt`包的`Println`字符串和整数表达式的结果。在`main`函数还使用了全局的`year`变量,此外还调用了`add`函数并打印了返回值。`add`函数有2个输入参数和一个返回值。
其中`//`开始的是行注释,`import`关键字导入了2个标准库的包`global`关键字定义了一个全局变量,并给了2023的初始值。`func`关键字定义了`main`函数和`add`函数。`main`函数是程序的入口,其中通过内置的`println`函数打印了“你好,凹语言!”,同时使用`fmt`包的`Println`字符串和整数表达式的结果。在`main`函数还使用了全局的`year`变量,此外还调用了`add`函数并打印了返回值。`add`函数有2个输入参数和一个返回值。

如果在本地已经安装有凹语言的`wa`命令(安装方式参考1.2节),可以输入以下命令执行:

Expand Down
2 changes: 1 addition & 1 deletion chs/1.安装及入门/1.3.命令行功能.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ $ wa run ./output/hello.wasm
...
```

如果不带参赛执行 `wa run` 命令,表示编译并执行当前凹语言工程,会先构建出 `output/hello.wasm` 然后再执行。
如果不带参数执行 `wa run` 命令,表示编译并执行当前凹语言工程,会先构建出 `output/hello.wasm` 然后再执行。

### 1.3.4 格式化代码

Expand Down
4 changes: 2 additions & 2 deletions chs/3.基础数据类型/3.1.局部变量声明.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
局部变量名: 数据类型 = 初始值
```

与全部变量和常量不同的是:局部变量的声明不以关键字开始;在声明局部变量时,如果省略 `= 初始值` 部分,则该变量将以0值初始化,如:
与全局变量和常量不同的是:局部变量的声明不以关键字开始;在声明局部变量时,如果省略 `= 初始值` 部分,则该变量将以0值初始化,如:

```wa
aI32: i32 = 42
aString: string = "你好"
aF32: f32 // 0.0
```

另一种常用的声明局部变量的语法使用快捷定义符 `:=` ,语法如下:
另一种常用的声明局部变量的语法是使用快捷定义符 `:=` ,语法如下:

```wa
局部变量名 := 表达式
Expand Down
2 changes: 1 addition & 1 deletion chs/3.基础数据类型/3.2.整数.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
- `&`:按位取与,两个操作数类型必须一致,返回值类型与操作数一致;
- `|`:按位取或,两个操作数类型必须一致,返回值类型与操作数一致;
- `^`:按位取异或,两个操作数类型必须一致,返回值类型与操作数一致;
- `&^`:按位清空,两个操作数类型必须一致,返回值类型与操作数一致。对 `z = x ^& y`,设 `xn``yn``zn` 分别为 `x``y``z` 的第n位,则当 `yn` 为1时 `zn` 为0,否则 `zn` 等于 `xn`。该运算等价于 `z = x & (^y)`
- `&^`:按位清空,两个操作数类型必须一致,返回值类型与操作数一致。对 `z = x &^ y`,设 `xn``yn``zn` 分别为 `x``y``z` 的第n位,则当 `yn` 为1时 `zn` 为0,否则 `zn` 等于 `xn`。该运算等价于 `z = x & (^y)`
- `<<`:左移,对 `z = x << y``z` 的类型与 `x` 一致,`y` 必须为大于0的整数,移位时低位补0;
- `>>`:右移,对 `z = x >> y``z` 的类型与 `x` 一致,`y` 必须为大于0的整数,移位时高位补0。

Expand Down
2 changes: 1 addition & 1 deletion chs/3.基础数据类型/3.4.字符串.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
println(s[1:3]) // ��
```

`s[m:n]` 用法从第`n`个字节处开始截取,返回的字串长度为 `n-m` 字节。若省略 `m` 则表示从字符串开始截取,若省略 `n` 则表示截取至字符串末尾,例如:
`s[m:n]` 用法从第`m`个字节处开始截取,返回的字串长度为 `n-m` 字节。若省略 `m` 则表示从字符串开始截取,若省略 `n` 则表示截取至字符串末尾,例如:
```wa
s := "abcdefg"
println(s[:3]) // abc
Expand Down
2 changes: 1 addition & 1 deletion chs/9.附录/a-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ImportPath = string_lit .
PackageName = identifier .
```

imort 关键字用于导入包,导入的包还可以被重新命名(对应PackageName)。
import 关键字用于导入包,导入的包还可以被重新命名(对应PackageName)。

以下代码是一个凹源文件的对应例子:

Expand Down
Binary file removed cover.png
Binary file not shown.
43 changes: 43 additions & 0 deletions cover.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion en/3.BasicTypes/3.2.Integers.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Integers(except Boolean) support the following binary bit operations:
- `&`: bitwise AND, the two operand types must be consistent, the type of return value is same with operands;
- `|`: Bitwise OR, the two operand types must be consistent, the type of return value is same with operands;
- `^`: Bitwise XOR, the two operand types must be consistent, the type of return value is same with operands;
- `&^`: clear bitwise, the two operand types must be consistent, the type of return value is same with operands. For `z = x ^& y`, let `xn`, `yn`, `zn` be the nth bit of `x`, `y`, `z` respectively, then when `yn` is 1, `zn ` is 0, otherwise `zn` is equal to `xn`. This operation is equivalent to `z = x & (^y)`;
- `&^`: clear bitwise, the two operand types must be consistent, the type of return value is same with operands. For `z = x &^ y`, let `xn`, `yn`, `zn` be the nth bit of `x`, `y`, `z` respectively, then when `yn` is 1, `zn ` is 0, otherwise `zn` is equal to `xn`. This operation is equivalent to `z = x & (^y)`;
- `<<`: Left shift, for `z = x << y`, the type of `z` is consistent with `x`, `y` must be an integer greater than 0, and the low-order bit is filled with 0 when shifting;
- `>>`: Right shift, for `z = x >> y`, the type of `z` is consistent with `x`, `y` must be an integer greater than 0, and the high bit is filled with 0 when shifting.

Expand Down
2 changes: 1 addition & 1 deletion en/3.BasicTypes/3.4.String.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ In this usage, the subscripted units within `[]` are bytes, not characters. If t
println(s[1:3]) // ��
```

`s[m:n]` operation starts from the `n`th byte, and the length of the returned string is `n-m` bytes. If `m` is omitted, it means start from the beginning of the string. If `n` is omitted, it means intercepting to the end of the string. For example:
`s[m:n]` operation starts from the `m`th byte, and the length of the returned string is `n-m` bytes. If `m` is omitted, it means start from the beginning of the string. If `n` is omitted, it means intercepting to the end of the string. For example:
```wa
s := "abcdefg"
println(s[:3]) // abc
Expand Down
6 changes: 3 additions & 3 deletions en/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
default:
mdbook serve
mnbook serve

build:
-rm ../book/en
-rm -rf ../book/en
mkdir -p ../book/en
mdbook build -d ../book/en
mnbook build && mv ./book ./en && mv ./en ../book/
-rm ../book/en/.gitignore

clean:
Expand Down
6 changes: 4 additions & 2 deletions en/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

***Ending's law: "Any application that can be compiled to WebAssembly, will be compiled to WebAssembly eventually."***

![](cover.png)
<img width="520px" height="660px" src="cover.svg" />

- Online manual:[https://wa-lang.org/man/](https://wa-lang.org/man/)
- Github: [https://github.com/wa-lang/wa](https://github.com/wa-lang/wa)
- Online manual: [https://wa-lang.github.io/man/en/](https://wa-lang.github.io/man/en/)
- Online manual(Chinese): [https://wa-lang.org/man/](https://wa-lang.org/man/)
2 changes: 1 addition & 1 deletion en/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[Wa-lang's manual](index.md)
[Preface](preface.md)

* [1.Install And Get Start](./1.InstallAndGetStart/readme.md)
* [Install And Get Start](./1.InstallAndGetStart/readme.md)
- [hello world](./1.InstallAndGetStart/1.1.HelloWorld.md)
- [Install Wa-lang Compiler](./1.InstallAndGetStart/1.2.Install.md)
- [wa command line](./1.InstallAndGetStart/1.3.Command.md)
Expand Down
Binary file removed en/cover.png
Binary file not shown.
55 changes: 55 additions & 0 deletions en/cover.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions en/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Wa-lang's Manual

![](cover.png)
![](cover.svg)

- Online manual:[https://wa-lang.github.io/man/en/](https://wa-lang.github.io/man/en/)
- Online manual(Chinese):[https://wa-lang.org/man/](https://wa-lang.org/man/)
- Github Repo: [https://github.com/wa-lang/man](https://github.com/wa-lang/man)
- Github: [https://github.com/wa-lang/wa](https://github.com/wa-lang/wa)
- Online manual: [https://wa-lang.github.io/man/en/](https://wa-lang.github.io/man/en/)
- Online manual(Chinese): [https://wa-lang.org/man/](https://wa-lang.org/man/)
1 change: 0 additions & 1 deletion en/wa-man-en.drawio

This file was deleted.

4 changes: 4 additions & 0 deletions icons/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
default:
base64 -i logo-animate1.svg -o logo-animate1.base64.txt
base64 -i logo-round-color-LightSeaGreen.svg -o logo-round-color-LightSeaGreen.base64.txt
clean:
1 change: 1 addition & 0 deletions icons/logo-animate1.base64.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PCEtLSAKLy8g54mI5p2DIEAyMDE5IOWHueivreiogCDkvZzogIXjgILkv53nlZnmiYDmnInmnYPliKnjgIIKLy8gaHR0cHM6Ly93YS1sYW5nLm9yZwotLT4KCjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2aWV3Qm94PSIwIDAgNDAwIDQwMCIgd2lkdGg9IjQwMCIgaGVpZ2h0PSI0MDAiIGZpbGw9Im5vbmUiPgoKICA8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTUwIDcwQzUwIDU4Ljk1NDMgNTguOTU0MyA1MCA3MCA1MEgxMzBDMTQxLjA0NiA1MCAxNTAgNTguOTU0MyAxNTAgNzBWNzRWMTMwVjE1MEgyNTBWMTMwVjc0VjcwQzI1MCA1OC45NTQzIDI1OC45NTQgNTAgMjcwIDUwSDMzMEMzNDEuMDQ2IDUwIDM1MCA1OC45NTQzIDM1MCA3MFY5NFYxMzBWMz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9zdmc+
22 changes: 22 additions & 0 deletions icons/logo-animate1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/logo-round-color-LightSeaGreen.base64.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CjwhLS0KLy8g54mI5p2DIEAyMDE5IOWHueivreiogCDkvZzogIXjgILkv53nlZnmiYDmnInmnYPliKnjgIIKLy8gaHR0cHM6Ly93YS1sYW5nLm9yZwotLT4KCjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIgoJdmlld0JveD0iMCAwIDQwMCA0MDAiIHdpZHRoPSI0MDAiIGhlaWdodD0iNDAwIgoJc3R5bGU9ImJvcmRlcjogMHB4IHNvbGlkIHJlZCIKPgoKPHBhdGgKCXN0cm9rZT0ibm9uZSIgZmlsbD0iTGlnaHRTZWFHcmVlbiIKCWQ9Ik02MCw1MCBoOTAgdjEwMCBoMTAwIHYtMTAwIGg5MCBsMTAsMTAgdjI4MCBsLTEwLDEwIGgtMjgwIGwtMTAsLTEwIHYtMjgwIgovPgoKPHBhdGgKCXN0cm9rZT0ibm9uZSIgZmlsbD0id2hpdGUiCglkPSJNMTAwLDEwMCBtLTUsLTUgaDEwIHYxMCBoLTEwIgovPgoKPHBhdGgKCXN0cm9rZT0ibm9uZSIgZmlsbD0id2hpdGUiCglkPSJNNDAwLDEwMCBtLTEwMCwwIG0tNSwtNSBoMTAgdjEwIGgtMTAiCi8+Cgo8cGF0aAoJc3Ryb2tlPSJ3aGl0ZSIgZmlsbD0ibm9uZSIgc3Ryb2tlLXdpZHRoPSI4IiBzdHJva2UtbGluZWNhcD0icm91bmQiCglkPSJNMjAwLDIzMCBsMzQsMzQgbDM0LC0zNCBNMjAwLDIzMCBsLTM0LDM0IGwtMzQsLTM0IgovPgoKPC9zdmc+Cg==
32 changes: 32 additions & 0 deletions icons/logo-round-color-LightSeaGreen.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![](cover.png)
![](cover.svg)

- 在线地址:[https://wa-lang.org/man/](https://wa-lang.org/man/)
- 在线地址(英文):[https://wa-lang.github.io/man/en/](https://wa-lang.github.io/man/en/)
Expand Down
1 change: 0 additions & 1 deletion wa-man.drawio

This file was deleted.

0 comments on commit 3b9e02f

Please sign in to comment.