elua: never actually fail parsing (keep error messages for debug, hidden by default)

This commit is contained in:
Daniel Kolesa 2014-06-03 16:35:20 +01:00
parent 9c3f65640c
commit 2d5806294a
1 changed files with 26 additions and 24 deletions

View File

@ -111,30 +111,32 @@ local parse = function(ls, keywords)
local line = ls.line_number local line = ls.line_number
local kw = keywords[tok.value] local kw = keywords[tok.value]
ls:get() ls:get()
local args = parse_call(ls) local status, args = pcall(parse_call, ls)
local n1, n2, cx, an = kw[1], kw[2], kw.context, kw.argnum if status then
local n1arg, n2arg, cxarg = args[n1], args[n2], args[cx] local n1, n2, cx, an = kw[1], kw[2], kw.context, kw.argnum
local n1argt, n2argt, cxargt = n1arg and (n1arg[2] ~= "<name>"), local n1arg, n2arg, cxarg = args[n1], args[n2], args[cx]
n2arg and (n2arg[2] ~= "<name>"), local n1argt, n2argt, cxargt = n1arg and (n1arg[2] ~= "<name>"),
cxarg and (cxarg[2] ~= "<name>") n2arg and (n2arg[2] ~= "<name>"),
if not args then goto skip end cxarg and (cxarg[2] ~= "<name>")
if an and #args ~= an then goto skip end if not args then goto skip end
if #args < n1 then goto skip end if an and #args ~= an then goto skip end
if n2 and #args < n2 then goto skip end if #args < n1 then goto skip end
if cx and #args < cx then goto skip end if n2 and #args < n2 then goto skip end
if not n1argt then goto skip end if cx and #args < cx then goto skip end
if n2 and not n2argt then goto skip end if not n1argt then goto skip end
if cx and not cxargt then goto skip end if n2 and not n2argt then goto skip end
local sc = saved_comments if cx and not cxargt then goto skip end
saved_comments = {} local sc = saved_comments
sc = tconc(sc, "\n") saved_comments = {}
local fsc = saved_flagcomments sc = tconc(sc, "\n")
saved_flagcomments = {} local fsc = saved_flagcomments
yield { saved_flagcomments = {}
n1arg[1], n2 and n2arg[1], context = cx and cxarg[1], yield {
xcomment = kw.xcomment, comment = sc, line = line, n1arg[1], n2 and n2arg[1], context = cx and cxarg[1],
flags = fsc xcomment = kw.xcomment, comment = sc, line = line,
} flags = fsc
}
end
else else
ls:get() ls:get()
end end