aboutsummaryrefslogtreecommitdiffstats
path: root/ast.moon
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-02-01 19:30:19 +0000
committers-ol <s-ol@users.noreply.github.com>2020-02-01 19:36:56 +0000
commit9b05b893ab5c286c7b5e3c6185d2f103a4c08327 (patch)
tree187ec8beb556cf255524154baef9f431d5c4ca5a /ast.moon
parentbasic references (diff)
downloadalive-9b05b893ab5c286c7b5e3c6185d2f103a4c08327.tar.gz
alive-9b05b893ab5c286c7b5e3c6185d2f103a4c08327.zip
ast testing + fix
Diffstat (limited to 'ast.moon')
-rw-r--r--ast.moon13
1 files changed, 6 insertions, 7 deletions
diff --git a/ast.moon b/ast.moon
index 47eebee..c5bfd07 100644
--- a/ast.moon
+++ b/ast.moon
@@ -1,12 +1,6 @@
import Const from require 'base'
unpack or= table.unpack
-unescape = (str) ->
- str = str\gsub '\\"', '"'
- str = str\gsub "\\'", "'"
- str = str\gsub "\\\\", "\\"
- str
-
class ASTNode
-- first pass (outin):
-- * expand macros
@@ -23,13 +17,18 @@ class Atom
new: (@raw, @atom_type) =>
+ unescape = (str) ->
+ str = str\gsub '\\"', '"'
+ str = str\gsub "\\'", "'"
+ str = str\gsub "\\\\", "\\"
+ str
expand: (scope) =>
@value = Const switch @atom_type
when 'num'
tonumber @raw
when 'sym'
assert scope[@raw], "undefined reference to symbol '#{@raw}'"
- when 'strq', 'std'
+ when 'strq', 'strd'
unescape @raw
else
error "unknown atom type: '#{@atom_type}'"