From a0d860c9bc4b994854149db58333bc0e04c315c6 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Sun, 12 Jan 2020 21:44:55 +0800 Subject: update readme. --- README.md | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1d843b2..ecfca3a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,67 @@ -# MoonParser -Try writing a parser for Moonscript language in C++. +# MoonPlus + +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. + +## Features + +* No other dependencies needed except modified **parserlib** library from Achilleas Margaritis with some performance enhancement. **lpeg** library is no longer needed. +* Written in C++17. +* Support full Moonscript language features, generate the same Lua codes with original compiler. +* Reserve line numbers from source Moonscript codes in compiled Lua codes to help with debugging. + +## Minor Changes + +* Can do slash call with Lua keyword. Generate codes from: +```Moonscript +c.repeat.if\then("xyz")\else res +``` +  to: +```Moonscript +local _call_3 = c["repeat"]["if"] +local _call_4 = _call_3["then"](_call_3, "xyz") +_call_4["else"](_call_4, res) +``` + +* Add a compiler flag `reuseVariable` which can help generate reduced Lua codes. For example, when set `reuseVariable` to `true`. Will generate codes from: +```Moonscript +with leaf + .world 1,2,3 + +with leaf + g = .what.is.this + print g + +for x in *something + print x +``` +  to: +```lua +leaf.world(1, 2, 3) +do + local g = leaf.what.is.this + print(g) +end +for _index_0 = 1, #something do + local x = something[_index_0] + print(x) +end +``` +  instead of: +```lua +do + local _with_0 = leaf + _with_0.world(1, 2, 3) +end +do + local _with_0 = leaf + local g = _with_0.what.is.this +end +local _list_0 = something +for _index_0 = 1, #_list_0 do + local x = _list_0[_index_0] + print(x) +end +``` + +## License +MIT \ No newline at end of file -- cgit v1.2.3-55-g6feb