5 Star 13 Fork 2

Li Jin / Yuescript

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

YueScript

logo

Ubuntu Windows macOS Discord Badge

Yuescript is a Moonscript dialect. It is derived from Moonscript language 0.5.0 and continuously adopting new features to be more up to date.

Moonscript is a language that compiles to Lua. Since original Moonscript has been used to write web framework lapis and run a few business web sites like itch.io and 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.

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.

Yue (月) is the name of moon in Chinese and it's pronounced as [jyɛ].

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 most of the features from Moonscript language. Generate Lua codes in the same way like the original compiler.
  • Reserve line numbers from source file in the compiled Lua codes to help debugging.
  • More features like macro, existential operator, pipe operator, Javascript-like export syntax and etc.
  • See other details in the changelog. Find document here.

Installation & Usage

  • Lua Module

  Build yue.so file with

> make shared LUAI=/usr/local/include/lua LUAL=/usr/local/lib/lua

  Then get the binary file from path bin/shared/yue.so.

  Or you can install luarocks, a package manager for Lua modules. Then install it as a Lua module with

> luarocks install yuescript

  Then require the Yuescript module in Lua:

require("yue")("main") -- require `main.yue`

local yue = require("yue")
local codes, err, globals = yue.to_lua([[
f = ->
  print "hello world"
f!
]],{
  implicit_return_root = true,
  reserve_line_number = true,
  lint_global = true
})
  • Binary Tool

  Clone this repo, then build and install executable with:

> make install

  Build Yuescript tool without macro feature:

> make install NO_MACRO=true

  Build Yuescript tool without built-in Lua binary:

> make install NO_LUA=true

  Use Yuescript tool with:

> yue -h
Usage: yue [options|files|directories] ...

   -h       Print this message
   -e str   Execute a file or raw codes
   -m       Generate minified codes
   -r       Rewrite output to match original line numbers
   -t path  Specify where to place compiled files
   -o file  Write output to file
   -s       Use spaces in generated codes instead of tabs
   -p       Write output to standard out
   -b       Dump compile time (doesn't write output)
   -g       Dump global variables used in NAME LINE COLUMN
   -l       Write line numbers from source codes
   -c       Reserve comments before statement from source codes
   -w path  Watch changes and compile every file under directory
   -v       Print version
   --       Read from standard in, print to standard out
            (Must be first and only argument)

   --target=version  Specify the Lua version that codes will be generated to
                     (version can only be 5.1, 5.2, 5.3 or 5.4)
   --path=path_str   Append an extra Lua search path string to package.path

   Execute without options to enter REPL, type symbol '$'
   in a single line to start/stop multi-line mode

  Use cases:
  Recursively compile every Yuescript file with extension .yue under current path: yue .
  Compile and save results to a target path: yue -t /target/path/ .
  Compile and reserve debug info: yue -l .
  Compile and generate minified codes: yue -m .
  Execute raw codes: yue -e 'print 123'
  Execute a Yuescript file: yue -e main.yue

Editor Support

License

MIT

MIT License Copyright (c) 2024 Li Jin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

用C++重写的Moonscript方言。 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C++
1
https://gitee.com/pig/Yuescript.git
git@gitee.com:pig/Yuescript.git
pig
Yuescript
Yuescript
main

搜索帮助