mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
use \ for colon call operator
This commit is contained in:
parent
b4df97d2d6
commit
c86a386d00
@ -240,8 +240,8 @@ local build_grammar = wrap(function()
|
||||
InBlock = #Cmt(Indent, advance_indent) * Block * OutBlock,
|
||||
OutBlock = Cmt("", pop_indent),
|
||||
|
||||
Import = key"import"* Ct(ImportNameList) * key"from" * Exp / mark"import",
|
||||
ImportName = (Ct(sym":" / trim * Name) + Name),
|
||||
Import = key"import" * Ct(ImportNameList) * key"from" * Exp / mark"import",
|
||||
ImportName = (sym"\\" * Ct(Cc":" * Name) + Name),
|
||||
ImportNameList = ImportName * (sym"," * ImportName)^0,
|
||||
|
||||
NameList = Name * (sym"," * Name)^0,
|
||||
@ -293,7 +293,6 @@ local build_grammar = wrap(function()
|
||||
((Chain + DotChain + Callable) * Ct(ExpList^0)) / flatten_func +
|
||||
Num,
|
||||
|
||||
|
||||
String = Space * DoubleString + Space * SingleString + LuaString,
|
||||
SingleString = simple_string("'"),
|
||||
DoubleString = simple_string('"'),
|
||||
@ -320,7 +319,7 @@ local build_grammar = wrap(function()
|
||||
-- shorthand dot call for use in with statement
|
||||
DotChain =
|
||||
(sym"." * Cc(-1) * (_Name / mark"dot") * ChainItem^0) / mark"chain" +
|
||||
(sym":" * Cc(-1) * (
|
||||
(sym"\\" * Cc(-1) * (
|
||||
(_Name * Invoke / mark"colon") * ChainItem^0 +
|
||||
(_Name / mark"colon_stub")
|
||||
)) / mark"chain",
|
||||
@ -334,9 +333,8 @@ local build_grammar = wrap(function()
|
||||
|
||||
Slice = symx"[" * Num * sym":" * Num * (sym":" * Num)^-1 *sym"]" / mark"slice",
|
||||
|
||||
ColonCall = symx":" * (_Name * Invoke) / mark"colon",
|
||||
|
||||
ColonSuffix = symx":" * _Name / mark"colon_stub",
|
||||
ColonCall = symx"\\" * (_Name * Invoke) / mark"colon",
|
||||
ColonSuffix = symx"\\" * _Name / mark"colon_stub",
|
||||
|
||||
Invoke = FnArgs/mark"call" +
|
||||
SingleString / wrap_func_arg +
|
||||
|
@ -7,7 +7,7 @@ class Hello
|
||||
__tostring: => "hello world"
|
||||
|
||||
x = Hello 1,2
|
||||
x:hello()
|
||||
x\hello()
|
||||
|
||||
print x
|
||||
|
||||
@ -18,7 +18,7 @@ class Yikes extends Simple
|
||||
new: => print "created hello"
|
||||
|
||||
x = Yikes()
|
||||
x:cool()
|
||||
x\cool()
|
||||
|
||||
|
||||
class Hi
|
||||
@ -34,6 +34,6 @@ class Simple extends Hi
|
||||
cool: => super 120302
|
||||
|
||||
x = Simple()
|
||||
x:cool()
|
||||
x\cool()
|
||||
|
||||
|
||||
|
@ -3,10 +3,10 @@
|
||||
import hello from yeah
|
||||
import hello, world from table["cool"]
|
||||
|
||||
import a, :b, c from items
|
||||
import a, \b, c from items
|
||||
|
||||
|
||||
import master, :ghost from find "mytable"
|
||||
import master, \ghost from find "mytable"
|
||||
|
||||
|
||||
a, yumm = 3434, "hello"
|
||||
@ -18,5 +18,5 @@ import something from a table
|
||||
|
||||
|
||||
if indent
|
||||
import okay, :well from tables[100]
|
||||
import okay, \well from tables[100]
|
||||
|
||||
|
@ -97,9 +97,9 @@ argon =
|
||||
return world: (a,b) -> print "sum", a + b
|
||||
|
||||
something.what()
|
||||
argon:world().something()
|
||||
argon\world().something()
|
||||
|
||||
argon:somethin"200".world(1,2)
|
||||
argon\somethin"200".world(1,2)
|
||||
|
||||
x = -434
|
||||
|
||||
@ -134,10 +134,11 @@ x = #{#{},#{1},#{1,2}}
|
||||
|
||||
hello, world
|
||||
|
||||
something:hello(what) a,b
|
||||
something:hello what
|
||||
something.hello:world a,b
|
||||
something.hello:world(1,2,3) a,b
|
||||
something\hello(what) a,b
|
||||
something\hello what
|
||||
something.hello\world a,b
|
||||
something.hello\world(1,2,3) a,b
|
||||
|
||||
|
||||
x = 1232
|
||||
x += 10 + 3
|
||||
|
@ -13,9 +13,9 @@ with leaf
|
||||
|
||||
.hi 1,2,3
|
||||
|
||||
:hi(1,2).world 2323
|
||||
\hi(1,2).world 2323
|
||||
|
||||
:hi "yeah", "man"
|
||||
\hi "yeah", "man"
|
||||
.world = 200
|
||||
|
||||
zyzyzy = with something
|
||||
|
Loading…
Reference in New Issue
Block a user