aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2020-01-25 17:48:03 +0800
committerLi Jin <dragon-fly@qq.com>2020-01-25 17:48:03 +0800
commited317e62eb1cf98fde4461fc90c6cb1045ebc7e8 (patch)
tree427e365939da39f31dbfa755675fb60bb141583d /README.md
parent4827d200604a086e2ad94edb4257c3abc7a3c4fc (diff)
downloadyuescript-ed317e62eb1cf98fde4461fc90c6cb1045ebc7e8.tar.gz
yuescript-ed317e62eb1cf98fde4461fc90c6cb1045ebc7e8.tar.bz2
yuescript-ed317e62eb1cf98fde4461fc90c6cb1045ebc7e8.zip
fix Moonscript issue 375.
Diffstat (limited to 'README.md')
-rw-r--r--README.md66
1 files changed, 61 insertions, 5 deletions
diff --git a/README.md b/README.md
index 2385a11..7421829 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
1# MoonPlus 1# MoonPlus
2 2
3![CI](https://github.com/pigpigyyy/MoonPlus/workflows/build-test/badge.svg) 3![CI](https://github.com/pigpigyyy/MoonPlus/workflows/build-test/badge.svg)
4MoonPlus is a compiler adopting features from Moonscript language 0.5.0 and could be 2~4 times faster than the original Moonscript compiler. 4MoonPlus is a compiler with features from Moonscript language 0.5.0 and could be 2~4 times faster than the original Moonscript compiler.
5 5
6## Features 6## Features
7 7
@@ -10,19 +10,75 @@ MoonPlus is a compiler adopting features from Moonscript language 0.5.0 and coul
10* Support full Moonscript language features, generate the same Lua codes with original compiler. 10* Support full Moonscript language features, generate the same Lua codes with original compiler.
11* Reserve line numbers from source Moonscript codes in compiled Lua codes to help with debugging. 11* Reserve line numbers from source Moonscript codes in compiled Lua codes to help with debugging.
12 12
13## Minor Changes 13## Changes
14 14
15* Can do slash call with Lua keyword. Generate codes from: 15* Add existential operator support. Generate codes from:
16```Moonscript 16```Moonscript
17c.repeat.if\then("xyz")\else res 17func?!
18
19x = tab?.value
20
21print abc?["hello world"]?.xyz
22
23if print and x?
24 print x
18``` 25```
19&emsp;&emsp;to: 26&emsp;&emsp;to:
27```Lua
28if func ~= nil then
29 func()
30end
31local x
32if tab ~= nil then
33 x = tab.value
34end
35print((function()
36 if abc ~= nil then
37 local _obj_0 = abc["hello world"]
38 if _obj_0 ~= nil then
39 return _obj_0.xyz
40 end
41 return nil
42 end
43 return nil
44end)())
45if print and (x ~= nil) then
46 print(x)
47end
48```
49
50* Can do slash call with Lua keywords. Generate codes from:
20```Moonscript 51```Moonscript
52c.repeat.if\then("xyz")\else res
53```
54&emsp;&emsp;to:
55```Lua
21local _call_3 = c["repeat"]["if"] 56local _call_3 = c["repeat"]["if"]
22local _call_4 = _call_3["then"](_call_3, "xyz") 57local _call_4 = _call_3["then"](_call_3, "xyz")
23_call_4["else"](_call_4, res) 58_call_4["else"](_call_4, res)
24``` 59```
25 60
61* Add more usage for `import` keyword. Will compile codes from:
62```Moonscript
63import 'module'
64import "module.part"
65import "d-a-s-h-e-s"
66import "player" as Player
67import "lpeg" as {:C, :Ct, :Cmt}
68```
69&emsp;&emsp;to:
70```Lua
71local module = require('module')
72local part = require("module.part")
73local d_a_s_h_e_s = require("d-a-s-h-e-s")
74local Player = require("player")
75local C, Ct, Cmt
76do
77 local _obj_0 = require("lpeg")
78 C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt
79end
80```
81
26* Add feature of `reusing variable` which helps generate reduced Lua codes. For example, MoonPlus will generate codes from: 82* Add feature of `reusing variable` which helps generate reduced Lua codes. For example, MoonPlus will generate codes from:
27```Moonscript 83```Moonscript
28with leaf 84with leaf
@@ -36,7 +92,7 @@ for x in *something
36 print x 92 print x
37``` 93```
38&emsp;&emsp;to: 94&emsp;&emsp;to:
39```lua 95```Lua
40leaf.world(1, 2, 3) 96leaf.world(1, 2, 3)
41do 97do
42 local g = leaf.what.is.this 98 local g = leaf.what.is.this