wa

command module
v0.20.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2025 License: AGPL-3.0 Imports: 27 Imported by: 0

README

The Wa Programming Language

简体中文 | English

Build Status Coverage Status GitHub release license CNCF Landscape

Wa-lang is a general-purpose programming language designed for for WebAssembly. The goal is to provide a simple, reliable, easy-to-use, statically typed language for high-performance web applications. The code generator and runtime are fully independently developed (not dependent on external projects such as LLVM). Currently, Wa-lang is in the engineering trial stage.

Note: Unless otherwise noted, the Wa source files are distributed under the AGPL-v3 license found in the LICENSE file.

How to contribute

The project is still in the prototype stage. If you have co-construction or PR needs, please refer to How to contribute. We no longer accept PRs for modifications to third-party libraries.

Note: Our canonical Git repository is located at https://gitcode.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.

Note: Submitting a PR to this repository is deemed to be your recognition and acceptance of the Wa-lang Contributor Agreement(Aka WCA), but your PRs will not be reviewed or accepted until WCA is actually signed.

Playground

https://wa-lang.org/playground

Snake Game

WASM4 Game

NES emulator

WebGPU Demo

P5 for creative coding

Arduino Nano 33

Example: Print Wa

Print rune and call function:

import "fmt"

global year: i32 = 2023

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

	fmt.Println(1+1)
}

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

Execute the program:

$ wa run hello.wa 
hello, Wa!
42 2023
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 && wa run -target=wasi 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.

Example: Chrome Native AI

Chrome builtin Gemini Nano Demo:

import "ai"

func main {
	ai.RequestSession(func(session: ai.Session){
		session.PromptAsync("Who are you?", func(res: string) {
			println(res)
		})
	})
}

More examples waroot/examples

Contributors

Contributor Contribution points
柴树杉 86000
丁尔男 90500
史斌 29000
扈梦明 49000
赵普明 18000
宋汝阳 2000
刘云峰 1000
王湘南 1000
王泽龙 1000
吴烜 3000
刘斌 2500
尹贻浩 2000
安博超 3000
yuqiaoyu 600
qstesiro 200
small_broken_gong 100
tk103331 100
蔡兴 3000
王仁义 1000
imalasong 1000
杨刚 4000
崔爽 2000

Give a Star! ⭐

If you like or are using Wa to learn or start your projects, please give it a star. Thanks!

Documentation

Overview

凹语言, The Wa Programming Language.

Directories

