diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-04-25 16:30:49 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-04-25 16:31:09 -0700 |
| commit | 5d59d510cd6fdc8553250e5ec10f19a285e8878c (patch) | |
| tree | 69d9a2646ed59746500fc9c62a04294a1019d381 /lib/training_wheels.nom | |
| parent | 50a092e4b5cb82131c0c8f6f46c7d21a42198858 (diff) | |
Removing end-of-line ":" and "(..)" for blocks (they just use
indentation now).
Diffstat (limited to 'lib/training_wheels.nom')
| -rw-r--r-- | lib/training_wheels.nom | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/training_wheels.nom b/lib/training_wheels.nom index e5c02fb..1f524da 100644 --- a/lib/training_wheels.nom +++ b/lib/training_wheels.nom @@ -26,19 +26,19 @@ parse [error!, panic!, fail!, abort!] as: barf! parse [error %, panic %, fail %, abort %] as: barf % parse [assert %condition %message] as: assume %condition or barf %message parse [%cond ? %if_true %if_false] as: %if_true if %cond else %if_false -compile [function %args %body, lambda %args %body] to: - %body_lua <- (%body as lua) - %statements <- ((%body_lua's "statements") or "return \(%body_lua's "expr");") - %locals <- (% for all ((%body_lua's "locals") or [])) - for all (%args's "value"): - lua> "utils.remove_from_list(\%locals, \(% as lua expr));" - if: (size of %locals) > 0 - %statements <- "local \(%locals joined with ", ");\n\%statements" - - return {..} - expr: ".." - (function(\(((% as lua expr) for all (%args's "value")) joined with ", ")) - \%statements - end) +compile [function %args %body, lambda %args %body] to + %lua <-: Lua value "(function(" + for %i = %arg in %args.value + if: %i > 1 + to %lua write ", " + to %lua write: %arg as lua expr + to %lua write ")\n " + %body <-: %body as lua + lua> "\%body:convert_to_statements('return ');" + for all %args.value: lua> "\%body:remove_free_vars(\%);" + to %lua write %body + to %lua write "\nend)" + return %lua parse [function %name %args %body] as: %name <- (function %args %body) -compile [call %fn %args] to {expr:"\(%fn as lua expr)(unpack(\(%args as lua expr)))"} +compile [call %fn %args] to + Lua value "\(%fn as lua expr)(unpack(\(%args as lua expr)))" |
