blob: c0f521614818064b2afe41e7a0f10610b8af2aa1 (
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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
#
# Currently this is just a dummy/placeholder file.
#
# Copyright © 2025 Samuel Lidén Borell <samuel@kodafritt.se>
#
# SPDX-License-Identifier: EUPL-1.2+
#
# Problems:
#
# - Want to be able to have functions in the main file also,
# so it has to be a class.
# - Should it be possible to pass around the Main object?
# - Should it be possible to support event-driven flows?
# e.g. for GUI programs, or for phone apps (that can be stopped/
# started by decisions by the OS), or for services (also start/stop),
# or for socket-activated stuff (could allow multiple activations
# per instance/process), or FastCGI, etc...
#
# Should the main file be:
# 1. a special case
# 2. an external extension of an abstract class
# 3. a standard class that has a `main` method that takes some
# parameter with the main class?
# 4. a standard class that has a `start` method that takes the
# main class (and e.g. stores it in an instance variable),
# plus "event" methods? or the possibility to register events?
func testfunc
String s
SomeType st
returns
SomeResult res
code
int x
unsigned y
wrapping z
int w
long l
var unsigned long vul
signed byte sgb
aliased SomeType st_aliased
return true and false
return true or false
return (true and false) or true
return 123 == 999 or 123 == 123
return not (true or (not false))
f x (g y z) w
# This is not allowed, since it would be ambiguous
#g x - y
# It should be written with parentheses
g x (-y)
g (x - y) y
while false
while false
break
end
break
loopempty
return false
loopend
return false
end
for Thing t in 123 # FIXME should be an array, iterator or iterable
return 456
end
Thing t1
Thing t2 = true
if false
return true
elif true
return false
else
return true
end
Int64 lowest_int = -0x8000_0000_0000_0000
UInt64 max_uint = 18446744073709551615
String empty1 = ""
String s1 = "test"
String empty2 = ""
String escapetest = "test\\ escapes «f"
String longstring = "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong"
switch max_uint
end
switch max_uint
case 1
return true
case 2
return false
# TODO multi-valued cases
# this is tricky to do safely, because `case 1` immediately followed by
# `case 2` can happen if all statements in the block of `case 1` have
# been commented out.
# options:
# 1. special handling if multiple cases appear on consecutive lines.
# 2. multiple values separated by spaces
# 3. multiple values in array literals? (this would make it impossible
# to add support for switching on arrays)
end
switch max_uint
default
return true
end
switch max_uint
case 1
return true
default
return false
end
assert -333 < 222
assert 1+2 <> 3+4 and 5*6 == (711*511)-511
return -321
return 11 - 0x22 + 33 + 4_4 - (0b101 - (55 - 66))
section sec1
return true
if true
return false
end
return true
section done
return false
return true
section fail
return false
end
func other
A a1
A a2
B b
returns
A x
B y
end
func noargs
end
func f
int arg1
int arg2
int arg3
code
end
func g
int x
int y
returns
int ret
code
return x + (2*y)
end
|