diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2018-11-02 15:17:48 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2018-11-02 15:17:49 -0700 |
| commit | 0f17c5eb9ac4660f2f969bd1e67af42713e45eac (patch) | |
| tree | 279ca7da2de0efe2f363684f3c84a540635f11a8 /nomsu.lua | |
| parent | acd9c2acd4688f2301b091daad910c04e402bd6a (diff) | |
| parent | dc41f30c73c9686685e3a4183c1213fb4ba55c90 (diff) | |
Merge branch 'master' into working
Diffstat (limited to 'nomsu.lua')
| -rw-r--r-- | nomsu.lua | 23 |
1 files changed, 10 insertions, 13 deletions
@@ -91,8 +91,6 @@ do local _obj_0 = require("code_obj") NomsuCode, LuaCode, Source = _obj_0.NomsuCode, _obj_0.LuaCode, _obj_0.Source end -local repr -repr = require("utils").repr if not arg or debug.getinfo(2).func == require then return NomsuCompiler end @@ -135,8 +133,7 @@ end local nomsu = NomsuCompiler nomsu.environment.arg = NomsuCompiler.environment._List(args.nomsu_args) if args.version then - nomsu:run([[use "core" -say (Nomsu version)]]) + nomsu:run([[(: use "core"; say (Nomsu version))]]) os.exit(EXIT_SUCCESS) end FILE_CACHE = setmetatable({ }, { @@ -185,11 +182,7 @@ run = function() return true end if not (args.no_core) then - for _, filename in Files.walk('core') do - if filename:match("%.nom$") then - nomsu:import(nomsu:run_file(filename)) - end - end + nomsu:import_file('core') end local get_file_and_source get_file_and_source = function(filename) @@ -282,8 +275,8 @@ run = function() if not (args.primary_file or args.exec_strings) then nomsu:run([[#!/usr/bin/env nomsu -V4 use "lib/consolecolor.nom" -action [quit, exit]: lua> "os.exit(0)" -action [help]: +[quit, exit] all mean: lua> "os.exit(0)" +(help) means: say "\ ..This is the Nomsu v\(Nomsu version) interactive console. You can type in Nomsu code here and hit 'enter' twice to run it. @@ -322,9 +315,13 @@ say "\ return Errhand.print_error(error_message) end local ret - ok, ret = xpcall(nomsu.run, err_hand, nomsu, buff, Source(pseudo_filename, 1, #buff)) + ok, ret = xpcall(nomsu.run, err_hand, nomsu, NomsuCode(Source(pseudo_filename, 1, #buff), buff)) if ok and ret ~= nil then - print("= " .. repr(ret)) + if type(ret) == 'number' then + print("= " .. tostring(ret)) + else + print("= " .. tostring(ret:as_nomsu())) + end elseif not ok then Errhand.print_error(ret) end |
