Skip to content

It aims to be for WASM what YAML is for JSON. Programming language targetting WebAssembly. Human friendly WAT

License

Notifications You must be signed in to change notification settings

CalmSystem/wala

Repository files navigation

Wala

A language trying to simplify WebAssembly Text syntax while keeping the full expressiveness and retro-compatibility. Unwittingly becoming a Zig toolchain for WASM.

Pronounced \vwa.la\ as in french voila (meaning here it is). The exact acronym's composition is unspecified but can be interpreted as WebAssembly Language Adaptor or What Another Linguistic Anomaly.

Philosophy

It is implemented as a set of complementary extensions over standard WebAssembly Text Format

func $fib export()
  u64 $n -> ?
  if {$n <= 2}
    1
    +
      $fib{$n - 2}
      $fib{$n - 1}

Is expended to:

(module
  (func $fib (export "fib") (param $n i64) (result i64)
    (if (result i64) (i64.le_u (local.get $n) (i64.const 2))
      (i64.const 1)
      (i64.add
        (call $fib (i64.sub (local.get $n) (i64.const 2)))
        (call $fib (i64.sub (local.get $n) (i64.const 1)))))))

For working samples see: fib, fizzbuzz, 99bottles, ...

Install

Prerequisites

Optional

Building

git clone https://github.com/CalmSystem/wala.git
cd wala
zigmod ci
zig build -Drelease-safe
PATH=$PATH:./zig-out/bin

Usage

  • Run built module (default WASI engine: --runtime wasmtime)
wala run samples/hello.wala
  • Convert samples/fib.wala to Wasm
wala build samples/fib.wala > fib.wasm

Features

Sweet expression

Deducing parentheses from indentation based on Readable Lisp S-expressions Project's Spir110

Curly infix expressions

  • {"hello" upper} -> (upper "hello)
  • {a + b} -> (+ a b)
  • {a * b * c} -> (* a b c)
  • {$fn call a b c} -> (call $fb a b c}

Neoteric expression

Like function calls

  • cos(v) -> (cos v)
  • e() -> (e)
  • sum(a b c) -> (sum a b c)
  • f{n + 1} -> (f (+ n 1))

Short const

  • 42i32 -> (i32.const 42)

Operand type deduction

  • (i32.add 35 7) -> (i32.add (i32.const 35) (i32.const 7))
  • (i64.add 35 7) -> (i64.add (i64.const 35) (i64.const 7))

Common operators

  • (+ 35i32 7) -> (i32.add (i32.const 35) (i32.const 7))
  • (+ 35i64 7) -> (i64.add (i64.const 35) (i64.const 7))

Ident expansion

  • ($a_func $a_param $a_global) -> (call $a_func (local.get $a_param) (global.get $a_global))

Assign operator

  • {$a_local = 5} -> (local.set $a_local (i32.const 5))
  • {$a_global = 5} -> (global.set $a_local (i32.const 5))

Interface types numbers

  • {42s64 <= 1} -> (i64.le_s (i64.const 42) (i64.const 1))
  • {42u64 <= 1} -> (i64.le_u (i64.const 42) (i64.const 1))

Define

  • {$C := 5} (call $func $C $C) -> (call $func (i32.const 5) (i32.const 5))

Planned

Result Type Deduction

No need to specify blocks and function result types

Interface integration

Allows to define, import and use wit declarations. See fib.wasi.wal

License

Distributed under the MIT license to facilitate cooperation and knowledge sharing. However, use with respect to contributors and end-users is strongly advised. See LICENSE for more information.

About

It aims to be for WASM what YAML is for JSON. Programming language targetting WebAssembly. Human friendly WAT

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages