2018-07-20 20:27:15 -07:00
|
|
|
#!/usr/bin/env nomsu -V2.5.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-20 20:27:15 -07:00
|
|
|
|
2018-07-17 23:08:13 -07:00
|
|
|
compile [with local %locals %body, with local %locals do %body] to:
|
2018-07-18 01:27:56 -07:00
|
|
|
%body_lua = (%body as lua statements)
|
2018-07-18 17:55:29 -07:00
|
|
|
if %locals.type is:
|
|
|
|
"Dict":
|
2018-07-18 01:27:56 -07:00
|
|
|
%body_lua = (..)
|
2018-07-20 20:27:15 -07:00
|
|
|
Lua ".."
|
|
|
|
\(compile as (<- %locals))
|
|
|
|
\%body_lua
|
2018-07-18 01:27:56 -07:00
|
|
|
|
2018-07-17 23:08:13 -07:00
|
|
|
declare locals ("\(%.1 as lua)" for % in %locals) in %body_lua
|
|
|
|
|
2018-07-20 20:27:15 -07:00
|
|
|
"List":
|
|
|
|
declare locals ("\(% as lua)" for % in %locals) in %body_lua
|
|
|
|
"Var" "Action":
|
|
|
|
declare locals ["\(%locals as lua)"] in %body_lua
|
|
|
|
else:
|
|
|
|
compile error at %locals.source "Unexpected locals: %s"
|
2018-07-17 23:08:13 -07:00
|
|
|
|
|
|
|
return (..)
|
2018-07-20 20:27:15 -07:00
|
|
|
Lua ".."
|
|
|
|
do
|
|
|
|
\%body_lua
|
2018-07-22 13:59:08 -07:00
|
|
|
end
|