if tb == "string" then seq.tag = builder\r
elseif tb == "function" or builder and builder.__call then seq = builder(seq)\r
elseif builder == nil then -- nothing\r
- else error("Invalid builder of type "..tb.." in sequence") end\r
+ else error ("Invalid builder of type "..tb.." in sequence") end\r
seq = transform (seq, self, fli, lli)\r
+ assert (not seq or seq.lineinfo)\r
return seq\r
end\r
\r
-- [gg.onkeyword] parser is the result of the subparser (modulo\r
-- [transformers] applications).\r
--\r
+-- lineinfo: the keyword is *not* included in the boundaries of the\r
+-- resulting lineinfo. A review of all usages of gg.onkeyword() in the\r
+-- implementation of metalua has shown that it was the appropriate choice\r
+-- in every case.\r
+--\r
-- Input fields:\r
--\r
-- * [name]: as usual\r
-------------------------------------------------------------------\r
function p:parse(lx)\r
if lx:is_keyword (lx:peek(), unpack(self.keywords)) then\r
- local fli = lx:lineinfo_right()\r
+ --local fli = lx:lineinfo_right()\r
if not self.peek then lx:next() end\r
- local lli = lx:lineinfo_left()\r
- return transform (self.primary(lx), p, fli, lli)\r
+ local content = self.primary (lx)\r
+ --local lli = lx:lineinfo_left()\r
+ local fli, lli = content.lineinfo.first, content.lineinfo.last\r
+ return transform (content, p, fli, lli)\r
else return false end\r
end\r
\r
local lambda_expr = gg.sequence{
"|", func_params_content, "|", expr,
builder= function (x)
- return {tag="Function", x[1], { {tag="Return", x[2] } } } end }
+ local li = x[2].lineinfo
+ return { tag="Function", x[1],
+ { {tag="Return", x[2], lineinfo=li }, lineinfo=li } }
+ end }
-- In an earlier version, lambda_expr took an expr_list rather than an expr
-- after the 2nd bar. However, it happened to be much more of a burden than an