diff options
author | Li Jin <dragon-fly@qq.com> | 2020-10-09 15:58:35 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2020-10-09 15:58:35 +0800 |
commit | 721946718de7bc4e90c94a7f44bf8e7d519a75e5 (patch) | |
tree | 65ab681a7d486293aba7afbfa2f59718d8506598 | |
parent | 97bbe98289fb74c7cf2d9793b80a1a27b4146045 (diff) | |
download | yuescript-721946718de7bc4e90c94a7f44bf8e7d519a75e5.tar.gz yuescript-721946718de7bc4e90c94a7f44bf8e7d519a75e5.tar.bz2 yuescript-721946718de7bc4e90c94a7f44bf8e7d519a75e5.zip |
update readme.
-rw-r--r-- | CHANGELOG.md | 94 | ||||
-rw-r--r-- | README.md | 19 |
2 files changed, 98 insertions, 15 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 698921f..85b5d06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md | |||
@@ -4,17 +4,89 @@ The implementation for original Moonscript language 0.5.0 can be found in the `0 | |||
4 | 4 | ||
5 | 5 | ||
6 | 6 | ||
7 | ## v0.4.7 | 7 | ## v0.4.16 |
8 | 8 | ||
9 | ### Fixed Issues | 9 | ### Fixed Issues |
10 | 10 | ||
11 | * Change MoonPlus file extension to '.mp' because some of the Moonscript syntax are no longer supported and some codes written in MoonPlus syntax won't be accepted by Moonscript compiler. | ||
12 | |||
11 | * Remove support for escape new line symbol, binary operator expressions can now be written multiline without escape new line symbol. | 13 | * Remove support for escape new line symbol, binary operator expressions can now be written multiline without escape new line symbol. |
14 | |||
12 | * Fix an issue when extending class without name. | 15 | * Fix an issue when extending class without name. |
16 | |||
13 | * Fix an issue when using return with export statement. | 17 | * Fix an issue when using return with export statement. |
18 | |||
14 | * Fix issues when declaring table key with Lua multiline string and indexing expressions with Lua multiline string. | 19 | * Fix issues when declaring table key with Lua multiline string and indexing expressions with Lua multiline string. |
15 | 20 | ||
21 | * Make simple table and table block appear in the end of function arguments merged into one table. | ||
22 | |||
23 | ```Moonscript | ||
24 | -- function arguments end with simple table followed by table block | ||
25 | another hello, one, | ||
26 | two, three, four, yeah: man | ||
27 | okay: yeah | ||
28 | fine: alright | ||
29 | ``` | ||
30 | |||
31 | ```Lua | ||
32 | -- compiled in original Moonscript compiler | ||
33 | -- get two tables as arguments | ||
34 | another(hello, one, two, three, four, { | ||
35 | yeah = man | ||
36 | }, { | ||
37 | okay = yeah, | ||
38 | fine = alright | ||
39 | }) | ||
40 | -- compiled in fixed MoonPlus compiler | ||
41 | -- get one table as argument | ||
42 | another(hello, one, two, three, four, { | ||
43 | yeah = man, | ||
44 | okay = yeah, | ||
45 | fine = alright | ||
46 | }) | ||
47 | ``` | ||
48 | |||
49 | |||
50 | |||
16 | ### Added Features | 51 | ### Added Features |
17 | 52 | ||
53 | * Add implicit objects support for table block syntax. | ||
54 | |||
55 | ```Moonscript | ||
56 | inventory = | ||
57 | equipment: | ||
58 | * "sword" | ||
59 | * "shield" | ||
60 | items: | ||
61 | * name: "potion" | ||
62 | count: 10 | ||
63 | * name: "bread" | ||
64 | count: 3 | ||
65 | ``` | ||
66 | |||
67 | Compiles to: | ||
68 | |||
69 | ```Lua | ||
70 | local inventory = { | ||
71 | equipment = { | ||
72 | "sword", | ||
73 | "shield" | ||
74 | }, | ||
75 | items = { | ||
76 | { | ||
77 | name = "potion", | ||
78 | count = 10 | ||
79 | }, | ||
80 | { | ||
81 | name = "bread", | ||
82 | count = 3 | ||
83 | } | ||
84 | } | ||
85 | } | ||
86 | ``` | ||
87 | |||
88 | |||
89 | |||
18 | * Add support for local variable declared with attribute 'close' and 'const' for Lua 5.4. | 90 | * Add support for local variable declared with attribute 'close' and 'const' for Lua 5.4. |
19 | 91 | ||
20 | ```moonscript | 92 | ```moonscript |
@@ -84,7 +156,7 @@ The implementation for original Moonscript language 0.5.0 can be found in the `0 | |||
84 | 156 | ||
85 | * Add macro functions. | 157 | * Add macro functions. |
86 | ```Moonscript | 158 | ```Moonscript |
87 | -- file 'macro.moon' | 159 | -- file 'macro.mp' |
88 | export macro block config = (debugging = true)-> | 160 | export macro block config = (debugging = true)-> |
89 | global debugMode = debugging == "true" | 161 | global debugMode = debugging == "true" |
90 | "" | 162 | "" |
@@ -97,7 +169,7 @@ export macro expr assert = (cond)-> | |||
97 | 169 | ||
98 | $config! | 170 | $config! |
99 | 171 | ||
100 | -- file 'main.moon' | 172 | -- file 'main.mp' |
101 | import 'macro' as {:$config, :$assert, :$asserts} | 173 | import 'macro' as {:$config, :$assert, :$asserts} |
102 | 174 | ||
103 | macro expr and = (...)-> "#{ table.concat {...}, ' and ' }" | 175 | macro expr and = (...)-> "#{ table.concat {...}, ' and ' }" |
@@ -111,11 +183,11 @@ if $and f1!, f2!, f3! | |||
111 | ``` | 183 | ``` |
112 | Compiles to: | 184 | Compiles to: |
113 | ```Lua | 185 | ```Lua |
114 | -- file 'macro.moon' | 186 | -- file 'macro.mp' |
115 | local _module_0 = { } | 187 | local _module_0 = { } |
116 | return _module_0 | 188 | return _module_0 |
117 | 189 | ||
118 | -- file 'main.moon' | 190 | -- file 'main.mp' |
119 | assert(item ~= nil) | 191 | assert(item ~= nil) |
120 | local value = item | 192 | local value = item |
121 | if (f1() and f2() and f3()) then | 193 | if (f1() and f2() and f3()) then |
@@ -150,20 +222,20 @@ From original Moonscript compiler: | |||
150 | * Move old `export` statement functions to `global` statement to match the `local` statement. | 222 | * Move old `export` statement functions to `global` statement to match the `local` statement. |
151 | * Change `export` statement behavier to support module management. Moon codes with `export` statement can not explicit return values in root scope. And codes with `export default` can export only one value as the module content. Use cases: | 223 | * Change `export` statement behavier to support module management. Moon codes with `export` statement can not explicit return values in root scope. And codes with `export default` can export only one value as the module content. Use cases: |
152 | ```Moonscript | 224 | ```Moonscript |
153 | -- file 'Config.moon' | 225 | -- file 'Config.mp' |
154 | export default {flag:1, value:"x"} | 226 | export default {flag:1, value:"x"} |
155 | 227 | ||
156 | -- file 'Utils.moon' | 228 | -- file 'Utils.mp' |
157 | export map = (items, func)-> [func item for item in *items] | 229 | export map = (items, func)-> [func item for item in *items] |
158 | export filter = (items, func)-> [item for item in *items when func item] | 230 | export filter = (items, func)-> [item for item in *items when func item] |
159 | 231 | ||
160 | -- file 'main.moon' | 232 | -- file 'main.mp' |
161 | import 'Config' as {:flag, :value} | 233 | import 'Config' as {:flag, :value} |
162 | import 'Utils' as {:map, :filter} | 234 | import 'Utils' as {:map, :filter} |
163 | ``` | 235 | ``` |
164 | Compiles to: | 236 | Compiles to: |
165 | ```Lua | 237 | ```Lua |
166 | -- file 'Config.moon' | 238 | -- file 'Config.mp' |
167 | local _module_0 = nil | 239 | local _module_0 = nil |
168 | _module_0 = { | 240 | _module_0 = { |
169 | flag = 1, | 241 | flag = 1, |
@@ -171,7 +243,7 @@ _module_0 = { | |||
171 | } | 243 | } |
172 | return _module_0 | 244 | return _module_0 |
173 | 245 | ||
174 | -- file 'Utils.moon' | 246 | -- file 'Utils.mp' |
175 | local _module_0 = { } | 247 | local _module_0 = { } |
176 | local map | 248 | local map |
177 | map = function(items, func) | 249 | map = function(items, func) |
@@ -201,7 +273,7 @@ end | |||
201 | _module_0["filter"] = filter | 273 | _module_0["filter"] = filter |
202 | return _module_0 | 274 | return _module_0 |
203 | 275 | ||
204 | -- file 'main.moon' | 276 | -- file 'main.mp' |
205 | local flag, value | 277 | local flag, value |
206 | do | 278 | do |
207 | local _obj_0 = require('Config') | 279 | local _obj_0 = require('Config') |
@@ -43,7 +43,7 @@ So MoonPlus is a new code base for pushing the language to go forward and being | |||
43 |   Then require the module in Lua: | 43 |   Then require the module in Lua: |
44 | 44 | ||
45 | ```Lua | 45 | ```Lua |
46 | require("moonp")("main") -- require `main.moon` | 46 | require("moonp")("main") -- require `main.mp` |
47 | 47 | ||
48 | local moonp = require("moonp") | 48 | local moonp = require("moonp") |
49 | local codes, err, globals = moonp.to_lua([[ | 49 | local codes, err, globals = moonp.to_lua([[ |
@@ -59,7 +59,6 @@ f! | |||
59 | 59 | ||
60 | 60 | ||
61 | 61 | ||
62 | |||
63 | * **Binary Tool** | 62 | * **Binary Tool** |
64 | 63 | ||
65 |   Clone this repo, then build and install executable with: | 64 |   Clone this repo, then build and install executable with: |
@@ -91,14 +90,26 @@ Usage: moonp [options|files|directories] ... | |||
91 | in a single line to start/stop multi-line mode | 90 | in a single line to start/stop multi-line mode |
92 | ``` | 91 | ``` |
93 |   Use cases: | 92 |   Use cases: |
94 |   Recursively compile every moon file under current path: `moonp .` | 93 |   Recursively compile every moon+ file with extension `.md` under current path: `moonp .` |
95 |   Compile and save results to a target path: `moonp -t /target/path/ .` | 94 |   Compile and save results to a target path: `moonp -t /target/path/ .` |
96 |   Compile and reserve debug info: `moonp -l .` | 95 |   Compile and reserve debug info: `moonp -l .` |
97 |   Compile and generate minified codes: `moonp -m .` | 96 |   Compile and generate minified codes: `moonp -m .` |
98 |   Execute raw codes: `moonp -e 'print 123'` | 97 |   Execute raw codes: `moonp -e 'print 123'` |
99 |   Execute a moon file: `moonp -e main.moon` | 98 |   Execute a moon+ file: `moonp -e main.mp` |
99 | |||
100 | |||
101 | |||
102 | * **Docker Hub** | ||
103 | Try moonp in another easy way: https://hub.docker.com/r/moonplus/moonplus | ||
104 | |||
105 | |||
106 | |||
107 | ## Editor Support | ||
108 | |||
109 | * [Vim](https://github.com/pigpigyyy/MoonPlus-vim) | ||
100 | 110 | ||
101 | 111 | ||
102 | 112 | ||
103 | ## License | 113 | ## License |
114 | |||
104 | MIT | 115 | MIT |