From e8e389b9ddebe6ced19d5f4bc112b309ffe1a8ff Mon Sep 17 00:00:00 2001 From: Andre Murbach Maidl Date: Wed, 7 Oct 2015 15:17:08 -0300 Subject: Adding some missing annotations due to MAXLABELS limitation to 32 labels --- examples/typedlua/test.lua | 8 ++++---- examples/typedlua/tlerror.lua | 3 +++ examples/typedlua/tlparser.lua | 6 +++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/examples/typedlua/test.lua b/examples/typedlua/test.lua index 3b99e5c..ffdbd70 100755 --- a/examples/typedlua/test.lua +++ b/examples/typedlua/test.lua @@ -1828,7 +1828,7 @@ for k;v in pairs(t) do end test.lua:1:6: syntax error, unexpected ';', expecting 'in', ',', ':', '=' ]=] e = [=[ -test.lua:1:6: unexpected ';', expecting 'in', ',', ':', '=' +test.lua:1:6: expecting 'in' ]=] r, m = parse(s) @@ -1910,7 +1910,7 @@ function a.b:c:d () end test.lua:1:15: syntax error, unexpected ':', expecting '(' ]=] e = [=[ -test.lua:1:15: unexpected ':', expecting '(' +test.lua:1:15: missing '(' ]=] r, m = parse(s) @@ -2030,7 +2030,7 @@ local function t.a() end test.lua:1:17: syntax error, unexpected '.', expecting '(' ]=] e = [=[ -test.lua:1:17: unexpected '.', expecting '(' +test.lua:1:17: missing '(' ]=] r, m = parse(s) @@ -2069,7 +2069,7 @@ local function (a, b, c, ...) end test.lua:1:16: syntax error, unexpected '(', expecting 'Name' ]=] e = [=[ -test.lua:1:16: unexpected '(', expecting 'Name' +test.lua:1:16: expecting in local function declaration ]=] r, m = parse(s) diff --git a/examples/typedlua/tlerror.lua b/examples/typedlua/tlerror.lua index fe3a72e..6881b6b 100644 --- a/examples/typedlua/tlerror.lua +++ b/examples/typedlua/tlerror.lua @@ -8,6 +8,7 @@ new_error("Number", "malformed ") new_error("String", "malformed ") new_error("LongString", "unfinished long string") new_error("LongComment", "unfinished long comment") +new_error("MissingOP", "missing '('") new_error("MissingCP", "missing ')'") new_error("MissingCC", "missing '}'") new_error("MissingCB", "missing ']'") @@ -35,6 +36,8 @@ new_error("MethodCall", "expecting '(' for method call") new_error("Label1", "expecting after '::'") new_error("Label2", "expecting '::' to close label declaration") new_error("LocalAssign", "expecting expression list after '='") +new_error("ForGen", "expecting 'in'") +new_error("LocalFunc", "expecting in local function declaration") local labels = {} for k, v in ipairs(errors) do diff --git a/examples/typedlua/tlparser.lua b/examples/typedlua/tlparser.lua index c8d03ea..2180812 100644 --- a/examples/typedlua/tlparser.lua +++ b/examples/typedlua/tlparser.lua @@ -161,7 +161,7 @@ local G = lpeg.P { "TypedLua"; ForNum = lpeg.V("Id") * tllexer.symb("=") * lpeg.V("Expr") * tllexer.symb(",") * lpeg.V("Expr") * (tllexer.symb(",") * lpeg.V("Expr"))^-1 * lpeg.V("ForBody"); - ForGen = lpeg.V("NameList") * tllexer.kw("in") * + ForGen = lpeg.V("NameList") * tllexer.try(tllexer.kw("in"), "ForGen") * lpeg.V("ExpList") * lpeg.V("ForBody"); ForStat = tllexer.kw("for") * (lpeg.V("ForNum") + lpeg.V("ForGen")) * tllexer.try(tllexer.kw("end"), "ForEnd"); RepeatStat = tllexer.kw("repeat") * lpeg.V("Block") * @@ -172,13 +172,13 @@ local G = lpeg.P { "TypedLua"; ParList = lpeg.V("NameList") * (tllexer.symb(",") * tllexer.try(lpeg.V("TypedVarArg"), "ParList"))^-1 + lpeg.V("TypedVarArg"); TypedVarArg = tllexer.symb("...") * (tllexer.symb(":") * tllexer.try(lpeg.V("Type"), "Type"))^-1; - FuncBody = tllexer.symb("(") * lpeg.V("ParList")^-1 * tllexer.try(tllexer.symb(")"), "MissingCP") * + FuncBody = tllexer.try(tllexer.symb("("), "MissingOP") * lpeg.V("ParList")^-1 * tllexer.try(tllexer.symb(")"), "MissingCP") * (tllexer.symb(":") * tllexer.try(lpeg.V("RetType"), "Type"))^-1 * lpeg.V("Block") * tllexer.try(tllexer.kw("end"), "FuncEnd"); FuncStat = tllexer.kw("const")^-1 * tllexer.kw("function") * lpeg.V("FuncName") * lpeg.V("FuncBody"); LocalFunc = tllexer.kw("function") * - lpeg.V("Id") * lpeg.V("FuncBody"); + tllexer.try(lpeg.V("Id"), "LocalFunc") * lpeg.V("FuncBody"); LocalAssign = lpeg.V("NameList") * ((tllexer.symb("=") * tllexer.try(lpeg.V("ExpList"), "LocalAssign")))^-1; LocalStat = tllexer.kw("local") * -- cgit v1.2.3-55-g6feb