nomsu/core/io.nom

32 lines
1013 B
Plaintext
Raw Normal View History

#!/usr/bin/env nomsu -V4.10.12.7
2018-06-14 22:17:26 -07:00
#
This file contains basic input/output code
2018-06-14 22:17:26 -07:00
use "core/metaprogramming.nom"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(say %message) compiles to:
2018-09-14 19:17:09 -07:00
lua> "\
..if \%message.type == "Text" then
return LuaCode("say(", \(%message as lua expr), ");");
2018-06-14 22:17:26 -07:00
else
return LuaCode("say(tostring(", \(%message as lua expr), "));");
end"
(say %message inline) compiles to:
lua> "\
..if \%message.type == "Text" then
return LuaCode("io.write(", \(%message as lua expr), ")");
else
return LuaCode("io.write(tostring(", \(%message as lua expr), "))");
2018-09-14 19:17:09 -07:00
end"
2018-06-14 22:17:26 -07:00
(ask %prompt) compiles to:
2018-09-14 19:17:09 -07:00
lua> "\
..if \%prompt.type == "Text" then
return LuaCode("(io.write(", \(%prompt as lua expr), ") and io.read())");
2018-06-14 22:17:26 -07:00
else
return LuaCode("(io.write(tostring(", \(%prompt as lua expr), ")) and io.read())");
2018-09-14 19:17:09 -07:00
end"