elua: fixed up the xgettext lua lexer/parser/generator

This commit is contained in:
Daniel Kolesa 2014-06-02 15:46:02 +01:00
parent be3e046865
commit 88473de76a
4 changed files with 10 additions and 4 deletions

View File

@ -285,7 +285,7 @@ for i = 1, #keywords do
-- all sanitized, store :)
keywords[kwb] = { context = context, argnum = tonumber(argnum),
xcomment = xcmt, tonumber(n1), tonumber(n2) }
xcomment = xcmt, tonumber(n1) or 1, tonumber(n2) }
keywords[i] = nil
end
@ -379,6 +379,7 @@ for i, fname in ipairs(input_files) do
local f = io.open(fpath, "r")
fcontents = f:read("*all")
f:close()
fpath = "@" .. fpath
end
parsed_files[#parsed_files + 1] = generator.init(fpath, fcontents,
keywords, flags, add_loc, opts)

View File

@ -64,6 +64,7 @@ local gen_grouped_messages = function(ps)
end
msg = ps()
end
return ret
end
local gen_line_info = function(chunkname, lines)
@ -112,7 +113,6 @@ return { init = function(chunkname, input, keywords, flags, add_loc, opts)
ret[#ret + 1] = "msgstr " .. gen_msgstr(msg[1], spf, ssf)
end
rets[#rets + 1] = tconc(ret, "\n")
msg = ps()
end
return tconc(rets, "\n\n")
end }

View File

@ -3,6 +3,10 @@
local yield = coroutine.yield
local tconc = table.concat
local max_custom_len = 79
local max_fname_len = 72
local max_str_len = 63
local source_to_msg = function(source)
local c = source:sub(1, 1)
local srclen = #source
@ -302,5 +306,5 @@ return { init = function(chunkname, input, opts)
local coro = coroutine.wrap(lex_main, ls)
ls.coro = coro
coro(ls)
return coro
return ls
end, syntax_error = syntax_error, source_to_msg = source_to_msg }

View File

@ -70,6 +70,7 @@ local parse_arglist = function(ls)
break
end
end
return rets
end
local parse_call = function(ls)
@ -97,7 +98,7 @@ end
local parse = function(ls, keywords)
yield()
local tok = ls.token
while tok.name do
while tok.name ~= "<eof>" do
if tok.name == "<comment>" then
saved_comment = tok.value
ls:get()