elua: line information in the generated output
This commit is contained in:
parent
a0b8f72ae9
commit
7cf6a8abb0
|
@ -1,5 +1,6 @@
|
||||||
-- Elua xgettext: generator
|
-- Elua xgettext: generator
|
||||||
|
|
||||||
|
local lexer = require("xgettext.lexer")
|
||||||
local parser = require("xgettext.parser")
|
local parser = require("xgettext.parser")
|
||||||
|
|
||||||
local gen_comment = function(cmt)
|
local gen_comment = function(cmt)
|
||||||
|
@ -45,6 +46,8 @@ return { init = function(chunkname, input, keywords, flags, opts)
|
||||||
if msg.context then
|
if msg.context then
|
||||||
ret[#ret + 1] = "msgctxt " .. gen_message(msg.context)
|
ret[#ret + 1] = "msgctxt " .. gen_message(msg.context)
|
||||||
end
|
end
|
||||||
|
ret[#ret + 1] = "#: " .. lexer.source_to_msg(chunkname)
|
||||||
|
.. ":" .. msg.line
|
||||||
ret[#ret + 1] = "msgid " .. gen_message(msg[1])
|
ret[#ret + 1] = "msgid " .. gen_message(msg[1])
|
||||||
local spf, ssf = opts["m"], opts["M"]
|
local spf, ssf = opts["m"], opts["M"]
|
||||||
if msg[2] then
|
if msg[2] then
|
||||||
|
|
|
@ -303,4 +303,4 @@ return { init = function(chunkname, input, opts)
|
||||||
ls.coro = coro
|
ls.coro = coro
|
||||||
coro(ls)
|
coro(ls)
|
||||||
return coro
|
return coro
|
||||||
end, syntax_error = syntax_error }
|
end, syntax_error = syntax_error, source_to_msg = source_to_msg }
|
|
@ -102,7 +102,8 @@ local parse = function(ls, keywords)
|
||||||
saved_comment = tok.value
|
saved_comment = tok.value
|
||||||
ls:get()
|
ls:get()
|
||||||
elseif tok.name == "<name>" and keywords[tok.value] then
|
elseif tok.name == "<name>" and keywords[tok.value] then
|
||||||
local kw = keywords[tok.value]
|
local line = ls.line_number
|
||||||
|
local kw = keywords[tok.value]
|
||||||
ls:get()
|
ls:get()
|
||||||
local args = parse_call(ls)
|
local args = parse_call(ls)
|
||||||
local n1, n2, cx, an = kw[1], kw[2], kw.context, kw.argnum
|
local n1, n2, cx, an = kw[1], kw[2], kw.context, kw.argnum
|
||||||
|
@ -122,7 +123,7 @@ local parse = function(ls, keywords)
|
||||||
saved_comment = nil
|
saved_comment = nil
|
||||||
yield {
|
yield {
|
||||||
n1arg[1], n2 and n2arg[1], context = cx and cxarg[1],
|
n1arg[1], n2 and n2arg[1], context = cx and cxarg[1],
|
||||||
xcomment = kw.xcomment, comment = sc
|
xcomment = kw.xcomment, comment = sc, line = line
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ls:get()
|
ls:get()
|
||||||
|
|
Loading…
Reference in New Issue