177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
...
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
...
342
343
344
345
346
347
348
349
350
351
352
353
354
355
|
end
end
end
local function scanParents(doc)
for i, p in ipairs(doc.parents) do
-- TODO figure out a way to ref the embedding section
local o,i,s = checkFromSec(nil, p)
if o or s then return o,i,s end
end
-- breadth-first search
for i, p in ipairs(doc.parents) do
local o,i,s = scanParents(p)
if o or s then return o,i,s end
end
................................................................................
end
end
end
o,i,s = scanParents(self.doc)
if o or s then return o,i,s end
self:fail("ID ā%sā does not name an object or section", id)
end
};
}
ct.sec = declare {
ident = 'section';
mk = function() return {
................................................................................
-- sets up a doc/ctx pair for a subdocument embedded in the source
-- of a gretaer document, pointing subdoc props to global tables/values
local newdoc = ct.doc.mk(self)
newdoc.meta = self.meta
newdoc.ext = self.ext
newdoc.enc = self.enc
newdoc.stage = self.stage
-- vars are handled through proper recursion across all parents and
-- are intentionally excluded here; subdocs can have their own vars
-- without losing access to parent vars
local nctx = ctx:clone()
nctx:init(newdoc, ctx.src)
nctx.line = ctx.line
nctx.docDepth = (ctx.docDepth or 0) + ctx.sec.depth - 1
|
|
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
...
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
...
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
end
end
end
local function scanParents(doc)
for i, p in ipairs(doc.parents) do
-- TODO figure out a way to ref the embedding section
local o,i,s = checkFromSec(doc.defined_in_parent_section, p)
if o or s then return o,i,s end
end
-- breadth-first search
for i, p in ipairs(doc.parents) do
local o,i,s = scanParents(p)
if o or s then return o,i,s end
end
................................................................................
end
end
end
o,i,s = scanParents(self.doc)
if o or s then return o,i,s end
self:fail("ID ā%sā does not name an object or section %s", id, self.invocation or "NIL")
end
};
}
ct.sec = declare {
ident = 'section';
mk = function() return {
................................................................................
-- sets up a doc/ctx pair for a subdocument embedded in the source
-- of a gretaer document, pointing subdoc props to global tables/values
local newdoc = ct.doc.mk(self)
newdoc.meta = self.meta
newdoc.ext = self.ext
newdoc.enc = self.enc
newdoc.stage = self.stage
newdoc.defined_in_parent_section = ctx.sec
-- vars are handled through proper recursion across all parents and
-- are intentionally excluded here; subdocs can have their own vars
-- without losing access to parent vars
local nctx = ctx:clone()
nctx:init(newdoc, ctx.src)
nctx.line = ctx.line
nctx.docDepth = (ctx.docDepth or 0) + ctx.sec.depth - 1
|