add compiler support for expression lines.

This commit is contained in:
trans_soup 2023-11-06 16:43:10 +01:00
parent eadd722f39
commit b9582163cc
1 changed files with 19 additions and 0 deletions

View File

@ -70,6 +70,25 @@ export function compile_line (env, line) {
};
}
if (line.type === Line.Expression) {
let value;
let valid = true;
try {
value = evaluate(env, line.value);
} catch (e) {
valid = false;
}
if (!valid) return invalid();
return {
valid: true,
env: env,
value: value,
};
}
return invalid();
}