aboutsummaryrefslogtreecommitdiff
path: root/nomsu_environment.moon
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-03-09 15:59:20 -0800
committerBruce Hill <bruce@bruce-hill.com>2019-03-09 15:59:41 -0800
commitc6734d82e99166fc55e44ab03a476889f1a14e9e (patch)
treeadf517b0f11613a0208b21da3d293aed0adb422e /nomsu_environment.moon
parent08fe139a4aa97325004d4b9847ce3a2ca545eced (diff)
Passing around DictEntry and changing API to _1_as_an_iterable
Diffstat (limited to 'nomsu_environment.moon')
-rw-r--r--nomsu_environment.moon13
1 files changed, 7 insertions, 6 deletions
diff --git a/nomsu_environment.moon b/nomsu_environment.moon
index 7066be1..4aa23f9 100644
--- a/nomsu_environment.moon
+++ b/nomsu_environment.moon
@@ -1,7 +1,7 @@
-- This file defines the environment in which Nomsu code runs, including some
-- basic bootstrapping functionality.
{:NomsuCode, :LuaCode, :Source} = require "code_obj"
-{:List, :Dict} = require 'containers'
+{:List, :Dict, :DictEntries} = require 'containers'
Text = require 'text'
SyntaxTree = require "syntax_tree"
Files = require "files"
@@ -44,9 +44,10 @@ _1_as_text = (x)->
if x == false then return "no"
return tostring(x)
-_1_as_list = (x)->
- mt = getmetatable(x)
- if mt.as_list then return mt.as_list(x)
+_1_as_an_iterable = (x)->
+ if mt = getmetatable(x)
+ if mt.as_iterable
+ return mt.as_iterable(x)
return x
local nomsu_environment
@@ -61,7 +62,7 @@ nomsu_environment = Importer{
:pairs, :ipairs, :jit, :_VERSION, LUA_VERSION: (jit and jit.version or _VERSION),
LUA_API: _VERSION, Bit: (jit or _VERSION == "Lua 5.2") and require('bitops') or nil
-- Nomsu types:
- a_List:List, a_Dict:Dict, Text:Text,
+ a_List:List, a_Dict:Dict, Text:Text, Dict_Entries:DictEntries,
-- Utilities and misc.
lpeg:lpeg, re:re, Files:Files,
:SyntaxTree, TESTS: Dict({}), globals: Dict({}),
@@ -74,7 +75,7 @@ nomsu_environment = Importer{
-- Nomsu functions:
_1_as_nomsu:tree_to_nomsu, _1_as_inline_nomsu:tree_to_inline_nomsu,
- compile: compile, at_1_fail:fail_at, :_1_as_text, :_1_as_list,
+ compile: compile, at_1_fail:fail_at, :_1_as_text, :_1_as_an_iterable,
exit:os.exit, quit:os.exit,
_1_parsed: (nomsu_code, syntax_version)->