Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

is/isnt implemented #28

Open
wants to merge 1 commit into from

2 participants

Vladimir Dronnikov Daniel Eloff
Vladimir Dronnikov

Please, consider applying

Daniel Eloff

This has been open two years, I think this PR can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 14, 2012
  1. Vladimir Dronnikov

    introduce is and isnt operators

    dvv authored
This page is out of date. Refresh to see the latest.
12 moonscript/compile/value.lua
View
@@ -39,8 +39,16 @@ value_compile = {
exp = function(self, node)
local _comp
_comp = function(i, value)
- if i % 2 == 1 and value == "!=" then
- value = "~="
+ if i % 2 == 1 then
+ if value == "!=" then
+ value = "~="
+ end
+ if value == "is" then
+ value = "=="
+ end
+ if value == "isnt" then
+ value = "~="
+ end
end
return self:value(value)
end
6 moonscript/compile/value.moon
View
@@ -22,8 +22,10 @@ value_compile =
-- list of values separated by binary operators
exp: (node) =>
_comp = (i, value) ->
- if i % 2 == 1 and value == "!="
- value = "~="
+ if i % 2 == 1
+ value = "~=" if value == "!="
+ value = "==" if value == "is"
+ value = "~=" if value == "isnt"
@value value
with @line!
2  moonscript/parse.lua
View
@@ -347,7 +347,7 @@ local build_grammar = wrap_env(function()
Update = Assignable * ((sym"..=" + sym"+=" + sym"-=" + sym"*=" + sym"/=" + sym"%=")/trim) * Exp / mark"update",
-- we can ignore precedence for now
- OtherOps = op"or" + op"and" + op"<=" + op">=" + op"~=" + op"!=" + op"==" + op".." + op"<" + op">",
+ OtherOps = op"or" + op"and" + op"<=" + op">=" + op"~=" + op"!=" + op"==" + op".." + op"<" + op">" + op"is" + op"isnt",
Assignable = Cmt(DotChain + Chain, check_assignable) + Name,
AssignableList = Assignable * (sym"," * Assignable)^0,
5 tests/inputs/cond.moon
View
@@ -51,3 +51,8 @@ elseif "just us"
print "will smith" else show 5555555
+if one is two
+ print "war is piece"
+
+if one isnt two
+ print "no big brother"
6 tests/outputs/cond.lua
View
@@ -84,4 +84,10 @@ elseif "just us" then
print("will smith")
else
show(5555555)
+end
+if one == two then
+ print("war is piece")
+end
+if one ~= two then
+ print("no big brother")
end
Something went wrong with that request. Please try again.