-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathspeedie_syntax.spd
More file actions
executable file
·109 lines (80 loc) · 2.14 KB
/
speedie_syntax.spd
File metadata and controls
executable file
·109 lines (80 loc) · 2.14 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/local/bin/spd
// maybe.spd: Tests a lot of different syntax and features in one project.
// doesnt really actually do anything useful otherwise.
targets: flow
class Person
|int| age
|string| name
setter Age (|int|)
expect (value > 0 and value < 300) "Age $value out of range on ${.name}"
.age = value
render
fs <~ "$.name's age is $.age"
main
using flowcontrol.Attempt("maybe")
app.TestSyntax
function PrintNum (|int64| b1)
"${B1.strsize} = $B1"
function app.TestSyntax
printnum(60GB)
printnum(7.9MB|int|)
printnum(9524600)
|| P = person(12, "fred")
P.age = -2 // try to corrupt the age
"$p" // see if it worked or not?
|| x = ["a", "b", "c"]
if x == 3
"$x has three items."
|| H = "house"
if H == 5
"'$H' has five letters"
|| L = "(a,b,c,d)".parse
if L == 4
"The list $L has four items!"
|| zz = 0
for i in 1 to 6
if i isa 2
"$i is even"
zz[i] = true
else
"$i is odd"
"zz is $zz"
FlowControl.DisabledIncr(1)
for 4
|| fn = (mesayer, shesayer)(0.5[])
(fn)(app.args[0] ?? "hello")
FlowControl.DisabledIncr(-1)
bug()
function Bug (|fn_doaction!|)
opt norefcounts
|| G = RPGHero("fred")
|dictionary of fn_doaction| dict
|| x = dict["hello"]
(x[])(G, "no reason")
|| j = DoAction["jump"]
j[](G, "hes scared")
if x
return x[]
return DoAction_duck
prototype SayerFunction (|string?| input)
function MeSayer (SayerFunction): "Me says: $input"
function SheSayer (SayerFunction): "Rebecca says: $input (very quietly)"
class RPGHero // for a tile-based board game
|string| Name
|bool| OnGround
|bool| IsDucking
|int| YSpeed
|int| GroundSpeed
constructor (|string| name)
.name = name
dispatch DoAction (|rpghero|self, |string| Reason)
jump
"$.Name jumped because $Reason"
if .OnGround
.YSpeed = (.YSpeed max 0) + 2
run
"$.Name ran because $Reason"
.GroundSpeed = .GroundSpeed min 5
duck
"$.Name ducked because $Reason"
.IsDucking = true