diff options
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 85 |
1 files changed, 47 insertions, 38 deletions
| @@ -1,55 +1,58 @@ | |||
| 1 | # YueScript | 1 | # YueScript |
| 2 | 2 | ||
| 3 | <img src="doc/docs/.vitepress/public/image/yuescript.png" width="300" height="300" alt="logo"/> | 3 | <img src="doc/docs/.vitepress/public/image/yuescript.png" width="300" height="300" alt="YueScript logo"/> |
| 4 | 4 | ||
| 5 | [](https://ippclub.org) [](https://github.com/pigpigyyy/Yuescript/actions/workflows/ubuntu.yml) [](https://github.com/pigpigyyy/Yuescript/actions/workflows/windows.yml) [](https://github.com/pigpigyyy/Yuescript/actions/workflows/macos.yml) [](https://discord.gg/cRJ2VAm2NV) | 5 | [](https://ippclub.org) [](https://github.com/pigpigyyy/Yuescript/actions/workflows/ubuntu.yml) [](https://github.com/pigpigyyy/Yuescript/actions/workflows/windows.yml) [](https://github.com/pigpigyyy/Yuescript/actions/workflows/macos.yml) [](https://discord.gg/cRJ2VAm2NV) |
| 6 | 6 | ||
| 7 | YueScript is a MoonScript dialect. It is derived from [MoonScript language](https://github.com/leafo/moonscript) 0.5.0 and continuously adopting new features to be more up to date. | 7 | YueScript is a MoonScript dialect that compiles to Lua. It is derived from [MoonScript](https://github.com/leafo/moonscript) `0.5.0` and continues to adopt new features to stay up to date. |
| 8 | 8 | ||
| 9 | MoonScript is a language that compiles to Lua. Since original MoonScript has been used to write web framework [lapis](https://github.com/leafo/lapis) and run a few business web sites like [itch.io](https://itch.io) and [streak.club](https://streak.club) with some large code bases. The original language is getting too hard to adopt new features for those may break the stablility for existing applications. | 9 | ## Quick Links |
| 10 | 10 | ||
| 11 | So YueScript is a new code base for pushing the language to go forward and being a playground to try introducing new language syntax or programing paradigms to make MoonScript language more expressive and productive. | 11 | - Website: <https://yuescript.org> |
| 12 | - Documentation: <https://yuescript.org/doc> | ||
| 13 | - Changelog: [`CHANGELOG.md`](./CHANGELOG.md) | ||
| 14 | - Discord: <https://discord.gg/cRJ2VAm2NV> | ||
| 12 | 15 | ||
| 13 | Yue (月) is the name of moon in Chinese and it's pronounced as [jyɛ]. | 16 | ## Overview |
| 14 | 17 | ||
| 18 | MoonScript has been used to build real-world projects such as [Lapis](https://github.com/leafo/lapis), [itch.io](https://itch.io), and [streak.club](https://streak.club). As the original implementation became harder to evolve without risking compatibility, YueScript was created as a modernized code base for pushing the language forward. | ||
| 15 | 19 | ||
| 20 | YueScript is both a production-ready compiler and a playground for exploring new syntax and programming paradigms that make MoonScript-style development more expressive and productive. | ||
| 21 | |||
| 22 | Yue (月) is the Chinese word for moon and is pronounced [jyɛ]. | ||
| 16 | 23 | ||
| 17 | ## About Dora SSR | 24 | ## About Dora SSR |
| 18 | 25 | ||
| 19 | YueScript is being developed and maintained alongside the open-source game engine [Dora SSR](https://github.com/ippclub/Dora-SSR). It has been used to create engine tools, game demos and prototypes, validating its capabilities in real-world scenarios while enhancing the Dora SSR development experience. | 26 | YueScript is being developed and maintained alongside the open-source game engine [Dora SSR](https://github.com/ippclub/Dora-SSR). It has been used to create engine tools, game demos and prototypes, validating its capabilities in real-world scenarios while enhancing the Dora SSR development experience. |
| 20 | 27 | ||
| 21 | |||
| 22 | |||
| 23 | ## Features | 28 | ## Features |
| 24 | 29 | ||
| 25 | * Based on modified [parserlib](https://github.com/axilmar/parserlib) library from Achilleas Margaritis with some performance enhancement. **lpeg** library is no longer needed. | 30 | - Based on a modified [parserlib](https://github.com/axilmar/parserlib) with performance enhancements. `lpeg` is no longer required. |
| 26 | * Written in C++17. | 31 | - Written in C++17. |
| 27 | * Support most of the features from MoonScript language. Generate Lua codes in the same way like the original compiler. | 32 | - Supports most MoonScript features and generates Lua code in a style compatible with the original compiler. |
| 28 | * Reserve line numbers from source file in the compiled Lua codes to help debugging. | 33 | - Preserves source line numbers in generated Lua to improve debugging. |
| 29 | * More features like macro, existential operator, pipe operator, Javascript-like export syntax and etc. | 34 | - Adds features like macros, existential operator, pipe operator, JavaScript-like export syntax, and more. |
| 30 | * See other details in the [changelog](./CHANGELOG.md). Find document [here](http://yuescript.org). | 35 | - See [`CHANGELOG.md`](./CHANGELOG.md) for more details. |
| 31 | |||
| 32 | |||
| 33 | 36 | ||
| 34 | ## Installation & Usage | 37 | ## Installation |
| 35 | 38 | ||
| 36 | * **Lua Module** | 39 | ### Lua Module |
| 37 | 40 | ||
| 38 |   Build `yue.so` file with | 41 | Build `yue.so` with: |
| 39 | 42 | ||
| 40 | ```sh | 43 | ```sh |
| 41 | > make shared LUAI=/usr/local/include/lua LUAL=/usr/local/lib/lua | 44 | > make shared LUAI=/usr/local/include/lua LUAL=/usr/local/lib/lua |
| 42 | ``` | 45 | ``` |
| 43 | 46 | ||
| 44 |   Then get the binary file from path `bin/shared/yue.so`. | 47 | Then get the binary file from `bin/shared/yue.so`. |
| 45 | 48 | ||
| 46 |   Or you can install [luarocks](https://luarocks.org), a package manager for Lua modules. Then install it as a Lua module with | 49 | Or install via [LuaRocks](https://luarocks.org): |
| 47 | 50 | ||
| 48 | ```sh | 51 | ```sh |
| 49 | > luarocks install yuescript | 52 | > luarocks install yuescript |
| 50 | ``` | 53 | ``` |
| 51 | 54 | ||
| 52 |   Then require the YueScript module in Lua: | 55 | Then require the YueScript module in Lua: |
| 53 | 56 | ||
| 54 | ```lua | 57 | ```lua |
| 55 | require("yue")("main") -- require `main.yue` | 58 | require("yue")("main") -- require `main.yue` |
| @@ -65,26 +68,27 @@ f! | |||
| 65 | }) | 68 | }) |
| 66 | ``` | 69 | ``` |
| 67 | 70 | ||
| 71 | ### Binary Tool (CLI) | ||
| 68 | 72 | ||
| 73 | Clone this repo, then build and install executable with: | ||
| 69 | 74 | ||
| 70 | * **Binary Tool** | ||
| 71 | |||
| 72 |   Clone this repo, then build and install executable with: | ||
| 73 | ```sh | 75 | ```sh |
| 74 | > make install | 76 | > make install |
| 75 | ``` | 77 | ``` |
| 76 | 78 | ||
| 77 |   Build YueScript tool without macro feature: | 79 | Build YueScript tool without macro feature: |
| 80 | |||
| 78 | ```sh | 81 | ```sh |
| 79 | > make install NO_MACRO=true | 82 | > make install NO_MACRO=true |
| 80 | ``` | 83 | ``` |
| 81 | 84 | ||
| 82 |   Build YueScript tool without built-in Lua binary: | 85 | Build YueScript tool without built-in Lua binary: |
| 86 | |||
| 83 | ```sh | 87 | ```sh |
| 84 | > make install NO_LUA=true | 88 | > make install NO_LUA=true |
| 85 | ``` | 89 | ``` |
| 86 | 90 | ||
| 87 |   Use YueScript tool with: | 91 | Use YueScript tool with: |
| 88 | 92 | ||
| 89 | ```sh | 93 | ```sh |
| 90 | > yue -h | 94 | > yue -h |
| @@ -131,24 +135,29 @@ Options: | |||
| 131 | in a single line to start/stop multi-line mode | 135 | in a single line to start/stop multi-line mode |
| 132 | ``` | 136 | ``` |
| 133 | 137 | ||
| 134 | Use cases: | 138 | ### Common Usage |
| 135 | 139 | ||
| 136 | * Recursively compile every YueScript file with extension `.yue` under current path: `yue .` | 140 | - Recursively compile every YueScript file with extension `.yue` under current path: `yue .` |
| 137 | * Compile and save results to a target path: `yue -t /target/path/ .` | 141 | - Compile and save results to a target path: `yue -t /target/path/ .` |
| 138 | * Compile and reserve debug info: `yue -l .` | 142 | - Compile and reserve debug info: `yue -l .` |
| 139 | * Compile and generate minified codes: `yue -m .` | 143 | - Compile and generate minified codes: `yue -m .` |
| 140 | * Execute raw codes: `yue -e 'print 123'` | 144 | - Execute raw codes: `yue -e 'print 123'` |
| 141 | * Execute a YueScript file: `yue -e main.yue` | 145 | - Execute a YueScript file: `yue -e main.yue` |
| 142 | 146 | ||
| 147 | ## Mascot (Xiaoyu / 小玉) | ||
| 143 | 148 | ||
| 149 | <img src="doc/docs/.vitepress/public/image/mascot/electrichearts_20260211A_yuescript_xiaoyu.png" width="420" alt="Xiaoyu, the YueScript mascot"/> | ||
| 144 | 150 | ||
| 145 | ## Editor Support | 151 | Xiaoyu (小玉) is YueScript's official mascot, a cyber rabbit often seen perched on a crescent moon and coding on a laptop. |
| 146 | 152 | ||
| 147 | * [Vim](https://github.com/pigpigyyy/YueScript-vim) | 153 | - English page: [here](https://yuescript.org/doc/extras/mascot.html) |
| 148 | * [ZeroBraneStudio](https://github.com/pkulchenko/ZeroBraneStudio/issues/1134) (Syntax highlighting) | 154 | - Artwork by [Tyson Tan](https://tysontan.com) |
| 149 | * [Visual Studio Code](https://github.com/pigpigyyy/yuescript-vscode) | ||
| 150 | 155 | ||
| 156 | ## Editor Support | ||
| 151 | 157 | ||
| 158 | - [Vim](https://github.com/pigpigyyy/YueScript-vim) | ||
| 159 | - [ZeroBraneStudio](https://github.com/pkulchenko/ZeroBraneStudio/issues/1134) (Syntax highlighting) | ||
| 160 | - [Visual Studio Code](https://github.com/pigpigyyy/yuescript-vscode) | ||
| 152 | 161 | ||
| 153 | ## License | 162 | ## License |
| 154 | 163 | ||
