pull/1110/head
Zef Hemel 2024-09-30 12:50:54 +02:00
parent a5c4bcc43b
commit c0a248daba
11 changed files with 1070 additions and 1075 deletions

View File

@ -1,6 +1,5 @@
import { parse } from "$common/space_lua/parse.ts"; import { parse } from "$common/space_lua/parse.ts";
Deno.test("Test Lua parser", () => { Deno.test("Test Lua parser", () => {
// Basic block test // Basic block test
parse(` parse(`

View File

@ -185,9 +185,7 @@ function parseStatement(t: ParseTree): LuaStatement {
case "Assign": case "Assign":
return { return {
type: "Assignment", type: "Assignment",
variables: t.children![0].children!.filter((t) => variables: t.children![0].children!.filter((t) => t.type !== ",").map(
t.type !== ","
).map(
parseLValue, parseLValue,
), ),
expressions: parseExpList(t.children![2]), expressions: parseExpList(t.children![2]),
@ -203,9 +201,7 @@ function parseStatement(t: ParseTree): LuaStatement {
to: t.to, to: t.to,
}; };
case "ReturnStatement": { case "ReturnStatement": {
const expressions = t.children![1] const expressions = t.children![1] ? parseExpList(t.children![1]) : [];
? parseExpList(t.children![1])
: [];
return { type: "Return", expressions, from: t.from, to: t.to }; return { type: "Return", expressions, from: t.from, to: t.to };
} }
case "break": case "break":