2018-07-17 23:08:13 -07:00
|
|
|
#!/usr/bin/env nomsu -V2.2.4.3
|
2018-07-15 19:41:22 -07:00
|
|
|
#
|
|
|
|
This file contains definitions pertaining to variable scoping
|
|
|
|
|
2018-05-10 22:51:08 -07:00
|
|
|
use "core/metaprogramming.nom"
|
|
|
|
use "core/operators.nom"
|
|
|
|
use "core/collections.nom"
|
|
|
|
use "core/control_flow.nom"
|
2018-07-17 23:08:13 -07:00
|
|
|
compile [with local %locals %body, with local %locals do %body] to:
|
2018-06-14 23:25:05 -07:00
|
|
|
%body_lua <- (%body as lua statements)
|
2018-07-17 23:08:13 -07:00
|
|
|
when %locals.type = ?:
|
|
|
|
* "Dict":
|
|
|
|
%body_lua <- (Lua "\(compile as (<- %locals))\n\%body_lua")
|
|
|
|
declare locals ("\(%.1 as lua)" for % in %locals) in %body_lua
|
|
|
|
|
|
|
|
* "List":
|
|
|
|
declare locals ("\(% as lua)" for % in %locals) in %body_lua
|
2018-06-14 23:25:05 -07:00
|
|
|
* "Var"
|
2018-07-17 23:08:13 -07:00
|
|
|
* "Action":
|
2018-06-21 19:12:59 -07:00
|
|
|
declare locals ["\(%locals as lua)"] in %body_lua
|
2018-07-17 23:08:13 -07:00
|
|
|
*else (barf "Unexpected local: \(%locals as nomsu)")
|
|
|
|
|
|
|
|
return (..)
|
2018-05-10 22:51:08 -07:00
|
|
|
Lua ".."
|
|
|
|
do
|
|
|
|
\%body_lua
|
|
|
|
end
|