summaryrefslogtreecommitdiff
path: root/README
blob: 0de18e746e0f74b6202bf5b15ff3850b050997d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
`codegen.py`, `scenario.txt`, and `bindings.yaml` form a

proof-of-concept of what Lars's code genearation approach is supposed
to look like. `scenario.txt` is the scenario text, extracted into a
separate file to avoid having to parse Markdown. `bindings.yaml`
describes what sceanrio steps are defined and what functions should be
called for them. `codegen.py` generates Python code that executes all
the steps in the scenario.

This doesn't even try to handle errors when running scenarios, or
missing bindings, or anything. It's the simplest possible thing that
shows the code generation idea.

Only generates Python, and takes advantage of Python's keyword
argument handling. Generating Rust, for example, would have to handle
things much more carefully, e.g., Rust doesn't have keyword arguments,
and needs explicit types to be defined. But that's too much for
showing the core idea.

Additionally `prelude.py` is copied to the output as-is.

To run:

```sh
python3 ./codgen.py > tmp.py
python3 tmp.py
```

Output should be:

```
precondition: {}
do: {'name': 'Tomjon'}
is_fine: {}
```