diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2020-02-01 23:51:40 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2020-02-01 23:55:30 +0000 |
| commit | 177cd265947bfd9db20ad1a99ae07c76b6b4f147 (patch) | |
| tree | 49af71e06770925abb0ab1fd2e89be077281b74c /ast.moon | |
| parent | first-class scopes (diff) | |
| download | alive-177cd265947bfd9db20ad1a99ae07c76b6b4f147.tar.gz alive-177cd265947bfd9db20ad1a99ae07c76b6b4f147.zip | |
macros and scopes
Diffstat (limited to 'ast.moon')
| -rw-r--r-- | ast.moon | 27 |
1 files changed, 20 insertions, 7 deletions
@@ -86,9 +86,17 @@ class Xpr @white[i/2] = parts[i+1] expand: (scope) => - scope = Scope @, scope - for child in *@ - child\expand scope + head = @[1] + head\expand scope + + @scope = Scope @, scope + + if head.value.type == 'macro' + macro = head.value\getc! + macro scope, @ + else + for child in *@[2,] + child\expand scope link: => head = @head! @@ -128,10 +136,15 @@ class Xpr make_nexpr: (...) -> Xpr 'naked', ... __tostring: => - if @tag - "<Xpr[#{@tag}] #{@value}>" - else - "<Xpr #{@value}>" + if @style == 'naked' + return 'ROOT' + + buf = "(" + buf ..= "[#{@tag}]" if @tag + buf ..= "#{@[1].raw}" + buf ..= " ..." if #@ > 1 + buf ..= ")" + buf { :Atom |
