Go to file
chai2010 2cf421d628 更新 changelog, 准备 v0.6.0 变更日志 2023-04-13 17:59:05 +08:00
.github/workflows 完善 release action 2023-03-25 06:31:05 +08:00
.workflow gitee 流水线完善 2023-02-04 15:55:02 +08:00
_examples 添加打印素数的中文示例 2023-04-13 06:12:31 +00:00
api main 强制导入 runtime 包 2023-03-14 23:41:00 +08:00
docs snake: 补充缺少的 wasi 方法 2023-03-21 23:35:23 +08:00
internal 添加了中文内置函数”长“和内置类型”字“ 2023-04-13 09:32:22 +08:00
.gitignore 支持 os.Args 2023-03-11 07:36:22 +08:00
.goreleaser.yml 配置 homebrew-tap 2023-03-25 07:43:57 +08:00
CONTRIBUTORS Create CONTRIBUTORS 2022-11-02 23:09:03 +08:00
LICENSE 启用 AGPLv3 协议 2022-10-20 21:18:55 +08:00
Makefile 完善 release action 2023-03-25 06:31:05 +08:00
README-zh.md 添加打印素数的中文示例 2023-04-13 06:12:31 +00:00
README.md 添加打印素数的中文示例 2023-04-13 06:12:31 +00:00
arduino.wa 零碎细节修改 2023-04-11 06:47:30 +08:00
brainfuck.wa 调整注释合规, 中文别名关键字后面空格可省 2023-01-26 22:16:11 +08:00
changelog.md 更新 changelog, 准备 v0.6.0 变更日志 2023-04-13 17:59:05 +08:00
go.mod Revert "升级 wazero-1.0.1, 感谢 @codefromthecrypt 的补丁" 2023-04-02 06:50:03 +08:00
go.sum Revert "升级 wazero-1.0.1, 感谢 @codefromthecrypt 的补丁" 2023-04-02 06:50:03 +08:00
hello.wa 调整注释合规, 中文别名关键字后面空格可省 2023-01-26 22:16:11 +08:00
logo.ico windows 增加 exe 图标 2022-09-30 08:17:23 +08:00
main.go main 函数移到 wacli 包中 2023-04-03 20:29:30 +08:00
main.rc windows 增加 exe 图标 2022-09-30 08:17:23 +08:00
main_rc_windows_amd64.syso 完善 release action 2023-03-25 06:31:05 +08:00

README.md

The Wa Programming Language

简体中文 | English

Build Status Go Report Card Coverage Status GitHub release Go Reference license

Wa is a general-purpose programming language designed for developing robustness and maintainability WebAssembly software. Instead of requiring complex toolchains to set up, you can simply go install it - or run it in a browser.

Note: Our canonical Git repository is located at https://gitee.com/wa-lang/wa. There is a mirror of the repository at https://github.com/wa-lang/wa. Unless otherwise noted, the Wa source files are distributed under the AGPL-v3 license found in the LICENSE file.

Playground

https://wa-lang.org/playground

Snake Game

Install and Run:

Go >= 1.17

  1. go install wa-lang.org/wa@latest
  2. wa init -name=_examples/hi
  3. wa run _examples/hi

The Wa project is still in very early stage. If you want to submit PR, please read the Contribution Guide(Chinese). We do not accept PR only about 3rdparty changes.

Example: Print Wa

Print rune and call function

// Copyright @2019-2022 The Wa author. All rights reserved.

import "fmt"

func main {
	println("hello, Wa!")
	println(add(40, 2))

	fmt.Println(1+1)
}

func add(a: i32, b: i32) => i32 {
	return a+b
}

Execute the program:

$ go run main.go hello.wa 
hello, Wa!
42
2

Example: Print Prime

Print prime numbers up to 30:

func main {
	for n := 2; n <= 30; n = n + 1 {
		var isPrime int = 1
		for i := 2; i*i <= n; i = i + 1 {
			if x := n % i; x == 0 {
				isPrime = 0
			}
		}
		if isPrime != 0 {
			println(n)
		}
	}
}

Execute the program:

$ go run main.go run _examples/prime
2
3
5
7
11
13
17
19
23
29

Example: Print Prime with Chinese syntax

Print prime numbers up to 30:

引于 "书"

【启】:
    // 输出30以内的素数
    从n=2到n>30有n++
        设素=1
        从i=2到i*i>n有i++
            设x=n%i
            若x==0则
                素=0
            。
        。
        若素!=0则
            书·曰n
        。
     。
。

Output is the same as the previous example.

More examples _examples