aboutsummaryrefslogtreecommitdiff
path: root/examples/typedlua/tlparser.lua
diff options
context:
space:
mode:
Diffstat (limited to 'examples/typedlua/tlparser.lua')
-rw-r--r--examples/typedlua/tlparser.lua8
1 files changed, 4 insertions, 4 deletions
diff --git a/examples/typedlua/tlparser.lua b/examples/typedlua/tlparser.lua
index 67a06a4..dba94f7 100644
--- a/examples/typedlua/tlparser.lua
+++ b/examples/typedlua/tlparser.lua
@@ -11,7 +11,7 @@ local function chainl1 (pat, sep, label)
11end 11end
12 12
13local G = lpeg.P { "TypedLua"; 13local G = lpeg.P { "TypedLua";
14 TypedLua = tllexer.Shebang^-1 * tllexer.Skip * lpeg.V("Chunk") * -1; 14 TypedLua = tllexer.Shebang^-1 * tllexer.Skip * lpeg.V("Chunk") * tllexer.try(-1, "Stat");
15 -- type language 15 -- type language
16 Type = lpeg.V("NilableType"); 16 Type = lpeg.V("NilableType");
17 NilableType = lpeg.V("UnionType") * tllexer.symb("?")^-1; 17 NilableType = lpeg.V("UnionType") * tllexer.symb("?")^-1;
@@ -179,14 +179,14 @@ local G = lpeg.P { "TypedLua";
179 tllexer.kw("function") * lpeg.V("FuncName") * lpeg.V("FuncBody"); 179 tllexer.kw("function") * lpeg.V("FuncName") * lpeg.V("FuncBody");
180 LocalFunc = tllexer.kw("function") * 180 LocalFunc = tllexer.kw("function") *
181 tllexer.try(lpeg.V("Id"), "LocalFunc") * lpeg.V("FuncBody"); 181 tllexer.try(lpeg.V("Id"), "LocalFunc") * lpeg.V("FuncBody");
182 LocalAssign = lpeg.V("NameList") * 182 LocalAssign = lpeg.V("NameList") * tllexer.symb("=") * tllexer.try(lpeg.V("ExpList"), "LocalAssign1") +
183 ((tllexer.symb("=") * tllexer.try(lpeg.V("ExpList"), "LocalAssign")))^-1; 183 lpeg.V("NameList") * (#(-tllexer.symb("=") * (lpeg.V("Stat") + -1)) * lpeg.P(true)) + lpeg.T(tlerror.labels["LocalAssign2"]);
184 LocalStat = tllexer.kw("local") * 184 LocalStat = tllexer.kw("local") *
185 (lpeg.V("LocalTypeDec") + lpeg.V("LocalFunc") + lpeg.V("LocalAssign")); 185 (lpeg.V("LocalTypeDec") + lpeg.V("LocalFunc") + lpeg.V("LocalAssign"));
186 LabelStat = tllexer.symb("::") * tllexer.try(tllexer.token(tllexer.Name, "Name"), "Label1") * tllexer.try(tllexer.symb("::"), "Label2"); 186 LabelStat = tllexer.symb("::") * tllexer.try(tllexer.token(tllexer.Name, "Name"), "Label1") * tllexer.try(tllexer.symb("::"), "Label2");
187 BreakStat = tllexer.kw("break"); 187 BreakStat = tllexer.kw("break");
188 GoToStat = tllexer.kw("goto") * tllexer.token(tllexer.Name, "Name"); 188 GoToStat = tllexer.kw("goto") * tllexer.token(tllexer.Name, "Name");
189 RetStat = tllexer.kw("return") * 189 RetStat = tllexer.kw("return") * tllexer.try(-lpeg.V("Stat"), "RetStat") *
190 (lpeg.V("Expr") * (tllexer.symb(",") * lpeg.V("Expr"))^0)^-1 * 190 (lpeg.V("Expr") * (tllexer.symb(",") * lpeg.V("Expr"))^0)^-1 *
191 tllexer.symb(";")^-1; 191 tllexer.symb(";")^-1;
192 TypeDecStat = lpeg.V("Interface"); 192 TypeDecStat = lpeg.V("Interface");