mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
add bitwise update assignment operators (#277)
This commit is contained in:
parent
f2cb2f506c
commit
330f5491d6
@ -146,7 +146,7 @@ local build_grammar = wrap_env(debug_grammar, function(root)
|
||||
CompFor = key("for" * Name * sym("=") * Ct(Exp * sym(",") * Exp * (sym(",") * Exp) ^ -1) / mark("for")),
|
||||
CompClause = CompFor + CompForEach + key("when") * Exp / mark("when"),
|
||||
Assign = sym("=") * (Ct(With + If + Switch) + Ct(TableBlock + ExpListLow)) / mark("assign"),
|
||||
Update = ((sym("..=") + sym("+=") + sym("-=") + sym("*=") + sym("/=") + sym("%=") + sym("or=") + sym("and=")) / trim) * Exp / mark("update"),
|
||||
Update = ((sym("..=") + sym("+=") + sym("-=") + sym("*=") + sym("/=") + sym("%=") + sym("or=") + sym("and=") + sym("&=") + sym("|=") + sym(">>=") + sym("<<=")) / trim) * Exp / mark("update"),
|
||||
CharOperators = Space * C(S("+-*/%^><|&")),
|
||||
WordOperators = op("or") + op("and") + op("<=") + op(">=") + op("~=") + op("!=") + op("==") + op("..") + op("<<") + op(">>") + op("//"),
|
||||
BinaryOperator = (WordOperators + CharOperators) * SpaceBreak ^ 0,
|
||||
|
@ -175,7 +175,7 @@ build_grammar = wrap_env debug_grammar, (root) ->
|
||||
CompClause: CompFor + CompForEach + key"when" * Exp / mark"when"
|
||||
|
||||
Assign: sym"=" * (Ct(With + If + Switch) + Ct(TableBlock + ExpListLow)) / mark"assign"
|
||||
Update: ((sym"..=" + sym"+=" + sym"-=" + sym"*=" + sym"/=" + sym"%=" + sym"or=" + sym"and=") / trim) * Exp / mark"update"
|
||||
Update: ((sym"..=" + sym"+=" + sym"-=" + sym"*=" + sym"/=" + sym"%=" + sym"or=" + sym"and=" + sym"&=" + sym"|=" + sym">>=" + sym"<<=") / trim) * Exp / mark"update"
|
||||
|
||||
CharOperators: Space * C(S"+-*/%^><|&")
|
||||
WordOperators: op"or" + op"and" + op"<=" + op">=" + op"~=" + op"!=" + op"==" + op".." + op"<<" + op">>" + op"//"
|
||||
|
@ -243,6 +243,8 @@ another hello, one,
|
||||
a += 3 - 5
|
||||
a *= 3 + 5
|
||||
a *= 3
|
||||
a >>= 3
|
||||
a <<= 3
|
||||
a /= func "cool"
|
||||
|
||||
---
|
||||
|
@ -241,6 +241,8 @@ another(hello, one, two, three, four, {
|
||||
a = a + (3 - 5)
|
||||
a = a * (3 + 5)
|
||||
a = a * 3
|
||||
a = a >> 3
|
||||
a = a << 3
|
||||
a = a / func("cool")
|
||||
x["then"] = "hello"
|
||||
x["while"]["true"] = "hello"
|
||||
|
Loading…
Reference in New Issue
Block a user