Was: Wax in shrubbery notation -- a reader that produces the Wax AST
Dependencies
type ints = [i32]
export "sum" fn sum(arr :: &ints) -> i32:
let total :: i32 = 0
let i :: i32 = 0
while i <~ arr.length():
total += arr[i]
i += 1
total| wax | was | why |
|---|---|---|
| x: i32 | x :: i32 | : opens a block, once, at the end of a group |
| { … } block | : and indentation | same |
| 'label | ~label | '…' is a shrubbery bracket pair |
| 'A' | char"A" | same |
| #[export = "n"] | export "n" prefix | # is reserved |
| a \| b | a \|\| b | a bare \| introduces alternatives |
| <s <u /s /u %s %u >>s >>u | <~ <$ /~ /$ %~ %$ >>~ >>$ | no shrubbery operator may contain a letter |
| [t\| a, b] | t[a, b] | \| again |
| [t\| v; n] | t[v ** n] | ; cannot separate groups inside […] |
| [t\| d @ off; n] | t[d at off ** n] | @ is at-notation |
| if c {…} else {…} | if c \| … \| … | alternatives |
| match v { p: &t => … } | match v \| p :: &t: … | alternatives |
| try t {…} catch {…} | try -> t: … \| tag: … | a block, then alternatives |
moon add marianoguerra/was@was.compile_string(src) // -> Result[Bytes, Diagnostics]
@was.compile_string_to_wat(src) // the same module, printed
@was.fields(src) // -> the Wax AST, and nothing further
@was.print_module(fields) // -> the other direction
@was.format_string(src) // read it, print it back| package | what |
|---|---|
| marianoguerra/was | the facade: source to Wax AST, wasm or wat |
| marianoguerra/was/read | the reader |
| marianoguerra/was/print | the printer |
moon check --deny-warn
moon testfn check_string(src : String, fname? : String, features? : Set, policy? : Policy) -> Result[Checked, Diagnostics]fn compile_string(src : String, fname? : String, features? : Set, policy? : Policy) -> Result[Bytes, Diagnostics] raise CompileErrorfn compile_string_to_wat(src : String, fname? : String, features? : Set, policy? : Policy) -> Result[String, Diagnostics] raise CompileErrorInstall
Download zipWas: Wax in shrubbery notation -- a reader that produces the Wax AST
Dependencies