Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

daelvn/msmx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

msmx - MoonScript Macro Expansion

This is a macro expansion system that uses lbuilder3.macro to do the replacements.

Features

apply

a $ b $ 1 + 1

turns into

(a (b 1 + 1))

ask

You can use ? instead of ! to call functions.

compare-type

Uses ltypekit6

x === string

turns into

((typeof x) == "string")

import-all

import * from require "msmx" as msmx

turns into

msmx = require "msmx"

import-in

import a, b in msmx

turns into

import a, b from require "msmx"

import-std

Brings std/<library> into the local scope, where <library> is any of:

coroutine

  • wrap -> cowrap
  • yield
  • create -> Coroutine
  • resume
  • status -> costatus
  • running -> corunning
  • isyieldable -> isYieldable

debug

  • gethook
  • getinfo
  • getlocal
  • getmetatable -> _getmetatable
  • getregistry
  • getupvalue
  • getuservalue
  • sethook
  • setlocal
  • setmetatable -> _setmetatable
  • setupvalue
  • setuservalue
  • traceback
  • upvalueid
  • upvaluejoin

io

  • close -> closeIO
  • flush -> flushIO
  • input -> inputIO
  • lines -> linesIO
  • open -> openIO
  • output -> outputIO
  • popen -> popenIO
  • read -> readIO
  • tmpfile -> tempfileIO
  • type -> typeIO
  • write -> writeIO

math

All values are the same

os

  • clock
  • date
  • difftime
  • execute
  • exit
  • getenv
  • remove -> fremove
  • rename -> frename
  • setlocale
  • time
  • tmpname -> tempname

package

  • config -> pkgConfig
  • cpath
  • path
  • loaded -> pkgLoaded
  • loadlib -> pkgLoad
  • preload -> pkgPreload
  • searchers -> pkgSearchers
  • searchpath -> pkgSearchpath

string

  • byte
  • char
  • dump
  • find
  • format
  • gmatch
  • gsub
  • len
  • lower
  • match
  • pack -> packString
  • packsize
  • rep
  • reverse
  • sub
  • unpack -> unpackString
  • upper

table

All values are the same

utf8

All values prefixed with utf8

import-simple

import msmx

turns into

msmx = require "msmx"

import-simple-all

import xmsmx as msmx

turns into

msmx = require "xmsmx"

infix

a `fn` b
a <fn> b

turns into

fn a, b
fn a, b

Special cases

  • <$> -> __apply
  • <.> -> __compose
  • <$!> -> __apply_excl
  • <|> -> __alternative

loadfile

a <=< "file"

turns into

a = assert io.open "file", "r"

negate

not= a

turns into

a = not a

nil-update

a ?= b

turns into

a = (a == nil) and b or a

oversign

Uses ltypekit6

f = ::> string -> string

turns into

f = sign "string -> string"

pragma

Activates language features. Syntax: {-# KEYWORD Argument #-}

LANGUAGE

Types

Uses ltypekit6

import typeof from require "ltypekit.type"

NoTypes

typeof = nil

DataTypes

Uses ltypekit6.1

import typeE, data, metatype from require "ltypekit.type"

NoDataTypes

typeE, data, metatype = nil, nil, nil

Signatures

Uses ltypekit6

import sign from require "ltypekit"

NoSignatures

sign = nil

IndexableStrings

getmetatable''.__index = (str, i) -> string.sub str, i, i

Substrings

getmetatable''.__call = string.sub

sign

Uses ltypekit6 Requires LANGUAGE Signatures pragma

f :: string -> string

turns into

f = sign "string -> string"

where

fncall x where
  return y

turns into

fncall x, (...) ->
  return y

which

data Char which
  name: "Char"

turns into

data Char,
  name: "Char"

About

MoonScript Macro eXpansion

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published