diff --git a/moonscript/parse.lua b/moonscript/parse.lua index 2ba504a..21fecb8 100644 --- a/moonscript/parse.lua +++ b/moonscript/parse.lua @@ -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, diff --git a/moonscript/parse.moon b/moonscript/parse.moon index f7d8926..558d4c8 100644 --- a/moonscript/parse.moon +++ b/moonscript/parse.moon @@ -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"//" diff --git a/spec/inputs/syntax.moon b/spec/inputs/syntax.moon index 05ce067..7b49d04 100644 --- a/spec/inputs/syntax.moon +++ b/spec/inputs/syntax.moon @@ -243,6 +243,8 @@ another hello, one, a += 3 - 5 a *= 3 + 5 a *= 3 +a >>= 3 +a <<= 3 a /= func "cool" --- diff --git a/spec/outputs/syntax.lua b/spec/outputs/syntax.lua index f19a3e6..bf32319 100644 --- a/spec/outputs/syntax.lua +++ b/spec/outputs/syntax.lua @@ -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"