Movatterモバイル変換


[0]ホーム

URL:


MoonScript

MoonScript
MoonScript on GitHubMoonScript on TwitterMoonScript on Google Plus
MoonScript is an
open source project
MIT License
A programmer friendly language that compiles toLua.

MoonScript is a dynamic scripting language that compiles intoLua. It gives you the power of one of the fastestscripting languages combined with a rich set of features.

See Lua
classThingname:"unknown"classPersonextendsThingsay_name:=>print"Hello, I am#{@name}!"withPerson!.name="MoonScript"\say_name!

MoonScript can either be compiled into Lua and run at a later time, or it canbe dynamically compiled and run using themoonloader. It’s as simple asrequire "moonscript" in order to have Lua understand how to load and run anyMoonScript file.

Because it compiles right into Lua code, it is completely compatible withalternative Lua implementations likeLuaJIT, and it isalso compatible with all existing Lua code and libraries.

The command line tools also let you run MoonScript directly from thecommand line, like any first-class scripting language.

A comprehensive overview of the language can be found in thereferencemanual, the rest of this page serves as an overview of thelanguage.

Overview

MoonScript provides a clean syntax using significant whitespace that avoids allthe keyword noise typically seen in a Lua script. Below is a sample of someconstructs found in the language.

See Lua
exportmy_funcx=2323collection=height:32434hats:{"tophat","bball","bowler"}my_func=(a)->x+aprintmy_func100

It also addstable comprehensions,implicit return on functions,classes,inheritance, scope management statementsimport &export, and a convenientobject creation statement calledwith.

See Lua
importconcat,insertfromtabledouble_args=(...)->[x*2forxin*{...}]tuples=[{k,v}fork,vinipairsmy_table]

It can be loaded directly from a Lua scriptwithout an intermediatecompile step. It even knows how totell youwhere errors occurred in the original file whenthey happen.

Installation

Installing with LuaRocks

If you're on Windows, then install theWindows binaries,otherwise the easiest way to install is to use LuaRocks.

LuaRocks can be obtainedhere or from your packagemanager.

After it is installed, run the following in a terminal:

$luarocks install moonscript

This will provide themoon andmoonc executables along with themoonscript andmoon Lua module.

Windows Binaries

Precompiled Windows binaries are available to avoid the trouble of compiling:moonscript.zip

Extract the contents into yourPATH. You can also use the includedmoonscript.dll to require the module in.

This version has been compiled against Lua 5.1.

Optional

If you're on Linux and usewatch mode (which compiles.moon files to.luafiles as they are changed) you can installlinotify to use inotify instead ofpolling.

Source

The source code to the project lives on GitHub:
https://github.com/leafo/moonscript

Issues with the tool can be reported on the issue tracker:
https://github.com/leafo/moonscript/issues

The latest development version can be installed with the dev rockspec:

$luarocks install\    https://luarocks.org/manifests/leafo/moonscript-dev-1.rockspec

Dependencies

In addition toLua 5.1 or 5.2, the following Lua modules arerequired to run the compiler and associated tools:

All of the required ones can be retrieved automatically using theLuaRocks installation.

Learning

Extras & Addons

Editor Support

Vim syntax and indent:
https://github.com/leafo/moonscript-vim

Sublime Text (and Textmate) syntax and indent:
https://github.com/leafo/moonscript-tmbundle

Tools

Online Compiler:
http://moonscript.org/compiler/

Overview of Differences & Highlights

A more detailed overview of the syntax can be found in thereference manual.

About

The syntax of MoonScript has been heavily inspired by the syntax ofCoffeeScript. MoonScript isCoffeeScript for Lua.

MoonScript would not have been possible without the excellent toolLPeg for parsing.

Changelog

Generated withSitegen on Fri Jan 25 18:27:41 2019; MoonScript v0.5.0
×

Compiled Lua


[8]ページ先頭

©2009-2025 Movatter.jp