Go to file
chai2010 165af52439 准备发版日志 2022-11-16 00:18:49 +08:00
.github/workflows Delete pr.yml 2022-10-29 06:46:20 +08:00
_examples test: improve test case _examples/prime. 2022-11-08 19:36:01 +08:00
api Remove useless files. 2022-10-29 16:54:39 +08:00
docs logo 1024 2022-10-24 21:07:43 +08:00
internal 准备发版日志 2022-11-16 00:18:49 +08:00
.gitignore 命令行增加 llvm 命令参数 2022-11-16 00:18:19 +08:00
CONTRIBUTORS Create CONTRIBUTORS 2022-11-02 23:09:03 +08:00
LICENSE 启用 AGPLv3 协议 2022-10-20 21:18:55 +08:00
Makefile windows 增加 exe 图标 2022-09-30 08:17:23 +08:00
README.md 准备发版日志 2022-11-16 00:18:49 +08:00
changelog.md 准备发版日志 2022-11-16 00:18:49 +08:00
go.mod deps: updates wazero to 1.0.0-pre.3 (#37) 2022-11-01 23:44:01 +08:00
go.sum deps: updates wazero to 1.0.0-pre.3 (#37) 2022-11-01 23:44:01 +08:00
hello.wa 准备发版日志 2022-11-16 00:18:49 +08:00
logo.ico windows 增加 exe 图标 2022-09-30 08:17:23 +08:00
main.go 命令行增加 llvm 命令参数 2022-11-16 00:18:19 +08:00
main.rc windows 增加 exe 图标 2022-09-30 08:17:23 +08:00
main_rc_windows.syso windows 增加 exe 图标 2022-09-30 08:17:23 +08:00

README.md

🇨🇳 凹语言™ The Wa Programming Language

主页 | Playground | 目标 | 路线 | 社区 | 日志 | 论坛

Document | Playground | Goals | Roadmap | Community | Changelog | Discussions

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

凹语言™凹读音“Wa”是 针对 WASM 平台设计的通用编程语言,同时支持 Linux、macOS 和 Windows 等主流操作系统和 Chrome 等浏览器环境同时也支持作为独立Shell脚本和被嵌入脚本模式执行。

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.

Playground 在线预览

https://wa-lang.org/playground

本地安装和测试 (Install and Run):

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

项目尚处于原型开源阶段如果有共建和PR需求请参考 如何贡献代码

The Wa project is still in very early stage. If you want to submit PR, please read the Contribution Guide(Chinese).

例子: 凹语言 (Example: Print 凹语言)

打印字符和调用函数(Print rune and call function)

import "fmt"

fn main {
	println("你好,凹语言!")
	println(add(40, 2))

	fmt.Println(1+1)
}

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

运行并输出结果 (Execute the program):

$ go run main.go hello.wa 
你好,凹语言!
42
2

例子: 打印素数 (Example: Print Prime)

打印 30 以内的素数 (Print prime numbers up to 30):

# 版权 @2021 凹语言™ 作者。保留所有权利。

fn 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

更多例子 (More examples) _examples

作为脚本执行 (Execut as a script)

凹语言本身也可以像 Lua 语言被嵌入 Go 宿主语言环境执行 (The Wa language itself can also be executed like the Lua language embedded in the Go host locale):

package main

import (
	"fmt"
	"github.com/wa-lang/wa/api"
)

func main() {
	output, err := api.RunCode("hello.wa", "fn main() { println(40+2) }")
	fmt.Print(string(output), err)
}

注:作为脚本执行目前只支持本地环境。(Note: Executing as a script currently only supports native environments.)

版权(License)

版权 @2019-2022 凹语言™ 作者。保留所有权利。(Copyrighe @2019-2022 The Wa author. All rights reserved.)