diff options
| author | Li Jin <dragon-fly@qq.com> | 2020-01-12 21:44:55 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2020-01-12 21:44:55 +0800 |
| commit | a0d860c9bc4b994854149db58333bc0e04c315c6 (patch) | |
| tree | ab75148c515d20be81ba4f08c562c1f240e2def7 | |
| parent | d35732a2f6883bd978c01dd05c37ab51f3a9bdba (diff) | |
| download | yuescript-a0d860c9bc4b994854149db58333bc0e04c315c6.tar.gz yuescript-a0d860c9bc4b994854149db58333bc0e04c315c6.tar.bz2 yuescript-a0d860c9bc4b994854149db58333bc0e04c315c6.zip | |
update readme.
| -rw-r--r-- | README.md | 69 |
1 files changed, 67 insertions, 2 deletions
| @@ -1,2 +1,67 @@ | |||
| 1 | # MoonParser | 1 | # MoonPlus |
| 2 | Try writing a parser for Moonscript language in C++. | 2 | |
| 3 | MoonPlus is a compiler for Moonscript language 0.5.0 written in C++ which could be 2~4 times faster than the original Moonscript compiler written in Moonscript. | ||
| 4 | |||
| 5 | ## Features | ||
| 6 | |||
| 7 | * No other dependencies needed except modified **parserlib** library from Achilleas Margaritis with some performance enhancement. **lpeg** library is no longer needed. | ||
| 8 | * Written in C++17. | ||
| 9 | * Support full Moonscript language features, generate the same Lua codes with original compiler. | ||
| 10 | * Reserve line numbers from source Moonscript codes in compiled Lua codes to help with debugging. | ||
| 11 | |||
| 12 | ## Minor Changes | ||
| 13 | |||
| 14 | * Can do slash call with Lua keyword. Generate codes from: | ||
| 15 | ```Moonscript | ||
| 16 | c.repeat.if\then("xyz")\else res | ||
| 17 | ``` | ||
| 18 |   to: | ||
| 19 | ```Moonscript | ||
| 20 | local _call_3 = c["repeat"]["if"] | ||
| 21 | local _call_4 = _call_3["then"](_call_3, "xyz") | ||
| 22 | _call_4["else"](_call_4, res) | ||
| 23 | ``` | ||
| 24 | |||
| 25 | * Add a compiler flag `reuseVariable` which can help generate reduced Lua codes. For example, when set `reuseVariable` to `true`. Will generate codes from: | ||
| 26 | ```Moonscript | ||
| 27 | with leaf | ||
| 28 | .world 1,2,3 | ||
| 29 | |||
| 30 | with leaf | ||
| 31 | g = .what.is.this | ||
| 32 | print g | ||
| 33 | |||
| 34 | for x in *something | ||
| 35 | print x | ||
| 36 | ``` | ||
| 37 |   to: | ||
| 38 | ```lua | ||
| 39 | leaf.world(1, 2, 3) | ||
| 40 | do | ||
| 41 | local g = leaf.what.is.this | ||
| 42 | print(g) | ||
| 43 | end | ||
| 44 | for _index_0 = 1, #something do | ||
| 45 | local x = something[_index_0] | ||
| 46 | print(x) | ||
| 47 | end | ||
| 48 | ``` | ||
| 49 |   instead of: | ||
| 50 | ```lua | ||
| 51 | do | ||
| 52 | local _with_0 = leaf | ||
| 53 | _with_0.world(1, 2, 3) | ||
| 54 | end | ||
| 55 | do | ||
| 56 | local _with_0 = leaf | ||
| 57 | local g = _with_0.what.is.this | ||
| 58 | end | ||
| 59 | local _list_0 = something | ||
| 60 | for _index_0 = 1, #_list_0 do | ||
| 61 | local x = _list_0[_index_0] | ||
| 62 | print(x) | ||
| 63 | end | ||
| 64 | ``` | ||
| 65 | |||
| 66 | ## License | ||
| 67 | MIT \ No newline at end of file | ||
