aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs/teal-lang.yue
diff options
context:
space:
mode:
Diffstat (limited to 'spec/inputs/teal-lang.yue')
-rw-r--r--spec/inputs/teal-lang.yue39
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/inputs/teal-lang.yue b/spec/inputs/teal-lang.yue
new file mode 100644
index 0000000..1993203
--- /dev/null
+++ b/spec/inputs/teal-lang.yue
@@ -0,0 +1,39 @@
1$ ->
2 package.yuepath = "?.yue;./spec/inputs/?.yue"
3
4import "macro-teal" as {$}
5
6$local "a:{string:number}", {value:123}
7$local "b:number", a.value
8
9$function "add(a:number, b:number):number", -> a + b
10
11s = add(a.value, b)
12print(s)
13
14$record Point,
15 x: number
16 y: number
17
18$method "Point.new(x:number, y:number):Point", ->
19 $local "point:Point", setmetatable {}, __index: Point
20 point.x = x or 0
21 point.y = y or 0
22 point
23
24$method "Point:move(dx:number, dy:number)", ->
25 @x += dx
26 @y += dy
27
28$local "p:Point", Point.new 100, 100
29
30p\move 50, 50
31
32$function "filter(tab:{string}, handler:function(item:string):boolean):{string}", ->
33 [item for item in *tab when handler item]
34
35$function "cond(item:string):boolean", -> item ~= "a"
36
37res = filter {"a", "b", "c", "a"}, cond
38for s in *res
39 print s