diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2012-05-13 16:51:31 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2012-05-13 16:51:31 +0100 |
commit | 10f2830af49de42970bd738c03cf444675fc9e0d (patch) | |
tree | 4118f40e60f4f5f76c62171ab8f411e87632ae6f | |
parent | 7ce9834646fa91b4abf92f50f86e08d90220e013 (diff) | |
download | lace-10f2830af49de42970bd738c03cf444675fc9e0d.tar.gz |
Add end position to tokens and fix lex_a_file
-rw-r--r-- | lib/lace/lex.lua | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/lace/lex.lua b/lib/lace/lex.lua index 07277a5..6210a36 100644 --- a/lib/lace/lex.lua +++ b/lib/lace/lex.lua @@ -54,7 +54,7 @@ local function lex_one_line(line) elseif c == " " or c == "\t" then -- A space (or tab) and not quoting, so clear the accumulator if acc ~= "" then - r[#r+1] = { spos, acc, pos = spos, str = acc } + r[#r+1] = { spos = spos, epos = cpos - 1, str = acc } spos = cpos + 1 elseif cpos == spos then -- Increment the start position since we've not found a word yet @@ -67,7 +67,7 @@ local function lex_one_line(line) end end if acc ~= "" then - r[#r+1] = { spos, acc, pos = spos, str = acc } + r[#r+1] = { spos = spos, epos = cpos, str = acc } end local warnings = {} @@ -77,9 +77,6 @@ local function lex_one_line(line) if escaping then warnings[#warnings+1] = "Un-used escape at end" end - if #r == 0 then - warnings[#warnings+1] = "No command found?" - end return r, warnings end @@ -120,7 +117,7 @@ local function lex_a_file(filename) end local ruleset = fh:read("*a") fh:close() - return lex_a_string(ruleset, "@" .. filename) + return lex_a_ruleset(ruleset, "@" .. filename) end return { |