aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs/syntax.moon
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2020-01-10 16:30:34 +0800
committerLi Jin <dragon-fly@qq.com>2020-01-10 16:30:34 +0800
commit52a6536103f46c26a3ba9b149b0fe7b40d524d8c (patch)
tree67e4759f8e1ea922079d0e162d84ecba5e558261 /spec/inputs/syntax.moon
parent975167856ed0b11c2ede03c6eb750ca4e4a6a7fc (diff)
downloadyuescript-52a6536103f46c26a3ba9b149b0fe7b40d524d8c.tar.gz
yuescript-52a6536103f46c26a3ba9b149b0fe7b40d524d8c.tar.bz2
yuescript-52a6536103f46c26a3ba9b149b0fe7b40d524d8c.zip
update.
Diffstat (limited to 'spec/inputs/syntax.moon')
-rw-r--r--spec/inputs/syntax.moon272
1 files changed, 272 insertions, 0 deletions
diff --git a/spec/inputs/syntax.moon b/spec/inputs/syntax.moon
new file mode 100644
index 0000000..854f629
--- /dev/null
+++ b/spec/inputs/syntax.moon
@@ -0,0 +1,272 @@
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
69something[[hey]] * 2
70something[======[hey]======] * 2
71
72
73something'else', 2
74something"else", 2
75something[[else]], 2
76
77something 'else', 2
78something "else", 2
79something [[else]], 2
80
81here(we)"go"[12123]
82
83-- this runs
84something =
85 test: 12323
86 what: -> print "hello world"
87
88print something.test
89
90frick = hello: "world"
91
92argon =
93 num: 100
94 world: (self) ->
95 print self.num
96 return {
97 something: -> print "hi from something"
98 }
99 somethin: (self, str) ->
100 print "string is", str
101 return world: (a,b) -> print "sum", a + b
102
103something.what()
104argon\world().something()
105
106argon\somethin"200".world(1,2)
107
108x = -434
109
110x = -hello world one two
111
112hi = -"herfef"
113
114x = -[x for x in x]
115
116print "hello" if cool
117print "hello" unless cool
118print "hello" unless 1212 and 3434 -- hello
119print "hello" for i=1,10
120
121print "nutjob"
122
123if hello then 343
124
125print "what" if cool else whack
126
127arg = {...}
128
129x = (...) ->
130 dump {...}
131
132
133x = not true
134
135y = not(5+5)
136
137
138y = #"hello"
139
140x = #{#{},#{1},#{1,2}}
141
142hello, world
143
144something\hello(what) a,b
145something\hello what
146something.hello\world a,b
147something.hello\world(1,2,3) a,b
148
149
150x = 1232
151x += 10 + 3
152j -= "hello"
153y *= 2
154y /= 100
155m %= 2
156hello ..= "world"
157
158@@something += 10
159@something += 10
160
161a["hello"] += 10
162a["hello#{tostring ff}"] += 10
163a[four].x += 10
164
165x = 0
166(if ntype(v) == "fndef" then x += 1) for v in *values
167
168
169hello =
170 something: world
171 if: "hello"
172 else: 3434
173 function: "okay"
174 good: 230203
175
176
177div class: "cool"
178
1795 + what wack
180what whack + 5
181
1825 - what wack
183what whack - 5
184
185x = hello - world - something
186
187((something = with what
188 \cool 100) ->
189 print something)!
190
191if something
192 03589
193
194-- okay what about this
195
196else
197 3434
198
199
200if something
201 yeah
202
203
204elseif "ymmm"
205
206 print "cool"
207
208else
209
210 okay
211
212
213-- test names containing keywords
214x = notsomething
215y = ifsomething
216z = x and b
217z = x andb
218
219
220-- undelimited tables
221
222while 10 > something
223 something: "world"
224 print "yeah"
225
226x =
227 okay: sure
228
229yeah
230 okay: man
231 sure: sir
232
233hello "no comma"
234 yeah: dada
235 another: world
236
237hello "comma",
238 something: hello_world
239 frick: you
240
241-- creates two tables
242another hello, one,
243 two, three, four, yeah: man
244 okay: yeah
245
246--
247a += 3 - 5
248a *= 3 + 5
249a *= 3
250a >>= 3
251a <<= 3
252a /= func "cool"
253
254---
255
256x.then = "hello"
257x.while.true = "hello"
258
259--
260
261x or= "hello"
262x and= "hello"
263
264--
265
266z = a-b
267z = a -b
268z = a - b
269z = a- b
270
271
272-- cooool