aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs/syntax.mp
diff options
context:
space:
mode:
Diffstat (limited to 'spec/inputs/syntax.mp')
-rw-r--r--spec/inputs/syntax.mp396
1 files changed, 396 insertions, 0 deletions
diff --git a/spec/inputs/syntax.mp b/spec/inputs/syntax.mp
new file mode 100644
index 0000000..1bb962f
--- /dev/null
+++ b/spec/inputs/syntax.mp
@@ -0,0 +1,396 @@
1#!/this/is/ignored
2
3a = 1 + 2* 3 / 6
4
5a, bunch, go, here = another, world
6
7func arg1, arg2, another, arg3
8
9here, we = () ->, yeah
10the, different = () -> approach; yeah
11
12dad()
13dad(lord)
14hello(one,two)()
15(5 + 5)(world)
16
17fun(a)(b)
18
19fun(a) b
20
21fun(a) b, bad hello
22
23hello world what are you doing here
24
25
26what(the)[3243] world, yeck heck
27
28hairy[hands][are](gross) okay okay[world]
29
30_ = (get[something] + 5)[years]
31
32i,x = 200, 300
33
34yeah = (1 + 5) * 3
35yeah = ((1+5)*3)/2
36yeah = ((1+5)*3)/2 + i % 100
37
38whoa = (1+2) * (3+4) * (4+5)
39
40_ = ->
41 if something
42 return 1,2,4
43
44 print "hello"
45
46_ = ->
47 if hello
48 "heloo", "world"
49 else
50 no, way
51
52
53_ = -> 1,2,34
54
55return 5 + () -> 4 + 2
56
57return 5 + (() -> 4) + 2
58
59print 5 + () ->
60 _ = 34
61 good nads
62
63
64something 'else', "ya"
65
66something'else'
67something"else"
68
69_ = something[[hey]] * 2
70_ = something[======[hey]======] * 2
71_ = something[ [======[hey]======] ] * 2
72
73
74_ = something'else', 2
75_ = something"else", 2
76_ = something[[else]], 2
77_ = something[ [[else]] ], 2
78
79something 'else', 2
80something "else", 2
81something [[else]], 2
82
83_ = here(we)"go"[12123]
84
85-- this runs
86something =
87 test: 12323
88 what: -> print "hello world"
89
90print something.test
91
92frick = hello: "world"
93
94argon =
95 num: 100
96 world: (self) ->
97 print self.num
98 return {
99 something: -> print "hi from something"
100 }
101 somethin: (self, str) ->
102 print "string is", str
103 return world: (a,b) -> print "sum", a + b
104
105something.what()
106argon\world().something()
107
108argon\somethin"200".world(1,2)
109
110x = -434
111
112x = -hello world one two
113
114hi = -"herfef"
115
116x = -[x for x in x]
117
118print "hello" if cool
119print "hello" unless cool
120print "hello" unless 1212 and 3434 -- hello
121print "hello" for i=1,10
122
123print "nutjob"
124
125if hello then _ = 343
126
127print "what" if cool
128
129((...)-> arg = {...})!
130
131x = (...) ->
132 dump {...}
133
134
135x = not true
136
137y = not(5+5)
138
139
140y = #"hello"
141
142x = #{#{},#{1},#{1,2}}
143
144_ = hello, world
145
146something\hello(what) a,b
147something\hello what
148something.hello\world a,b
149something.hello\world(1,2,3) a,b
150
151
152x = 1232
153x += 10 + 3
154j -= "hello"
155y *= 2
156y /= 100
157m %= 2
158hello ..= "world"
159
160@@something += 10
161@something += 10
162
163a["hello"] += 10
164a["hello#{tostring ff}"] += 10
165a[four].x += 10
166
167x = 0
168_ = (if ntype(v) == "fndef" then x += 1) for v in *values
169
170
171hello =
172 something: world
173 if: "hello"
174 else: 3434
175 function: "okay"
176 good: 230203
177
178
179div class: "cool"
180
181_ = 5 + what wack
182what whack + 5
183
184_ = 5 - what wack
185what whack - 5
186
187x = hello - world - something
188
189((something = with what
190 \cool 100) ->
191 print something)!
192
193if something
194 _ = 03589
195
196-- okay what about this
197
198else
199 _ = 3434
200
201
202if something
203 _ = yeah
204
205
206elseif "ymmm"
207
208 print "cool"
209
210else
211
212 _ = okay
213
214
215-- test names containing keywords
216x = notsomething
217y = ifsomething
218z = x and b
219z = x andb
220
221
222-- undelimited tables
223
224while 10 > something
225 something: "world"
226 print "yeah"
227
228x =
229 okay: sure
230
231yeah
232 okay: man
233 sure: sir
234
235hello "no comma"
236 yeah: dada
237 another: world
238
239hello "comma",
240 something: hello_world
241 frick: you
242
243-- creates one table
244another hello, one,
245 two, three, four, yeah: man
246 okay: yeah
247 fine: alright
248
249another hello, one,
250 two, three, four,
251 yeah: man, okay: yeah
252 * fine: alright,
253 okay: 1
254 * fine: alright,
255 okay: 2
256
257another hello, one, two, three, four,
258 yeah: man
259 okay: yeah
260
261another hello, one, two, three, four, yeah: man
262 okay: yeah
263
264ajax url,
265 (data) ->
266 process data,
267 (error) ->
268 print error
269
270--
271a += 3 - 5
272a *= 3 + 5
273a *= 3
274a >>= 3
275a <<= 3
276a /= func "cool"
277
278---
279
280x.then = "hello"
281x.while.true = "hello"
282
283--
284
285x or= "hello"
286x and= "hello"
287
288--
289
290z = a-b
291z = a -b
292z = a - b
293z = a- b
294
295
296-- cooool
297
298str = --[[
299This is a multi line comment.
300It's OK.
301]] strA \ -- comment 1
302 .. strB \ -- comment 2
303 .. strC
304
305func --[[port]] 3000, --[[ip]] "192.168.1.1"
306
307f = ->
308 a,b, \
309 c,d, \
310 e,f
311
312f = ->
313 a,b \
314 ,c,d \
315 ,e,f
316
317with obj
318 invoke(
319 --[[arg1]] \func!,
320 --[[arg2]] 123,
321 --[[arg3]] "abc"
322 )
323
324invokeA(
325 invokeB(
326 invokeC 123
327 )
328)
329
330123
331 |> invokeC
332 |> invokeB
333 |> invokeA
334
335v = {
336 a -1
337 a(
338-1)
339 a \
340- 1
341 a-1
342 a - 1
343 a -
3441
345 a-
3461
347 a - --[[123]]1
348
349 a ~1
350 a(
351~1)
352 a \
353~ 1
354 a~1
355 a ~ 1
356 a ~
3571
358 a~
3591
360 a ~ --[[123]]1
361}
362
363do
364 a = 1 \
365 + 2 \
366 * 3 /
367 4
368
369 _1 = f1 -1 \
370 + 2 \
371 + 3
372
373 _2 = f1 - 1 \
374 + 2 \
375 + 3
376
377 f2 = (x)-> print x \
378 +1
379
380 a = f2!
381 -1 |> f2
382
383 a = f2! \
384 - 1 |> f2
385
386 _1 \
387 ,_2 \
388 ,_3 \
389 ,_4 = 1 \
390 ,f 2 \
391 ,3 \
392 ,f 4, \
393 4
394
395nil
396