diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-05-30 17:20:22 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-05-30 17:21:19 -0700 |
| commit | b53516c47c0dd1f9325f9f721f561487510cca98 (patch) | |
| tree | 92961e19bc94eec3ab8b0f19357c57399c205b7d /nomsu_tree.moon | |
| parent | 5637676bc45ce9aa3015726485f63a2a5745a45a (diff) | |
Simplified and correctified lib/object (though the codegen still need
streamlining), added a .stub member to Action trees, and switched
Source's repr to be @filename[start:stop] instead of
"filename[start:stop]"
Diffstat (limited to 'nomsu_tree.moon')
| -rw-r--r-- | nomsu_tree.moon | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/nomsu_tree.moon b/nomsu_tree.moon index 1e662d7..4e9ec3d 100644 --- a/nomsu_tree.moon +++ b/nomsu_tree.moon @@ -20,7 +20,7 @@ Tree = (name, kind, methods)-> with methods .type = name .name = name - .__new = (value, source)=> + .__new or= (value, source)=> assert source if type(source) == 'string' source = Source\from_string(source) @@ -46,7 +46,10 @@ Tree = (name, kind, methods)-> ._map = (fn)=> fn(@) or @ - Types[name] = immutable {"value", "source"}, methods + if name == "Action" + Types[name] = immutable {"value", "source", "stub"}, methods + else + Types[name] = immutable {"value", "source"}, methods Tree "Block", 'multi' Tree "EscapedNomsu", 'multi' @@ -60,10 +63,13 @@ Tree "Comment", 'single' Tree "Var", 'single' Tree "Action", 'multi', - get_stub: (include_names=false)=> - if include_names - concat [type(a) == "string" and a or "%#{a.value}" for a in *@value], " " - else - concat [type(a) == "string" and a or "%" for a in *@value], " " + __new: (value, source)=> + assert source + if type(source) == 'string' + source = Source\from_string(source) + stub = concat [type(a) == "string" and a or "%" for a in *value], " " + return value, source, stub + get_spec: => + concat [type(a) == "string" and a or "%#{a.value}" for a in *@value], " " return Types |
