aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2018-09-18 04:01:05 +0000
committers-ol <s-ol@users.noreply.github.com>2018-09-18 04:01:05 +0000
commit6b45dd8900c84531a5eba6de0837e0f84d619286 (patch)
treeff0d130a5f830e4d848469667ee2aa11da3b393e
parentcleanup (diff)
downloadmmm-6b45dd8900c84531a5eba6de0837e0f84d619286.tar.gz
mmm-6b45dd8900c84531a5eba6de0837e0f84d619286.zip
tape
-rw-r--r--app/html.client.moon5
-rw-r--r--app/html.server.moon5
-rw-r--r--app/realities.moon36
-rw-r--r--duct_tape.moon115
-rw-r--r--server.moon3
5 files changed, 144 insertions, 20 deletions
diff --git a/app/html.client.moon b/app/html.client.moon
index fdec714..77d6c51 100644
--- a/app/html.client.moon
+++ b/app/html.client.moon
@@ -28,8 +28,9 @@ element = (element) -> (...) ->
elements = {}
add = (e) -> elements[e] = element e
-for e in *{'div', 'span', 'a', 'p', 'pre', 'button', 'ul', 'li', 'i', 'b', 'u', 'tt'} do add e
-for e in *{'br', 'img', 'input', 'p'} do add e
+for e in *{'div', 'form', 'span', 'a', 'p', 'button', 'ul', 'ol', 'li', 'i', 'b', 'u', 'tt'} do add e
+for e in *{'article', 'section', 'header', 'footer', 'content'} do add e
+for e in *{'br', 'hr', 'img', 'input', 'p', 'textarea'} do add e
for i=1,8 do add "h" .. i
elements
diff --git a/app/html.server.moon b/app/html.server.moon
index 6bd05e1..3a27b37 100644
--- a/app/html.server.moon
+++ b/app/html.server.moon
@@ -29,8 +29,9 @@ element = (element) -> (...) ->
elements = {}
add = (e) -> elements[e] = element e
-for e in *{'div', 'span', 'a', 'p', 'pre', 'button', 'ul', 'li', 'i', 'b', 'u', 'tt'} do add e
-for e in *{'br', 'img', 'input', 'p'} do add e
+for e in *{'div', 'form', 'span', 'a', 'p', 'button', 'ul', 'ol', 'li', 'i', 'b', 'u', 'tt'} do add e
+for e in *{'article', 'section', 'header', 'footer', 'content'} do add e
+for e in *{'br', 'hr', 'img', 'input', 'p', 'textarea'} do add e
for i=1,8 do add "h" .. i
elements
diff --git a/app/realities.moon b/app/realities.moon
index b3c5020..244cd41 100644
--- a/app/realities.moon
+++ b/app/realities.moon
@@ -1,8 +1,11 @@
-import append, tohtml, h1, h2, p, a, i, div, ol, li, br, hr, span, button, section, article from require 'app.component'
+import append, h1, h2, p, a, i, div, ol, li, br, hr, span, button, section, article from require 'app.component'
local Diagram, o
GRID_W = 50
GRID_H = 40
+
+-- script https://cdnjs.cloudflare.com/ajax/libs/svg.js/2.6.6/svg.min.js
+
if MODE == 'CLIENT'
require 'svg.js'
eval = js.global\eval
@@ -189,32 +192,33 @@ append with article style: { margin: 'auto', 'max-width': '750px' }
\append with sect "Terminology"
\append p "We propose the following terms and definitions that will be used extensively for the remainder of the paper:"
- for term, definition in pairs {
- "layer of reality": "a closed system consisting of a world model and a set of rules or dynamics operating on and
- constraining said model.",
- "world model": "describes a world state containing objects, agents and/or concepts on an arbitrary abstraction level.",
- break: 1,
- "reality stack": "structure consisting of all layers of reality encoding an agent's interaction with his environment
- in their world model at a given moment, as well as all layers supporting these respectively."
- next: 2,
- "physical reality": "layer of reality defined by physical matter and the physical laws acting upon it.
+ for definition in *{
+ { "layer of reality": "a closed system consisting of a world model and a set of rules or dynamics operating on and
+ constraining said model." },
+ { "world model": "describes a world state containing objects, agents and/or concepts on an arbitrary abstraction level." },
+ '------',
+ { "reality stack": "structure consisting of all layers of reality encoding an agent's interaction with his environment
+ in their world model at a given moment, as well as all layers supporting these respectively." },
+ '------',
+ { "physical reality": "layer of reality defined by physical matter and the physical laws acting upon it.
While the emergent phenomena of micro- and macro physics as well as layers of social existence etc. may be seen
- as separate layers, for the purpose of this paper we will group these together under the term of physical reality."
- "mental reality": "layer of reality perceived and processed by the brain of a human agent.",
- "digital reality": "layer of reality created and simulated by a digital system, e.g. a virtual reality game."
- "phys, mind, digi": "abbreviations for physical, mental and digital reality respectively.",
+ as separate layers, for the purpose of this paper we will group these together under the term of physical reality." },
+ { "mental reality": "layer of reality perceived and processed by the brain of a human agent." },
+ { "digital reality": "layer of reality created and simulated by a digital system, e.g. a virtual reality game." },
+ { "phys, mind, digi": "abbreviations for physical, mental and digital reality respectively." },
}
- if 'number' == type definition
+ if 'string' == type definition
\append hr!
continue
\append with div style: { 'margin-left': '2rem' }
+ term = next definition
\append span term, style: {
display: 'inline-block',
'margin-left': '-2rem',
'font-weight': 'bold',
'min-width': '140px'
}
- \append span definition
+ \append span definition[term]
\append with sect "Introduction"
\append p "We identify two different types of relationships between layers in multi-reality environments.
diff --git a/duct_tape.moon b/duct_tape.moon
new file mode 100644
index 0000000..f6e2a84
--- /dev/null
+++ b/duct_tape.moon
@@ -0,0 +1,115 @@
+package.noompath = './?.noom;./?/init.noom'
+
+local *
+
+compile = require "moonscript.compile"
+parse = require "moonscript.parse"
+
+import smart_node, build from require "moonscript.types"
+import dirsep from require "moonscript.base"
+-- import split, get_options, unpack from require "moonscript.util"
+import get_options, unpack from require "moonscript.util"
+
+line_tables = require "moonscript.line_tables"
+lua = :loadstring, :load
+
+import p from require 'moon'
+
+matches = (chain) ->
+ return unless chain[1] == "chain"
+ ref, call = chain[2], chain[3]
+ return unless ref[1] == "ref" and call[1] == "call"
+ ref[2] == "COMPILE"
+
+transform_extract = (node) ->
+ { _, ref, call } = node
+ { _, call_args } = call
+ fndef = smart_node call_args[1]
+
+ if #fndef.whitelist > 1
+ return 'cannot COMPILE function with whitelist!'
+
+ code, ltable, pos = compile.tree { fndef }
+ if not code
+ return compile.format_error(ltable, pos, text)
+
+ node[1] = "string"
+ node[2] = "'"
+ node[3] = code
+ node[-1] = nil
+ nil
+
+transform_extracts = (node) ->
+ if matches node
+ transform_extract node
+ else
+ err = nil
+ for v in *node
+ err or= transform_extracts v if 'table' == type v
+ err
+
+to_lua = (text, options={}) ->
+ if "string" != type text
+ t = type text
+ return nil, "expecting string (got ".. t ..")"
+
+ tree, err = parse.string text
+ if not tree
+ return nil, err
+
+ err = transform_extracts tree
+ if err
+ return nil, err
+
+ code, ltable, pos = compile.tree tree, options
+ if not code
+ return nil, compile.format_error(ltable, pos, text)
+
+ code, ltable
+
+noom_loader = (name) ->
+ name_path = name\gsub "%.", dirsep
+
+ local file, file_path
+ for path in package.noompath\gmatch "[^;]+"
+ file_path = path\gsub "?", name_path
+ file = io.open file_path
+ break if file
+
+ if file
+ text = file\read "*a"
+ file\close!
+ res, err = loadstring text, "@#{file_path}"
+ if not res
+ error file_path .. ": " .. err
+
+ return res
+
+ return nil, "Could not find noom file"
+
+loadstring = (...) ->
+ options, str, chunk_name, mode, env = get_options ...
+ chunk_name or= "=(noom.loadstring)"
+
+ code, ltable_or_err = to_lua str, options
+ unless code
+ return nil, ltable_or_err
+
+ line_tables[chunk_name] = ltable_or_err if chunk_name
+ -- the unpack prevents us from passing nil
+ (lua.loadstring or lua.load) code, chunk_name, unpack { mode, env }
+
+insert_loader = (pos=2) ->
+ -- if not package.moonpath
+ -- package.moonpath = create_moonpath package.path
+
+ loaders = package.loaders or package.searchers
+ for loader in *loaders
+ return false if loader == noom_loader
+
+ table.insert loaders, pos, noom_loader
+ true
+
+{
+ :insert_loader
+}
diff --git a/server.moon b/server.moon
index 5a79039..0253faf 100644
--- a/server.moon
+++ b/server.moon
@@ -1,5 +1,8 @@
package.moonpath = './?.server.moon;' .. package.moonpath
+import insert_loader from require 'duct_tape'
+insert_loader!
+
export MODE, warn, append
MODE = 'SERVER'
warn = (...) ->