deno fmt
parent
a5c4bcc43b
commit
c0a248daba
|
@ -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(`
|
||||||
|
|
|
@ -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":
|
||||||
|
|
Loading…
Reference in New Issue