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