1
0
Fork 0
mirror of https://github.com/Reuh/candran.git synced 2025-10-27 17:59:30 +00:00

Implicit returns

This commit is contained in:
Étienne Fildadut 2017-08-24 18:35:06 +02:00
parent 025a55f708
commit 1d5390d0a7
2 changed files with 9 additions and 8 deletions

File diff suppressed because one or more lines are too long

View file

@ -273,11 +273,11 @@ local G = { V"Lua",
Lua = V"Shebang"^-1 * V"Skip" * V"Block" * expect(P(-1), "Extra");
Shebang = P"#!" * (P(1) - P"\n")^0;
Block = tagC("Block", V"Stat"^0 * V"RetStat"^-1);
Block = tagC("Block", V"Stat"^0 * (V"RetStat" + V"ImplicitRetStat")^-1);
Stat = V"IfStat" + V"DoStat" + V"WhileStat" + V"RepeatStat" + V"ForStat"
+ V"LocalStat" + V"LetStat" + V"FuncStat" + V"BreakStat" + V"ContinueStat" + V"LabelStat" + V"GoToStat"
+ V"FuncCall" + V"Assignment" + sym(";") + -V"BlockEnd" * throw("InvalidStat");
BlockEnd = P"return" + "end" + "elseif" + "else" + "until" + -1;
BlockEnd = P"return" + "end" + "elseif" + "else" + "until" + -1 + V"ImplicitRetStat";
IfStat = tagC("If", V"IfPart" * V"ElseIfPart"^0 * V"ElsePart"^-1 * expect(kw("end"), "EndIf"));
IfPart = kw("if") * expect(V"Expr", "ExprIf") * expect(kw("then"), "ThenIf") * V"Block";
@ -324,6 +324,7 @@ local G = { V"Lua",
BreakStat = tagC("Break", kw("break"));
ContinueStat = tagC("Continue", kw("continue"));
RetStat = tagC("Return", kw("return") * commaSep(V"Expr", "RetList")^-1 * sym(";")^-1);
ImplicitRetStat = tagC("Return", commaSep(V"Expr", "RetList") * sym(";")^-1);
NameList = tagC("NameList", commaSep(V"Id"));
VarList = tagC("VarList", commaSep(V"VarExpr", "VarList"));