A toy transpiler to convert reqlang-expr expressions to Typescript.
This is not a serious project.
(id `foo`)
transpiles to
// This file was generated by reqlang-expr-tspl
import * as ReqlangExpr from "@reqlang-expr-tspl/runtime";
const expression: ReqlangExpr.Expression = (ctx) => {
return ctx.builtins.id("foo");
};
const args = ReqlangExpr.getArgs();
const env = new ReqlangExpr.Env(
args.vars,
args.prompts,
args.secrets,
args.client
);
const context = {
env,
builtins: ReqlangExpr.builtinFns,
};
const value = expression(context);
console.log(JSON.stringify(value));See: @reqlang-expr-tspl/runtime
reqlang-expr-tspl spec/greeting_name.expr > spec/greeting_name.expr.ts
npx tsx spec/greeting_name.expr.ts \
--var 'greeting=Hello' \
--prompt 'name=World'
# "Hello World"The reqlang-expr-tspl.sh script helps run the latest development version of the CLI.
./reqlang-expr-tspl.sh spec/greeting_name.expr > spec/greeting_name.expr.ts
npx tsx spec/greeting_name.expr.ts \
--var 'greeting=Hello' \
--prompt 'name=World'
# "Hello World"The spec directory has several input *.expr with corrosponding *.expr.ts expected generated code.
cargo testTranspiles the*.exprfiles and checks the*.expr.tsfiles for equality.npm run testRuns the*.expr.tsfiles usingnpx tsxand compares results against*.expr.ts.interpretedfilesnpm run checkTypechecks the*.expr.tsfilesjust testRuns all tests