diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-04-19 17:23:44 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-04-19 17:23:54 -0700 |
| commit | da33269c307c8a045e548cb1df2a3281a7a0f99e (patch) | |
| tree | 9451b857633b0869b4589a73107056815aa560c7 /nomsu_tree.moon | |
| parent | dcb380f1f6ec67c52364b1246546f1f6b2c168d3 (diff) | |
All tests passing (except object)
Diffstat (limited to 'nomsu_tree.moon')
| -rw-r--r-- | nomsu_tree.moon | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/nomsu_tree.moon b/nomsu_tree.moon index 23ad830..1c41906 100644 --- a/nomsu_tree.moon +++ b/nomsu_tree.moon @@ -27,6 +27,15 @@ Tree = (name, methods)-> .with_value = (value)=> getmetatable(self)(value, @source) .type = name .name = name + .as_nomsu = => + leading_space = 0 + src_file = FILE_CACHE[@source.filename] + while src_file\sub(@source.start-leading_space-1, @source.start-leading_space-1) == " " + leading_space += 1 + if src_file\sub(@source.start-leading_space-1, @source.start-leading_space-1) != "\n" + leading_space = 0 + ret = tostring(@source\get_text!)\gsub("\n"..((" ")\rep(leading_space)), "\n") + return ret Types[name] = immutable {"value","source"}, methods @@ -49,7 +58,7 @@ Tree "File", Tree "Nomsu", as_lua: (nomsu)=> - Lua.Value(@source, "nomsu:parse(Nomsu(",repr(@source),", ",repr(@source\get_text!),"))") + Lua.Value(@source, "nomsu:parse(Nomsu(",repr(@value.source),", ",repr(tostring(@value.source\get_text!)),")).value[1]") Tree "Block", as_lua: (nomsu)=> |
