diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2020-02-01 19:30:19 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2020-02-01 19:36:56 +0000 |
| commit | 9b05b893ab5c286c7b5e3c6185d2f103a4c08327 (patch) | |
| tree | 187ec8beb556cf255524154baef9f431d5c4ca5a /ast.moon | |
| parent | basic references (diff) | |
| download | alive-9b05b893ab5c286c7b5e3c6185d2f103a4c08327.tar.gz alive-9b05b893ab5c286c7b5e3c6185d2f103a4c08327.zip | |
ast testing + fix
Diffstat (limited to 'ast.moon')
| -rw-r--r-- | ast.moon | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -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}'" |
