Go to file
chai2010 0d4097dff6 完善 waroot 目录 2023-06-18 17:03:41 +08:00
.github/workflows 完善 waroot 目录 2023-06-18 17:03:41 +08:00
.workflow 完善 waroot 目录 2023-06-18 17:03:41 +08:00
api 完善 ci 测试 2023-06-09 21:11:22 +08:00
docs 完善 waroot 目录 2023-06-18 17:03:41 +08:00
internal 支持简短局部变量声明语法 2023-06-17 21:17:26 +08:00
waroot 完善 waroot 目录 2023-06-18 17:03:41 +08:00
.gitignore 支持 os.Args 2023-03-11 07:36:22 +08:00
LICENSE 启用 AGPLv3 协议 2022-10-20 21:18:55 +08:00
Makefile 完善 waroot 目录 2023-06-18 17:03:41 +08:00
README-zh.md 完善 waroot 目录 2023-06-18 17:03:41 +08:00
README.md 完善 waroot 目录 2023-06-18 17:03:41 +08:00
exe.rc 根目录只保留一个 main 名字的源文件, 方便执行时补全 2023-06-03 20:59:08 +08:00
exe_rc_windows_amd64.syso 根目录只保留一个 main 名字的源文件, 方便执行时补全 2023-06-03 20:59:08 +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
logo.ico windows 增加 exe 图标 2022-09-30 08:17:23 +08:00
main.go main 函数移到 wacli 包中 2023-04-03 20:29:30 +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:

Install from binary: download wa command from https://github.com/wa-lang/wa/releases, and set $PATH env.

Or install form Go (Go >= 1.17):

  1. go install wa-lang.org/wa@latest
  2. cd waroot
  3. wa init -name=examples/hi
  4. 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 {
		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:

$ cd waroot && 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 waroot/examples

Contributors

Contributor Contribution points
柴树杉 37000
丁尔男 42500
史斌 29000
扈梦明 14000
赵普明 17000
宋汝阳 2000
刘云峰 1000
王湘南 1000
王泽龙 1000
吴烜 3000
刘斌 2500