Giter Site home page Giter Site logo

zaxebo1 / yuescript Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pigpigyyy/yuescript

0.0 0.0 0.0 10.43 MB

A Moonscript dialect compiles to Lua.

Home Page: http://yuescript.org

License: MIT License

C++ 39.53% C 43.24% Lua 16.08% Makefile 0.94% CMake 0.17% Dockerfile 0.04%

yuescript's Introduction

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
   -t path  Specify where to place compiled files
   -o file  Write output to file
   -s       Use spaces in generated codes instead of tabs
   -m       Generate minified codes
   -p       Write output to standard out
   -b       Dump compile time (doesn't write output)
   -l       Write line numbers from source codes
   -v       Print version
   --       Read from standard in, print to standard out
            (Must be first and only argument)

   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

yuescript's People

Contributors

pigpigyyy avatar criztianix avatar childishgiant avatar shalokshalom avatar ekickx avatar shadmansaleh avatar aergo20 avatar apologetiks avatar natnat-mc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.