elua: initial work on parser part of the extractor

This commit is contained in:
Daniel Kolesa 2014-05-22 14:12:09 +01:00
parent 3f4fd784c2
commit 00bec70b69
1 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,28 @@
-- Elua xgettext: parser
local lexer = require("xgettext.lexer")
local yield = coroutine.yield
local saved_comments = {}
local parse = function(ls, keywords)
yield()
local tok = ls.token
while tok.name do
if tok.name == "<comment>" then
saved_comments[#saved_comments + 1] = tok.value
ls:get()
elseif tok.name == "<name>" and keywords[tok.value] then
local cmt = saved_comments[#saved_comments]
saved_comments = {}
else
ls:get()
end
end
end
return { init = function (chunkname, input, keywords)
local ls = lexer.init(chunkname, input)
ls:get()
end }