mirror of
https://github.com/leafo/moonscript.git
synced 2025-01-09 00:04:22 +00:00
unary minus must not have any whitespace after it
avoids precedence ambiguity between minus with fncall
This commit is contained in:
parent
63437f8c52
commit
17184f2aa8
@ -35,6 +35,7 @@ local Indent = C(S"\t "^0) / count_indent
|
||||
|
||||
local Comment = P"--" * (1 - S"\n")^0 * #Stop
|
||||
local Space = _Space * Comment^-1
|
||||
local SomeSpace = S" \t"^1 * Comment^-1
|
||||
|
||||
local _Name = C(R("az", "AZ", "__") * R("az", "AZ", "09", "__")^0)
|
||||
local Name = Space * _Name
|
||||
@ -279,7 +280,7 @@ local build_grammar = wrap(function()
|
||||
|
||||
Value =
|
||||
If +
|
||||
sym"-" * Exp / mark"minus" +
|
||||
sym"-" * -SomeSpace * Exp / mark"minus" +
|
||||
sym"#" * Exp / mark"length" +
|
||||
sym"not" * Exp / mark"not" +
|
||||
TableLit +
|
||||
@ -407,12 +408,3 @@ function string(str)
|
||||
return g:match(str)
|
||||
end
|
||||
|
||||
local program3 = [[
|
||||
-- hello
|
||||
class Hello
|
||||
@something: 2323
|
||||
|
||||
hello: () ->
|
||||
print 200
|
||||
]]
|
||||
|
||||
|
@ -159,3 +159,12 @@ hello =
|
||||
good: 230203
|
||||
|
||||
|
||||
5 + what wack
|
||||
what whack + 5
|
||||
|
||||
5 - what wack
|
||||
what whack - 5
|
||||
|
||||
x = hello - world - something
|
||||
|
||||
|
||||
|
@ -118,4 +118,9 @@ local hello = {
|
||||
["else"] = 3434,
|
||||
["function"] = "okay",
|
||||
good = 230203
|
||||
}
|
||||
}
|
||||
_ = 5 + what(wack)
|
||||
what(whack + 5)
|
||||
_ = 5 - what(wack)
|
||||
what(whack - 5)
|
||||
x = hello - world - something
|
Loading…
Reference in New Issue
Block a user