https://github.com/testingrequired/reqlang-expr-tspl
A toy transpiler to convert reqlang-expr expressions to Typescript.
https://github.com/testingrequired/reqlang-expr-tspl
transpiler
Last synced: 6 months ago
JSON representation
A toy transpiler to convert reqlang-expr expressions to Typescript.
- Host: GitHub
- URL: https://github.com/testingrequired/reqlang-expr-tspl
- Owner: testingrequired
- License: mit
- Created: 2025-06-22T03:49:34.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-06-22T04:55:01.000Z (8 months ago)
- Last Synced: 2025-06-22T05:20:05.650Z (8 months ago)
- Topics: transpiler
- Language: Rust
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# reqlang-expr-tspl
A toy transpiler to convert [reqlang-expr](https://github.com/testingrequired/reqlang-expr) expressions to Typescript.
This is not a serious project.
## Example
```
(id `foo`)
```
transpiles to
```typescript
// 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](./src/index.ts)
## Running Transpiled Files
```bash
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"
```
## Development
- [Rust](https://www.rust-lang.org/)
- [Node](https://nodejs.org/)
- [just](https://just.systems/)
## Running CLI
The `reqlang-expr-tspl.sh` script helps run the latest development version of the CLI.
```bash
./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"
```
### Tests
[](https://github.com/testingrequired/reqlang-expr-tspl/actions/workflows/verify.yml)
The [spec](./spec/) directory has several input `*.expr` with corrosponding `*.expr.ts` expected generated code.
- `cargo test` Transpiles the `*.expr` files and checks the `*.expr.ts` files for equality.
- `npm run test` Runs the `*.expr.ts` files using `npx tsx` and compares results against `*.expr.ts.interpreted` files
- `npm run check` Typechecks the `*.expr.ts` files
- `just test` Runs all tests