diff options
| author | Li Jin <dragon-fly@qq.com> | 2025-06-04 11:38:34 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2025-06-04 11:38:34 +0800 |
| commit | 548ab1d9ff5b831050f14f1355a3314a41163ad6 (patch) | |
| tree | d84b6b64b4e547070c7c43db53821b83b819ab8e /spec/outputs/switch.lua | |
| parent | 98be64dd52df92f7fdd40bae225c279db1676cab (diff) | |
| download | yuescript-548ab1d9ff5b831050f14f1355a3314a41163ad6.tar.gz yuescript-548ab1d9ff5b831050f14f1355a3314a41163ad6.tar.bz2 yuescript-548ab1d9ff5b831050f14f1355a3314a41163ad6.zip | |
Added new syntax.
- Slice Expression.
- Reversed Indexing,.
- Range Destructuring.
- Table Range Matching.
Diffstat (limited to 'spec/outputs/switch.lua')
| -rw-r--r-- | spec/outputs/switch.lua | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/outputs/switch.lua b/spec/outputs/switch.lua index 204b816..7a11bac 100644 --- a/spec/outputs/switch.lua +++ b/spec/outputs/switch.lua | |||
| @@ -727,4 +727,54 @@ do | |||
| 727 | print("not matched") | 727 | print("not matched") |
| 728 | end | 728 | end |
| 729 | end | 729 | end |
| 730 | do | ||
| 731 | local clientData = { | ||
| 732 | "Meta", | ||
| 733 | "CUST_1001", | ||
| 734 | "CHK123" | ||
| 735 | } | ||
| 736 | local _type_0 = type(clientData) | ||
| 737 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
| 738 | if _tab_0 then | ||
| 739 | local metadata | ||
| 740 | do | ||
| 741 | local _accum_0 = { } | ||
| 742 | local _len_0 = 1 | ||
| 743 | local _max_0 = -3 | ||
| 744 | for _index_0 = 1, _max_0 < 0 and #clientData + _max_0 + 1 or _max_0 do | ||
| 745 | local _item_0 = clientData[_index_0] | ||
| 746 | _accum_0[_len_0] = _item_0 | ||
| 747 | _len_0 = _len_0 + 1 | ||
| 748 | end | ||
| 749 | metadata = _accum_0 | ||
| 750 | end | ||
| 751 | local customerId = clientData[#clientData - 1] | ||
| 752 | local checksum = clientData[#clientData] | ||
| 753 | if customerId ~= nil and checksum ~= nil then | ||
| 754 | print(metadata) | ||
| 755 | print(customerId) | ||
| 756 | print(checksum) | ||
| 757 | end | ||
| 758 | end | ||
| 759 | end | ||
| 760 | do | ||
| 761 | local handlePath | ||
| 762 | handlePath = function(segments) | ||
| 763 | local _type_0 = type(segments) | ||
| 764 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
| 765 | if _tab_0 then | ||
| 766 | local resource = segments[#segments - 1] | ||
| 767 | local action = segments[#segments] | ||
| 768 | if resource ~= nil and action ~= nil then | ||
| 769 | print("Resource:", resource) | ||
| 770 | return print("Action:", action) | ||
| 771 | end | ||
| 772 | end | ||
| 773 | end | ||
| 774 | handlePath({ | ||
| 775 | "admin", | ||
| 776 | "logs", | ||
| 777 | "view" | ||
| 778 | }) | ||
| 779 | end | ||
| 730 | return nil | 780 | return nil |
