wax是一个小型的编程语言,可以转译成C, C++, Java, TypeScript, Python, c#, Swift, Lua和WebAssembly。
主要特性
- 强静态类型
- 内置支持数组、哈希表和结构体
- 支持与 C 类似的宏
- 语法简单
- 不支持 OOP
- ……
wax语法受WebAssembly Text Format(wat)启发,并且与C极为相似。
(func main (result int)
(print "hello world!")
(return 0)
)
;; sort array in-place for index range [lo,hi] inclusive (func qksort_inplace (param A (arr float)) (param lo int) (param hi int) (if (>= lo hi) (then (return) )) (let pivot float (get A lo)) (let left int lo) (let right int hi) (while (<= left right) (do (while (< (get A left) pivot) (do (set left (+ left 1)) )) (while (> (get A right) pivot) (do (set right (- right 1)) )) (if (<= left right) (then (let tmp float (get A left)) (set A left (get A right)) (set A right tmp) (set left (+ left 1)) (set right (- right 1)) )) )) (call qksort_inplace A lo right) (call qksort_inplace A left hi) ) (func qksort (param A (arr float)) (if (! (# A)) (then (return) )) (call qksort_inplace A 0 (- (# A) 1)) )