From 88473de76a643d10985618ebcc3ed176ee67a0b0 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Mon, 2 Jun 2014 15:46:02 +0100 Subject: [PATCH] elua: fixed up the xgettext lua lexer/parser/generator --- src/bin/elua/apps/xgettext.lua | 3 ++- src/bin/elua/modules/xgettext/generator.lua | 2 +- src/bin/elua/modules/xgettext/lexer.lua | 6 +++++- src/bin/elua/modules/xgettext/parser.lua | 3 ++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/bin/elua/apps/xgettext.lua b/src/bin/elua/apps/xgettext.lua index b08a8b8fdb..b85eb06ec3 100644 --- a/src/bin/elua/apps/xgettext.lua +++ b/src/bin/elua/apps/xgettext.lua @@ -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) diff --git a/src/bin/elua/modules/xgettext/generator.lua b/src/bin/elua/modules/xgettext/generator.lua index 97f41b58d6..c442e6d73f 100644 --- a/src/bin/elua/modules/xgettext/generator.lua +++ b/src/bin/elua/modules/xgettext/generator.lua @@ -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 } \ No newline at end of file diff --git a/src/bin/elua/modules/xgettext/lexer.lua b/src/bin/elua/modules/xgettext/lexer.lua index 2d66958e57..d980d7afdf 100644 --- a/src/bin/elua/modules/xgettext/lexer.lua +++ b/src/bin/elua/modules/xgettext/lexer.lua @@ -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 } \ No newline at end of file diff --git a/src/bin/elua/modules/xgettext/parser.lua b/src/bin/elua/modules/xgettext/parser.lua index 000d4448c9..5a3b0e2e6e 100644 --- a/src/bin/elua/modules/xgettext/parser.lua +++ b/src/bin/elua/modules/xgettext/parser.lua @@ -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 ~= "" do if tok.name == "" then saved_comment = tok.value ls:get()