Go to file
chai2010 093eb2b5ab 完善 ci 测试 2023-05-27 11:24:53 +08:00
.github/workflows 完善 ci 测试 2023-05-27 11:24:53 +08:00
.workflow gitee 流水线完善 2023-02-04 15:55:02 +08:00
_dev/play-chai 构造 play 测试代码, 对比 js 和 本地环境运行差异 2023-04-29 07:54:43 +08:00
_examples 完善 ci 测试 2023-05-27 11:19:03 +08:00
api 添加 _examples 到 ci 测试 2023-05-27 11:04:47 +08:00
docs 添加 png 格式 logo 2023-05-20 18:18:33 +08:00
internal 完善 ci 测试 2023-05-27 11:19:03 +08:00
.gitignore 支持 os.Args 2023-03-11 07:36:22 +08:00
CONTRIBUTORS Create CONTRIBUTORS 2022-11-02 23:09:03 +08:00
LICENSE 启用 AGPLv3 协议 2022-10-20 21:18:55 +08:00
Makefile 完善 ci 测试 2023-05-27 11:19:03 +08:00
README-zh.md wat2wasm 改用 wasm 版本; 更新变更日志 2023-05-26 01:03:03 +08:00
README.md 修改中文版示例的格式 2023-04-15 02:05:35 +08:00
arduino.wa 零碎细节修改 2023-04-11 06:47:30 +08:00
brainfuck.wa 调整注释合规, 中文别名关键字后面空格可省 2023-01-26 22:16:11 +08:00
changelog.md wat2wasm 改用 wasm 版本; 更新变更日志 2023-05-26 01:03:03 +08:00
go.mod wat2wasm 改用 wasm 版本; 更新变更日志 2023-05-26 01:03:03 +08:00
go.sum wat2wasm 改用 wasm 版本; 更新变更日志 2023-05-26 01:03: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