@@ -161,12 +161,22 @@ if rid then return rid, id, sec end end + + for _, i in ipairs(sec.imports) do + local rr, ri, rs = checkFromSec(i, doc) + if ri then return rr, ri, rs end + end if doc.sections[id] then return nil, id, doc.sections[id] end + + for _, i in ipairs(doc.globals) do + local rr, ri, rs = checkFromSec(i, doc) + if ri then return rr, ri, rs end + end else local secid, ref = string.match(id, "(.-)%.(.+)") local s s = s or doc.sections[secid] @@ -224,8 +234,9 @@ ident = 'section'; mk = function() return { blocks = {}; refs = {}; + imports = {}; depth = 0; kind = 'ordinary'; } end; construct = function(self, id, depth) @@ -358,8 +369,9 @@ end; }; mk = function(...) return { sections = {}; + globals = {}; secorder = {}; embed = {}; meta = {}; vars = {}; @@ -1007,8 +1019,37 @@ keywords = dsetmeta; desc = dsetmeta; when = dcond; unless = dcond; + with = function(w,c) + local _,str = w(2) + local aka, name = str:match '^([^=])=(.*)$' + if aka == nil then name=str aka=name end + + local o,id,s = c:ref(name) + if o then -- import object + c.sec.import.objs[aka] = o + else -- import scope + table.insert(c.sec.import.scope, s) + end + end; + global = function(w,c) + local _,str = w(2) + if str ~= nil and str ~= '' then + local aka, name = str:match '^([^=])=(.*)$' + if aka == nil then name=str aka=name end + + local o,id,s = c:ref(name) + + if o then + c.doc.globals.objs[aka] = name + else + table.insert(c.doc.globals, s) + end + else + table.insert(c.doc.globals, c.sec) + end + end; pragma = function(w,c) end; lang = function(w,c) local _, op, l = w(2)