mirror of
https://github.com/leafo/moonscript.git
synced 2025-01-09 00:04:22 +00:00
Merge branch 'lua5.3_operators' of https://github.com/Nymphium/moonscript into Nymphium-lua5.3_operators
This commit is contained in:
commit
93a1bffe0c
@ -286,6 +286,9 @@ return {
|
||||
number = function(self, node)
|
||||
return node[2]
|
||||
end,
|
||||
bitnot = function(self, node)
|
||||
return self:line("~", self:value(node[2]))
|
||||
end,
|
||||
length = function(self, node)
|
||||
return self:line("#", self:value(node[2]))
|
||||
end,
|
||||
|
@ -173,6 +173,9 @@ string_chars = {
|
||||
number: (node) =>
|
||||
node[2]
|
||||
|
||||
bitnot: (node) =>
|
||||
@line "~", @value node[2]
|
||||
|
||||
length: (node) =>
|
||||
@line "#", @value node[2]
|
||||
|
||||
|
@ -145,12 +145,12 @@ local build_grammar = wrap_env(debug_grammar, function(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"),
|
||||
CharOperators = Space * C(S("+-*/%^><")),
|
||||
WordOperators = op("or") + op("and") + op("<=") + op(">=") + op("~=") + op("!=") + op("==") + op(".."),
|
||||
CharOperators = Space * C(S("+-*/%^><|&")),
|
||||
WordOperators = op("or") + op("and") + op("<=") + op(">=") + op("~=") + op("!=") + op("==") + op("..") + op("<<") + op(">>") + op("//"),
|
||||
BinaryOperator = (WordOperators + CharOperators) * SpaceBreak ^ 0,
|
||||
Assignable = Cmt(Chain, check_assignable) + Name + SelfName,
|
||||
Exp = Ct(Value * (BinaryOperator * Value) ^ 0) / flatten_or_mark("exp"),
|
||||
SimpleValue = If + Unless + Switch + With + ClassDecl + ForEach + For + While + Cmt(Do, check_do) + sym("-") * -SomeSpace * Exp / mark("minus") + sym("#") * Exp / mark("length") + key("not") * Exp / mark("not") + TblComprehension + TableLit + Comprehension + FunLit + Num,
|
||||
SimpleValue = If + Unless + Switch + With + ClassDecl + ForEach + For + While + Cmt(Do, check_do) + sym("-") * -SomeSpace * Exp / mark("minus") + sym("#") * Exp / mark("length") + sym("~") * Exp / mark("bitnot") + key("not") * Exp / mark("not") + TblComprehension + TableLit + Comprehension + FunLit + Num,
|
||||
ChainValue = (Chain + Callable) * Ct(InvokeArgs ^ -1) / join_chain,
|
||||
Value = pos(SimpleValue + Ct(KeyValueList) / mark("table") + ChainValue + String),
|
||||
SliceValue = SimpleValue + ChainValue,
|
||||
|
@ -180,8 +180,8 @@ build_grammar = wrap_env debug_grammar, (root) ->
|
||||
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"
|
||||
|
||||
CharOperators: Space * C(S"+-*/%^><")
|
||||
WordOperators: op"or" + op"and" + op"<=" + op">=" + op"~=" + op"!=" + op"==" + op".."
|
||||
CharOperators: Space * C(S"+-*/%^><|&")
|
||||
WordOperators: op"or" + op"and" + op"<=" + op">=" + op"~=" + op"!=" + op"==" + op".." + op"<<" + op">>" + op"//"
|
||||
BinaryOperator: (WordOperators + CharOperators) * SpaceBreak^0
|
||||
|
||||
Assignable: Cmt(Chain, check_assignable) + Name + SelfName
|
||||
@ -196,6 +196,7 @@ build_grammar = wrap_env debug_grammar, (root) ->
|
||||
Cmt(Do, check_do) +
|
||||
sym"-" * -SomeSpace * Exp / mark"minus" +
|
||||
sym"#" * Exp / mark"length" +
|
||||
sym"~" * Exp / mark"bitnot" +
|
||||
key"not" * Exp / mark"not" +
|
||||
TblComprehension +
|
||||
TableLit +
|
||||
|
Loading…
Reference in New Issue
Block a user