Path Synopsis
凹语言™ 功能 API 包。
凹语言™ 功能 API 包。
凹语言打包程序: Windows/Linux/macOS/wasm
凹语言打包程序: Windows/Linux/macOS/wasm
internal
3rdparty/cli
Package cli provides a minimal framework for creating and organizing command line Go applications.
Package cli provides a minimal framework for creating and organizing command line Go applications.
3rdparty/go-dap
Package dap contains data types and code for Debug Adapter Protocol (DAP) specification.
Package dap contains data types and code for Debug Adapter Protocol (DAP) specification.
3rdparty/go-dap/cmd/gentypes
gentypes generates Go types from debugProtocol.json
gentypes generates Go types from debugProtocol.json
3rdparty/gover
Package gover implements support for Go toolchain versions like 1.21.0 and 1.21rc1.
Package gover implements support for Go toolchain versions like 1.21.0 and 1.21rc1.
3rdparty/toml
Package toml implements decoding and encoding of TOML files.
Package toml implements decoding and encoding of TOML files.
3rdparty/wazero/api
Package api includes constants and interfaces used by both end-users and internal implementations.
Package api includes constants and interfaces used by both end-users and internal implementations.
3rdparty/wazero/experimental
Package experimental includes features we aren't yet sure about.
Package experimental includes features we aren't yet sure about.
3rdparty/wazero/imports/wasi_snapshot_preview1
Package wasi_snapshot_preview1 contains Go-defined functions to access system calls, such as opening a file, similar to Go's x/sys package.
Package wasi_snapshot_preview1 contains Go-defined functions to access system calls, such as opening a file, similar to Go's x/sys package.
3rdparty/wazero/internalx/platform
Package platform includes runtime-specific code needed for the compiler or otherwise.
Package platform includes runtime-specific code needed for the compiler or otherwise.
3rdparty/wazero/internalx/wasi_snapshot_preview1
Package wasi_snapshot_preview1 is an internal helper to remove package cycles re-using errno
Package wasi_snapshot_preview1 is an internal helper to remove package cycles re-using errno
3rdparty/wazero/internalx/wasmdebug
Package wasmdebug contains utilities used to give consistent search keys between stack traces and error messages.
Package wasmdebug contains utilities used to give consistent search keys between stack traces and error messages.
3rdparty/wazero/internalx/wasmruntime
Package wasmruntime contains internal symbols shared between modules for error handling.
Package wasmruntime contains internal symbols shared between modules for error handling.
3rdparty/wazero/internalx/wazeroir
Package wazeroir is a pkg to compile down the standard Wasm binary to wazero's specific IR (wazeroir).
Package wazeroir is a pkg to compile down the standard Wasm binary to wazero's specific IR (wazeroir).
3rdparty/wazero/sys
Package sys includes constants and types used by both public and internal APIs.
Package sys includes constants and types used by both public and internal APIs.
ast
Package ast declares the types used to represent syntax trees for Go packages.
Package ast declares the types used to represent syntax trees for Go packages.
ast/astutil
Package astutil contains common utilities for working with the Go AST.
Package astutil contains common utilities for working with the Go AST.
ast/inspector
Package inspector provides helper functions for traversal over the syntax trees of a package, including node filtering by type, and materialization of the traversal stack.
Package inspector provides helper functions for traversal over the syntax trees of a package, including node filtering by type, and materialization of the traversal stack.
backends/compiler_c/cir/ctypes
ctypes包定义C-IR的类型
ctypes包定义C-IR的类型
backends/compiler_wat/wir/wat
WAT 文本格式的模块。
WAT 文本格式的模块。
constant
Package constant implements Values representing untyped Go constants and their corresponding operations.
Package constant implements Values representing untyped Go constants and their corresponding operations.
dap
dlopen
以不依赖CGO的方式加载不同平台的共享库.
以不依赖CGO的方式加载不同平台的共享库.
format
Package format implements standard formatting of Go source.
Package format implements standard formatting of Go source.
frontend/wz/parser
Package parser implements a parser for Go source files.
Package parser implements a parser for Go source files.
frontend/wz/scanner
Package scanner implements a scanner for Go source text.
Package scanner implements a scanner for Go source text.
frontend/wz/token
Package token defines constants representing the lexical tokens of the Go programming language and basic operations on tokens (printing, predicates).
Package token defines constants representing the lexical tokens of the Go programming language and basic operations on tokens (printing, predicates).
lsp
lsp/diff
Package diff computes differences between text files or strings.
Package diff computes differences between text files or strings.
lsp/diff/lcs
package lcs contains code to find longest-common-subsequences (and diffs)
package lcs contains code to find longest-common-subsequences (and diffs)
lsp/event
Package event provides a set of packages that cover the main concepts of telemetry in an implementation agnostic way.
Package event provides a set of packages that cover the main concepts of telemetry in an implementation agnostic way.
lsp/event/core
Package core provides support for event based telemetry.
Package core provides support for event based telemetry.
lsp/event/tag
Package tag provides the labels used for telemetry throughout gopls.
Package tag provides the labels used for telemetry throughout gopls.
lsp/filecache
The filecache package provides a file-based shared durable blob cache.
The filecache package provides a file-based shared durable blob cache.
lsp/jsonrpc2
Package jsonrpc2 is a minimal implementation of the JSON RPC 2 spec.
Package jsonrpc2 is a minimal implementation of the JSON RPC 2 spec.
lsp/protocol
Package protocol contains the structs that map directly to the request and response messages of the Language Server Protocol.
Package protocol contains the structs that map directly to the request and response messages of the Language Server Protocol.
lsp/span
Package span contains support for representing with positions and ranges in text files.
Package span contains support for representing with positions and ranges in text files.
lsp/util/lru
The lru package implements a fixed-size in-memory LRU cache.
The lru package implements a fixed-size in-memory LRU cache.
lsp/util/safetoken
Package safetoken provides wrappers around methods in go/token, that return errors rather than panicking.
Package safetoken provides wrappers around methods in go/token, that return errors rather than panicking.
lsp/xcontext
Package xcontext is a package to offer the extra functionality we need from contexts that is not available from the standard context package.
Package xcontext is a package to offer the extra functionality we need from contexts that is not available from the standard context package.
parser
Package parser implements a parser for Go source files.
Package parser implements a parser for Go source files.
printer
Package printer implements printing of AST nodes.
Package printer implements printing of AST nodes.
scanner
Package scanner implements a scanner for Go source text.
Package scanner implements a scanner for Go source text.
ssa
Package ssa defines a representation of the elements of Go programs (packages, types, functions, variables and constants) using a static single-assignment (SSA) form intermediate representation (IR) for the bodies of functions.
Package ssa defines a representation of the elements of Go programs (packages, types, functions, variables and constants) using a static single-assignment (SSA) form intermediate representation (IR) for the bodies of functions.
token
Package token defines constants representing the lexical tokens of the Go programming language and basic operations on tokens (printing, predicates).
Package token defines constants representing the lexical tokens of the Go programming language and basic operations on tokens (printing, predicates).
types
Package types declares the data types and implements the algorithms for type-checking of Go packages.
Package types declares the data types and implements the algorithms for type-checking of Go packages.
types/objectpath
Package objectpath defines a naming scheme for types.Objects (that is, named entities in Go programs) relative to their enclosing package.
Package objectpath defines a naming scheme for types.Objects (that is, named entities in Go programs) relative to their enclosing package.
types/typeutil
Package typeutil defines various utilities for types, such as Map, a mapping from types.Type to interface{} values.
Package typeutil defines various utilities for types, such as Map, a mapping from types.Type to interface{} values.
wat/token
wat记号类型
wat记号类型
tests
src

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL