diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-01-19 17:11:31 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-01-19 17:11:31 +0800 |
| commit | ccfe66f87663e10603e453f02894bb82dd23c93b (patch) | |
| tree | 78f90066a182978bd74218440d13bd3a4dd1d269 /spec/outputs/syntax.lua | |
| parent | 8a01e9c4ec201ad7079f6863c9236851d162b864 (diff) | |
| download | yuescript-ccfe66f87663e10603e453f02894bb82dd23c93b.tar.gz yuescript-ccfe66f87663e10603e453f02894bb82dd23c93b.tar.bz2 yuescript-ccfe66f87663e10603e453f02894bb82dd23c93b.zip | |
Made `;` work as statements separator.
Diffstat (limited to 'spec/outputs/syntax.lua')
| -rw-r--r-- | spec/outputs/syntax.lua | 74 |
1 files changed, 72 insertions, 2 deletions
diff --git a/spec/outputs/syntax.lua b/spec/outputs/syntax.lua index 2df3473..d975ef7 100644 --- a/spec/outputs/syntax.lua +++ b/spec/outputs/syntax.lua | |||
| @@ -5,9 +5,9 @@ func(arg1, arg2, another, arg3) | |||
| 5 | local we | 5 | local we |
| 6 | here, we = function() end, yeah | 6 | here, we = function() end, yeah |
| 7 | local the, different | 7 | local the, different |
| 8 | the, different = function() | 8 | the, different = (function() |
| 9 | return approach | 9 | return approach |
| 10 | end, yeah | 10 | end), yeah |
| 11 | dad() | 11 | dad() |
| 12 | dad(lord) | 12 | dad(lord) |
| 13 | hello(one, two)(); | 13 | hello(one, two)(); |
| @@ -441,4 +441,74 @@ do | |||
| 441 | end | 441 | end |
| 442 | end)()) | 442 | end)()) |
| 443 | end | 443 | end |
| 444 | do | ||
| 445 | a = 1 | ||
| 446 | local b = 2 | ||
| 447 | local c = a + b | ||
| 448 | print(a) | ||
| 449 | print(b) | ||
| 450 | print(c) | ||
| 451 | f = function() | ||
| 452 | a = 1 | ||
| 453 | b = 2 | ||
| 454 | return a + b | ||
| 455 | end | ||
| 456 | a = 1 | ||
| 457 | b = 2 | ||
| 458 | local success, result = pcall(function() | ||
| 459 | return func() | ||
| 460 | end) | ||
| 461 | if success then | ||
| 462 | print(result) | ||
| 463 | end | ||
| 464 | local value = "foo" | ||
| 465 | print(value) | ||
| 466 | value = value .. "bar" | ||
| 467 | print(value) | ||
| 468 | do | ||
| 469 | if ok then | ||
| 470 | print("ok!") | ||
| 471 | end | ||
| 472 | return 42 | ||
| 473 | end | ||
| 474 | for i = 1, 3 do | ||
| 475 | print(i) | ||
| 476 | goto _continue_0 | ||
| 477 | ::_continue_0:: | ||
| 478 | end | ||
| 479 | local n = 0 | ||
| 480 | while n < 2 do | ||
| 481 | print("n=", n) | ||
| 482 | n = n + 1 | ||
| 483 | end | ||
| 484 | local obj = { } | ||
| 485 | obj:set(10) | ||
| 486 | obj:get() | ||
| 487 | print("done") | ||
| 488 | do | ||
| 489 | local _with_0 = tbl | ||
| 490 | _with_0:push(1) | ||
| 491 | print("push") | ||
| 492 | end | ||
| 493 | a = 5 | ||
| 494 | if a > 3 then | ||
| 495 | print("big") | ||
| 496 | b = a * 2 | ||
| 497 | print(b) | ||
| 498 | else | ||
| 499 | print("small") | ||
| 500 | b = a | ||
| 501 | end | ||
| 502 | xpcall(function() | ||
| 503 | x = 1 | ||
| 504 | y = 2 | ||
| 505 | return print(x + y) | ||
| 506 | end, function(err) | ||
| 507 | return print("error:", err) | ||
| 508 | end) | ||
| 509 | local q = 1 | ||
| 510 | local w = 2 | ||
| 511 | local e = 3 | ||
| 512 | print(q, w, e) | ||
| 513 | end | ||
| 444 | return nil | 514 | return nil |
