Lua work
parent
aa712ed8f4
commit
cdcce0d828
|
@ -93,7 +93,7 @@ export type LuaLocalFunctionStatement = {
|
||||||
|
|
||||||
export type LuaFunctionName = {
|
export type LuaFunctionName = {
|
||||||
type: "FunctionName";
|
type: "FunctionName";
|
||||||
propNames?: string[];
|
propNames: string[];
|
||||||
colonName?: string;
|
colonName?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -185,4 +185,17 @@ Deno.test("Statement evaluation", async () => {
|
||||||
env7,
|
env7,
|
||||||
);
|
);
|
||||||
assertEquals(env7.get("c"), 3);
|
assertEquals(env7.get("c"), 3);
|
||||||
|
|
||||||
|
// Function definition and calling
|
||||||
|
const env8 = new LuaEnv();
|
||||||
|
env8.set("print", new LuaNativeJSFunction(console.log));
|
||||||
|
await evalBlock(
|
||||||
|
`
|
||||||
|
function test(a)
|
||||||
|
return a + 1
|
||||||
|
end
|
||||||
|
print("3 + 1 = " .. test(3))
|
||||||
|
`,
|
||||||
|
env8,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,11 +6,15 @@ import type {
|
||||||
import { evalPromiseValues } from "$common/space_lua/util.ts";
|
import { evalPromiseValues } from "$common/space_lua/util.ts";
|
||||||
import {
|
import {
|
||||||
type ILuaFunction,
|
type ILuaFunction,
|
||||||
|
type ILuaGettable,
|
||||||
|
type ILuaSettable,
|
||||||
LuaBreak,
|
LuaBreak,
|
||||||
LuaEnv,
|
LuaEnv,
|
||||||
|
LuaFunction,
|
||||||
luaGet,
|
luaGet,
|
||||||
luaLen,
|
luaLen,
|
||||||
type LuaLValueContainer,
|
type LuaLValueContainer,
|
||||||
|
LuaReturn,
|
||||||
LuaTable,
|
LuaTable,
|
||||||
luaTruthy,
|
luaTruthy,
|
||||||
type LuaValue,
|
type LuaValue,
|
||||||
|
@ -356,6 +360,39 @@ export async function evalStatement(
|
||||||
case "FunctionCallStatement": {
|
case "FunctionCallStatement": {
|
||||||
return evalExpression(s.call, env);
|
return evalExpression(s.call, env);
|
||||||
}
|
}
|
||||||
|
case "Function": {
|
||||||
|
let body = s.body;
|
||||||
|
let propNames = s.name.propNames;
|
||||||
|
if (s.name.colonName) {
|
||||||
|
// function hello:there() -> function hello.there(self) transformation
|
||||||
|
body = {
|
||||||
|
...s.body,
|
||||||
|
parameters: ["self", ...s.body.parameters],
|
||||||
|
};
|
||||||
|
propNames = [...s.name.propNames, s.name.colonName];
|
||||||
|
}
|
||||||
|
let settable: ILuaSettable & ILuaGettable = env;
|
||||||
|
for (let i = 0; i < propNames.length - 1; i++) {
|
||||||
|
settable = settable.get(propNames[i]);
|
||||||
|
if (!settable) {
|
||||||
|
throw new Error(
|
||||||
|
`Cannot find property ${propNames[i]}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
settable.set(
|
||||||
|
propNames[propNames.length - 1],
|
||||||
|
new LuaFunction(body, env),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "Return": {
|
||||||
|
throw new LuaReturn(
|
||||||
|
await evalPromiseValues(
|
||||||
|
s.expressions.map((value) => evalExpression(value, env)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unknown statement type ${s.type}`);
|
throw new Error(`Unknown statement type ${s.type}`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
Block { statement* ReturnStatement? }
|
Block { statement* ReturnStatement? }
|
||||||
|
|
||||||
ReturnStatement { kw<"return"> exp? ";"?}
|
ReturnStatement { kw<"return"> ExpList? ";"?}
|
||||||
|
|
||||||
@skip { newline | space | Comment }
|
@skip { newline | space | Comment }
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,9 @@ import {LRParser} from "@lezer/lr"
|
||||||
const spec_identifier = {__proto__:null,break:16, goto:20, do:24, end:26, while:30, nil:32, true:34, false:36, or:80, and:82, not:104, function:114, repeat:122, until:124, if:128, then:130, elseif:132, else:134, for:138, in:146, local:156, return:172}
|
const spec_identifier = {__proto__:null,break:16, goto:20, do:24, end:26, while:30, nil:32, true:34, false:36, or:80, and:82, not:104, function:114, repeat:122, until:124, if:128, then:130, elseif:132, else:134, for:138, in:146, local:156, return:172}
|
||||||
export const parser = LRParser.deserialize({
|
export const parser = LRParser.deserialize({
|
||||||
version: 14,
|
version: 14,
|
||||||
states: ">`O!ZQPOOOOQO'#Cc'#CcO!UQPO'#CaO!bQPOOOOQO'#Ei'#EiO!vQQO'#CwO$]QPO'#EhOOQO'#Eh'#EhO$gQPO'#EhOOQO'#EO'#EOO%vQPO'#D}OOQO'#Ed'#EdOOQO'#EV'#EVO%{QPO'#C_OOQO'#C_'#C_QOQPOOO!UQPO'#CeO&`QPO'#CgO!vQQO'#CjO&gQPO'#DjO!vQQO'#DmO!UQPO'#DrO!UQPO'#DyO&nQPO'#EPO&vQQO'#ETO'^QPO,58{OOQO'#Cq'#CqO!UQPO,59^O!vQQO,59`O(gQQO'#C|O(nQQO'#EnOOQO'#Ej'#EjOOQO,59f,59fO!UQPO,59fO(uQPO'#EfO,eQPO,59cOOQO'#Dc'#DcOOQO'#Dd'#DdOOQO'#De'#DeO!vQQO'#DaOOQO'#Ef'#EfO,lQPO'#DfO,qQPO'#E^O,yQPO,5;kO!vQQO,5:iOOQO-E8T-E8TOOQO,58y,58yOOQO,59P,59PO-RQPO,59RO-WQPO,59UO-_QPO,5:UO-dQPO,5:XO-kQPO'#FOOOQO'#Dv'#DvO-vQPO'#DuO-{QPO,5:^O.QQPO'#DzO,lQPO,5:eO.]QQO'#ERO/sQPO'#FQOOQO'#EQ'#EQO!UQPO,5:gO1WQPO,5:kO2hQPO,5:oOOQO,5:o,5:oOOQO1G.g1G.gOOQO1G.x1G.xO3OQPO1G.zO3VQSO'#EfO4cQSO'#EiO!vQQO'#DOO7WQSO'#DQOOQO'#Ek'#EkOOQO,59h,59hO7bQSO,59hO7jQPO'#EoOOQO,5;Y,5;YO9PQPO,5;YO9UQPO1G/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!ZR$h#lR$W#UR!XeR!WeQ!dhQ#Y|Q$_#bR$i#mR!ZfgYO]ac#[#^#c$}%S%b%iR!`gQ!]gR$f#jR#i![d^Oac#[#^#c$}%S%b%iR!O]d]Oac#[#^#c$}%S%b%iR}]Q#u!nR$z#uQ#o!aR$k#oS$|$T$UR%^$|Q%P$ZR%`%PQ#a!UR$^#aQ#e!YR$b#eQ{UR#X{Q#k!]R$g#kg[O]ac#[#^#c$}%S%b%iQsTQ!RbQ!TdY!ahn|#b#mQ!glW!km#t$y%ZQ#TwQ#s!jQ#w%oQ#z!zQ#{!{Q#|!|Q#}!}Q$O#OQ$P#PQ$Q#QQ$R#RQ$S#SQ$Y#]Q$[#_Q$j#nQ$l#rQ$n%pQ$o%qQ$p%rQ$q%sQ$r%tQ$s%uQ$t%vQ$u%wQ$v%xQ%c%QQ%e%TQ%f%XR%n%klRO]acz#U#[#^#c${$}%S%b%i!UrTbdhlnw|!j!z!{!|!}#O#P#Q#R#S#]#_#b#m#n%Q%T%kq!hm#r#t$y%X%Z%o%p%q%r%s%t%u%v%w%xfUO]ac#[#^#c$}%S%b%i!vVTbdhlmnw|!j!z!{!|!}#O#P#Q#R#S#]#_#b#m#n#r#t$y%Q%T%X%Z%k%o%p%q%r%s%t%u%v%w%xQ#WzQ$T#UR%[${UpRr!hR#y!qQ!nmV$w#t$y%ZXoRr!h!qW!bh|#b#mR!pnR$V#UR!VegXO]ac#[#^#c$}%S%b%iR!^g",
|
||||||
nodeNames: "⚠ Comment Chunk Block ; Label :: Name break Goto goto Scope do end WhileStatement while nil true false Ellipsis Number LiteralString Property . MemberExpression [ ] Parens ( ) FunctionCall : TableConstructor { FieldDynamic FieldProp FieldExp } , BinaryExpression or and CompareOp BitOp BitOp BitOp BitOp Concat ArithOp ArithOp ArithOp UnaryExpression not ArithOp BitOp LenOp FunctionDef function FuncBody ArgList RepeatStatement repeat until IfStatement if then elseif else ForStatement for ForNumeric ForGeneric NameList in ExpList Function FuncName LocalFunction local Assign VarList Local AttNameList AttName Attrib ReturnStatement return",
|
nodeNames: "⚠ Comment Chunk Block ; Label :: Name break Goto goto Scope do end WhileStatement while nil true false Ellipsis Number LiteralString Property . MemberExpression [ ] Parens ( ) FunctionCall : TableConstructor { FieldDynamic FieldProp FieldExp } , BinaryExpression or and CompareOp BitOp BitOp BitOp BitOp Concat ArithOp ArithOp ArithOp UnaryExpression not ArithOp BitOp LenOp FunctionDef function FuncBody ArgList RepeatStatement repeat until IfStatement if then elseif else ForStatement for ForNumeric ForGeneric NameList in ExpList Function FuncName LocalFunction local Assign VarList Local AttNameList AttName Attrib ReturnStatement return",
|
||||||
maxTerm: 130,
|
maxTerm: 130,
|
||||||
nodeProps: [
|
nodeProps: [
|
||||||
|
@ -13,10 +13,10 @@ export const parser = LRParser.deserialize({
|
||||||
],
|
],
|
||||||
skippedNodes: [0,1],
|
skippedNodes: [0,1],
|
||||||
repeatNodeCount: 9,
|
repeatNodeCount: 9,
|
||||||
tokenData: "7O~RsXY#`YZ#z[]#`]^$Xpq#`rs$ast)duv)ivw)nwx)sxy.qyz.vz{.{{|/Q|}/V}!O/^!O!P0Q!P!Q0g!Q!R0|!R![2b![!]4f!]!^4s!^!_4z!_!`5^!`!a5f!c!}5x!}#O6W#O#P#q#P#Q6]#Q#R6b#T#o5x#o#p6g#p#q6l#q#r6q#r#s6v~#eS#V~XY#`[]#`pq#`#O#P#q~#tQYZ#`]^#`~$PP#U~]^$S~$XO#U~~$^P#U~YZ$S~$dWOY$|Z]$|^r$|s#O$|#O#P%q#P;'S$|;'S;=`(R<%lO$|~%PXOY$|Z]$|^r$|rs%ls#O$|#O#P%q#P;'S$|;'S;=`(R<%lO$|~%qO#Z~~%tZrs$|wx$|!Q![&g#O#P$|#T#U$|#U#V$|#Y#Z$|#b#c$|#i#j(X#l#m(z#n#o$|~&jZOY$|Z]$|^r$|rs%ls!Q$|!Q![']![#O$|#O#P%q#P;'S$|;'S;=`(R<%lO$|~'`ZOY$|Z]$|^r$|rs%ls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topRules: {"Chunk":[0,2]},
|
topRules: {"Chunk":[0,2]},
|
||||||
dynamicPrecedences: {"110":1},
|
dynamicPrecedences: {"110":1},
|
||||||
specialized: [{term: 101, get: (value) => spec_identifier[value] || -1}],
|
specialized: [{term: 101, get: (value) => spec_identifier[value] || -1}],
|
||||||
tokenPrec: 2787
|
tokenPrec: 2785
|
||||||
})
|
})
|
||||||
|
|
|
@ -81,4 +81,9 @@ Deno.test("Test Lua parser", () => {
|
||||||
parse(`a(1, 2, 3)`);
|
parse(`a(1, 2, 3)`);
|
||||||
parse(`print "Sup"`);
|
parse(`print "Sup"`);
|
||||||
parse(`e(1 + print "8")`);
|
parse(`e(1 + print "8")`);
|
||||||
|
|
||||||
|
// Return statements
|
||||||
|
parse(`return`);
|
||||||
|
parse(`return 1`);
|
||||||
|
parse(`return 1, 2, 3`);
|
||||||
});
|
});
|
||||||
|
|
|
@ -165,6 +165,10 @@ function parseStatement(n: CrudeAST): LuaStatement {
|
||||||
names: parseAttNames(t[2]),
|
names: parseAttNames(t[2]),
|
||||||
expressions: t[4] ? parseExpList(t[4]) : [],
|
expressions: t[4] ? parseExpList(t[4]) : [],
|
||||||
};
|
};
|
||||||
|
case "ReturnStatement": {
|
||||||
|
const expressions = t[2] ? parseExpList(t[2]) : [];
|
||||||
|
return { type: "Return", expressions };
|
||||||
|
}
|
||||||
case "break":
|
case "break":
|
||||||
return { type: "Break" };
|
return { type: "Break" };
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import type { LuaFunctionBody } from "./ast.ts";
|
import type { LuaFunctionBody } from "./ast.ts";
|
||||||
|
import { evalStatement } from "$common/space_lua/eval.ts";
|
||||||
|
|
||||||
export class LuaEnv implements ILuaSettable {
|
export class LuaEnv implements ILuaSettable, ILuaGettable {
|
||||||
variables = new Map<string, LuaValue>();
|
variables = new Map<string, LuaValue>();
|
||||||
|
|
||||||
constructor(readonly parent?: LuaEnv) {
|
constructor(readonly parent?: LuaEnv) {
|
||||||
|
@ -18,7 +19,7 @@ export class LuaEnv implements ILuaSettable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get(name: string): LuaValue {
|
get(name: string): LuaValue | undefined {
|
||||||
if (this.variables.has(name)) {
|
if (this.variables.has(name)) {
|
||||||
return this.variables.get(name);
|
return this.variables.get(name);
|
||||||
}
|
}
|
||||||
|
@ -61,6 +62,10 @@ export interface ILuaSettable {
|
||||||
set(key: LuaValue, value: LuaValue): void;
|
set(key: LuaValue, value: LuaValue): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ILuaGettable {
|
||||||
|
get(key: LuaValue): LuaValue | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
export class LuaFunction implements ILuaFunction {
|
export class LuaFunction implements ILuaFunction {
|
||||||
constructor(private body: LuaFunctionBody, private closure: LuaEnv) {
|
constructor(private body: LuaFunctionBody, private closure: LuaEnv) {
|
||||||
}
|
}
|
||||||
|
@ -76,7 +81,19 @@ export class LuaFunction implements ILuaFunction {
|
||||||
}
|
}
|
||||||
env.set(this.body.parameters[i], arg);
|
env.set(this.body.parameters[i], arg);
|
||||||
}
|
}
|
||||||
throw new Error("Not yet implemented funciton call");
|
return evalStatement(this.body.block, env).catch((e: any) => {
|
||||||
|
if (e instanceof LuaReturn) {
|
||||||
|
if (e.values.length === 0) {
|
||||||
|
return;
|
||||||
|
} else if (e.values.length === 1) {
|
||||||
|
return e.values[0];
|
||||||
|
} else {
|
||||||
|
return new LuaMultiRes(e.values);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +111,7 @@ export class LuaNativeJSFunction implements ILuaFunction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class LuaTable implements ILuaSettable {
|
export class LuaTable implements ILuaSettable, ILuaGettable {
|
||||||
// To optimize the table implementation we use a combination of different data structures
|
// To optimize the table implementation we use a combination of different data structures
|
||||||
// When tables are used as maps, the common case is that they are string keys, so we use a simple object for that
|
// When tables are used as maps, the common case is that they are string keys, so we use a simple object for that
|
||||||
private stringKeys: Record<string, any>;
|
private stringKeys: Record<string, any>;
|
||||||
|
@ -131,7 +148,7 @@ export class LuaTable implements ILuaSettable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get(key: LuaValue): LuaValue {
|
get(key: LuaValue): LuaValue | undefined {
|
||||||
if (typeof key === "string") {
|
if (typeof key === "string") {
|
||||||
return this.stringKeys[key];
|
return this.stringKeys[key];
|
||||||
} else if (Number.isInteger(key) && key >= 1) {
|
} else if (Number.isInteger(key) && key >= 1) {
|
||||||
|
@ -202,6 +219,12 @@ export function luaLen(obj: any): number {
|
||||||
export class LuaBreak extends Error {
|
export class LuaBreak extends Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class LuaReturn extends Error {
|
||||||
|
constructor(readonly values: LuaValue[]) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function luaTruthy(value: any): boolean {
|
export function luaTruthy(value: any): boolean {
|
||||||
if (value === undefined || value === null || value === false) {
|
if (value === undefined || value === null || value === false) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue