aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-07-22 13:44:00 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-07-22 13:44:00 -0700
commitfead66ab9b39b24e1059b3a55dd09dd1491fee60 (patch)
tree3ffd13f0394055b8500d9ed29f46cb696980b5c7
parent5435e50f0f0512656bca873b90c0e0fcfb9e38b1 (diff)
Added equality metamethod to ASTs.
-rw-r--r--nomsu_tree.moon5
1 files changed, 5 insertions, 0 deletions
diff --git a/nomsu_tree.moon b/nomsu_tree.moon
index 9df240a..885892f 100644
--- a/nomsu_tree.moon
+++ b/nomsu_tree.moon
@@ -40,6 +40,11 @@ for name in *types
replacement = (@__class)(@source, unpack(replacements))
replacement.comments = [c for c in *@comments] if @comments
return replacement
+ .__eq = (other)=>
+ return false if type(@) != type(other) or #@ != #other or getmetatable(@) != getmetatable(other)
+ for i=1,#@
+ return false if @[i] != other[i]
+ return true
AST[name] = setmetatable cls,
__tostring: => @name