nomsu/core/io.nom

21 lines
711 B
Plaintext
Raw Normal View History

2018-06-14 22:17:26 -07:00
#
This file contains basic input/output code
use "core/metaprogramming.nom"
compile [say %message] to
lua> ".."
if \%message.type == "Text" then
2018-06-18 15:44:29 -07:00
return LuaCode(tree.source, "io.write(", \(%message as lua expr), ", '\\\\n');");
2018-06-14 22:17:26 -07:00
else
2018-06-18 15:44:29 -07:00
return LuaCode(tree.source, "io.write(tostring(", \(%message as lua expr), "), '\\\\n');");
2018-06-14 22:17:26 -07:00
end
compile [ask %prompt] to
lua> ".."
if \%prompt.type == "Text" then
2018-06-18 15:44:29 -07:00
return LuaCode.Value(tree.source, "(io.write(", \(%prompt as lua expr), ") and io.read())");
2018-06-14 22:17:26 -07:00
else
2018-06-18 15:44:29 -07:00
return LuaCode.Value(tree.source, "(io.write(tostring(", \(%prompt as lua expr), ")) and io.read())");
2018-06-14 22:17:26 -07:00
end