aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs/teal_lang.yue
blob: e01682f4147f3eff953f13bd3d9e17071c2abe35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import "macro_teal" as $

$local "a:{string:number}", {value:123}
$local "b:number", a.value

$function "add(a:number, b:number):number", -> a + b

s = add(a.value, b)
print(s)

$record Point,
	x: number
	y: number

$method "Point.new(x:number, y:number):Point", ->
	$local "point:Point", setmetatable {}, __index: Point
	point.x = x or 0
	point.y = y or 0
	point

$method "Point:move(dx:number, dy:number)", ->
	@x += dx
	@y += dy

$local "p:Point", Point.new 100, 100

p\move 50, 50

$function "filter(tab:{string}, handler:function(item:string):boolean):{string}", ->
	[item for item in *tab when handler item]

$function "cond(item:string):boolean", -> item ~= "a"

res = filter {"a", "b", "c", "a"}, cond
for s in *res
	print s