diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-09-17 15:29:48 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-09-17 15:30:24 -0700 |
| commit | c1cba45968b8d5e993fb12fcd7dae9192fbe6d79 (patch) | |
| tree | ffa1ba6e6eb9b544bd28ce08e653d7467df226e8 /core | |
| parent | e3bf10196ae42463db8d702fe90a222bb7cb4d54 (diff) | |
Added support for compile actions returning trees, and compiling blocks
into values.
Diffstat (limited to 'core')
| -rw-r--r-- | core/metaprogramming.nom | 6 | ||||
| -rw-r--r-- | core/operators.nom | 11 |
2 files changed, 4 insertions, 13 deletions
diff --git a/core/metaprogramming.nom b/core/metaprogramming.nom index 5d31c2b..c50f783 100644 --- a/core/metaprogramming.nom +++ b/core/metaprogramming.nom @@ -197,16 +197,14 @@ compile [parse %actions as %body] to (..) end local \%new_body = LuaCode(\%body.source, "local mangle = mangler()", - "\\nlocal tree = ", make_tree(\%body), - "\\nlocal lua = nomsu:compile(tree)", - "\\nreturn lua") + "\\nreturn ", make_tree(\%body)) local ret = \(compile as (compile %actions to %new_body)) return ret" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # TODO: add check for .is_value -compile [%tree as lua expr] to (Lua value "nomsu:compile(\(=lua "nomsu:compile(\%tree)"))") +compile [%tree as lua expr] to (Lua value "nomsu:compile(\(=lua "nomsu:compile(\%tree, nil, true)"), nil, true)") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/core/operators.nom b/core/operators.nom index 161bf83..3ae7c2f 100644 --- a/core/operators.nom +++ b/core/operators.nom @@ -27,16 +27,9 @@ test: # Variable assignment operator compile [%var = %value] to: - lua> "local \%var_lua = \(%var as lua)" + lua> "local \%var_lua = \(%var as lua expr)" assume %var_lua.is_value or barf "Invalid target for assignment: \%var" - lua> "\ - ..\%value = \%value:map(function(t) - if Action:is_instance(t) and t.stub == "?" then - return \%var - end - end) - local \%value_lua = \(%value as lua)" - + lua> "local \%value_lua = \(%value as lua expr)" assume %value_lua.is_value or barf "Invalid value for assignment: \%value" lua> "\ ..local lua = LuaCode(tree.source, \%var_lua, ' = ', \%value_lua, ';') |
