elua: fixed up the xgettext lua lexer/parser/generator
authorDaniel Kolesa <d.kolesa@samsung.com>
Mon, 2 Jun 2014 14:46:02 +0000 (15:46 +0100)
committerDaniel Kolesa <d.kolesa@samsung.com>
Tue, 10 Jun 2014 14:48:52 +0000 (15:48 +0100)
src/bin/elua/apps/xgettext.lua
src/bin/elua/modules/xgettext/generator.lua
src/bin/elua/modules/xgettext/lexer.lua
src/bin/elua/modules/xgettext/parser.lua

index b08a8b8..b85eb06 100644 (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)
index 97f41b5..c442e6d 100644 (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 }
\ No newline at end of file
index 2d66958..d980d7a 100644 (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 }
\ No newline at end of file
index 000d444..5a3b0e2 100644 (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()