aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/io.nom12
-rw-r--r--nomsu_environment.lua2
-rw-r--r--nomsu_environment.moon2
-rw-r--r--tools/repl.nom11
4 files changed, 18 insertions, 9 deletions
diff --git a/core/io.nom b/core/io.nom
index d9dbdd3..c667466 100644
--- a/core/io.nom
+++ b/core/io.nom
@@ -9,9 +9,17 @@ use "core/metaprogramming.nom"
(say %message) compiles to:
lua> "\
..if \%message.type == "Text" then
- return LuaCode("print(", \(%message as lua expr), ");");
+ return LuaCode("say(", \(%message as lua expr), ");");
else
- return LuaCode("print(tostring(", \(%message as lua expr), "));");
+ 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), "))");
end"
(ask %prompt) compiles to:
diff --git a/nomsu_environment.lua b/nomsu_environment.lua
index 41f7cd6..4d2a95b 100644
--- a/nomsu_environment.lua
+++ b/nomsu_environment.lua
@@ -72,7 +72,7 @@ local nomsu_environment = Importer({
string = string,
xpcall = xpcall,
module = module,
- print = print,
+ say = print,
loadfile = loadfile,
rawset = rawset,
_VERSION = _VERSION,
diff --git a/nomsu_environment.moon b/nomsu_environment.moon
index 142abdb..1046004 100644
--- a/nomsu_environment.moon
+++ b/nomsu_environment.moon
@@ -38,7 +38,7 @@ nomsu_environment = Importer{
-- Lua stuff:
:next, unpack: unpack or table.unpack, :setmetatable, :coroutine, :rawequal, :getmetatable, :pcall,
:error, :package, :os, :require, :tonumber, :tostring, :string, :xpcall, :module,
- :print, :loadfile, :rawset, :_VERSION, :collectgarbage, :rawget, :rawlen,
+ say:print, :loadfile, :rawset, :_VERSION, :collectgarbage, :rawget, :rawlen,
:table, :assert, :dofile, :loadstring, lua_type_of:type, :select, :math, :io, :load,
:pairs, :ipairs, :jit, :_VERSION
bit: (jit or _VERSION == "Lua 5.2") and require('bitops') or nil
diff --git a/tools/repl.nom b/tools/repl.nom
index aeac324..daa39d0 100644
--- a/tools/repl.nom
+++ b/tools/repl.nom
@@ -21,18 +21,19 @@ say "\
"
repeat:
- %io.write (bright (yellow ">> "))
+ say (bright (yellow ">> ")) inline
%buff = []
repeat:
- %io.write (bright)
+ say (bright) inline
%line = (%io.read "*L")
- %io.write (reset color)
+ say (reset color) inline
if ((%line == "\n") or (not %line)):
if ((size of %buff) > 0):
- %io.write "\027[1A\027[2K"
+ # clear the line
+ say "\027[1A\027[2K" inline
go to (run buffer)
%buff::add (%line::with "\t" -> " ")
- %io.write (dim (yellow ".. "))
+ say (dim (yellow ".. ")) inline
=== (run buffer) ===
if ((size of %buff) == 0): stop
%buff = (%buff::joined)