From 2751039739e5357beb8e858a25e21e2bc0344fe8 Mon Sep 17 00:00:00 2001 From: SoniEx2 Date: Fri, 7 Jun 2024 12:05:21 -0300 Subject: Fix strange misplaced semicolon issue FIXME: rewrite the compiler, properly --- src/cratera/compiler.lua | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/cratera/compiler.lua b/src/cratera/compiler.lua index cb0681f..6b188ef 100644 --- a/src/cratera/compiler.lua +++ b/src/cratera/compiler.lua @@ -169,7 +169,9 @@ defs[parser.FALLBACK] = function(state, token) -- keep going i = i - 3 elseif results[i-2] == TK.FUNCTION then -- we're in funcname - find_statement = false -- don't even bother with : handling + -- funcname is of the form Name {'.' Name} ':' + -- TODO how can we parse 'function Foo:[Bar].Baz()'... + find_statement = false break else -- found start of statement @@ -381,19 +383,17 @@ defs[parser.FALLBACK] = function(state, token) results.n = results.n + 1 end -- inject cratera - table.insert(results, pos, ')') table.insert(results, pos, CRATERA_FUNCTION) - table.insert(results, pos, '(') -- check for potential prefixexp and correct for it - if is_tk(results, pos-1, ']') or - is_tk(results, pos-1, '}') or - is_tk(results, pos-1, ')') or - results[pos-2] == TK.NAME or - results[pos-2] == TK.STRING then - table.insert(results, pos, ';') - results.n = results.n + 1 - end - results.n = results.n + 3 + --if is_tk(results, pos-1, ']') or + -- is_tk(results, pos-1, '}') or + -- is_tk(results, pos-1, ')') or + -- results[pos-2] == TK.NAME or + -- results[pos-2] == TK.STRING then + -- table.insert(results, pos, ' ') + -- results.n = results.n + 1 + --end + results.n = results.n + 1 -- tag it so we know to insert a ')' to close our '(' -- and to handle '(' ')' (no argument) calls -- we add the tag before TK.STRING/'{'/',' -- cgit 1.4.1