elua: fixed up the xgettext lua lexer/parser/generator
This commit is contained in:
parent
be3e046865
commit
88473de76a
|
@ -285,7 +285,7 @@ for i = 1, #keywords do
|
||||||
|
|
||||||
-- all sanitized, store :)
|
-- all sanitized, store :)
|
||||||
keywords[kwb] = { context = context, argnum = tonumber(argnum),
|
keywords[kwb] = { context = context, argnum = tonumber(argnum),
|
||||||
xcomment = xcmt, tonumber(n1), tonumber(n2) }
|
xcomment = xcmt, tonumber(n1) or 1, tonumber(n2) }
|
||||||
keywords[i] = nil
|
keywords[i] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -379,6 +379,7 @@ for i, fname in ipairs(input_files) do
|
||||||
local f = io.open(fpath, "r")
|
local f = io.open(fpath, "r")
|
||||||
fcontents = f:read("*all")
|
fcontents = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
fpath = "@" .. fpath
|
||||||
end
|
end
|
||||||
parsed_files[#parsed_files + 1] = generator.init(fpath, fcontents,
|
parsed_files[#parsed_files + 1] = generator.init(fpath, fcontents,
|
||||||
keywords, flags, add_loc, opts)
|
keywords, flags, add_loc, opts)
|
||||||
|
|
|
@ -64,6 +64,7 @@ local gen_grouped_messages = function(ps)
|
||||||
end
|
end
|
||||||
msg = ps()
|
msg = ps()
|
||||||
end
|
end
|
||||||
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
local gen_line_info = function(chunkname, lines)
|
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)
|
ret[#ret + 1] = "msgstr " .. gen_msgstr(msg[1], spf, ssf)
|
||||||
end
|
end
|
||||||
rets[#rets + 1] = tconc(ret, "\n")
|
rets[#rets + 1] = tconc(ret, "\n")
|
||||||
msg = ps()
|
|
||||||
end
|
end
|
||||||
return tconc(rets, "\n\n")
|
return tconc(rets, "\n\n")
|
||||||
end }
|
end }
|
|
@ -3,6 +3,10 @@
|
||||||
local yield = coroutine.yield
|
local yield = coroutine.yield
|
||||||
local tconc = table.concat
|
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 source_to_msg = function(source)
|
||||||
local c = source:sub(1, 1)
|
local c = source:sub(1, 1)
|
||||||
local srclen = #source
|
local srclen = #source
|
||||||
|
@ -302,5 +306,5 @@ return { init = function(chunkname, input, opts)
|
||||||
local coro = coroutine.wrap(lex_main, ls)
|
local coro = coroutine.wrap(lex_main, ls)
|
||||||
ls.coro = coro
|
ls.coro = coro
|
||||||
coro(ls)
|
coro(ls)
|
||||||
return coro
|
return ls
|
||||||
end, syntax_error = syntax_error, source_to_msg = source_to_msg }
|
end, syntax_error = syntax_error, source_to_msg = source_to_msg }
|
|
@ -70,6 +70,7 @@ local parse_arglist = function(ls)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return rets
|
||||||
end
|
end
|
||||||
|
|
||||||
local parse_call = function(ls)
|
local parse_call = function(ls)
|
||||||
|
@ -97,7 +98,7 @@ end
|
||||||
local parse = function(ls, keywords)
|
local parse = function(ls, keywords)
|
||||||
yield()
|
yield()
|
||||||
local tok = ls.token
|
local tok = ls.token
|
||||||
while tok.name do
|
while tok.name ~= "<eof>" do
|
||||||
if tok.name == "<comment>" then
|
if tok.name == "<comment>" then
|
||||||
saved_comment = tok.value
|
saved_comment = tok.value
|
||||||
ls:get()
|
ls:get()
|
||||||
|
|
Loading…
Reference in New Issue