Basic description of recipe format
Getty Ritter
8 years ago
1 | # Apicus | |
2 | ||
3 | Explorations in recipe visualization. Right now, this just implements | |
4 | a DSL for describing recipes in a graph-like way. A basic Apicus recipe | |
5 | looks like this: | |
6 | ||
7 | ``` | |
8 | scrambled eggs { | |
9 | [2] eggs -> whisk -> stir & butter -> DONE; | |
10 | } | |
11 | ``` | |
12 | ||
13 | The name of the recipe is `scrambled eggs` and it consists of one rule. | |
14 | This rule starts with an ingredient where the amount of the ingredient | |
15 | is marked with `[...]`, and then has a set of actions. Actions can | |
16 | optionally include ingredients after a `&` character, which is supposed | |
17 | to be used for garnishes, seasonings, or incidental ingredients like | |
18 | flour used as a thickener or oil used as a medium for cooking. | |
19 | ||
20 | A recipe can include multiple rules, and you join them together using | |
21 | _join points_, which are written with a dollar sign: | |
22 | ||
23 | ``` | |
24 | nicer scrambled eggs { | |
25 | [1/2] onion + [1 clove] garlic | |
26 | -> chop coarsely -> sautee & butter -> $mix; | |
27 | [2] eggs -> whisk -> $mix; | |
28 | $mix -> stir & salt -> DONE; | |
29 | } | |
30 | ``` | |
31 | ||
32 | This recipe includes a join point called `$mix`, which combines two | |
33 | previously separate threads of preparation. Rules can begin with | |
34 | either ingredients or join points, and actions can be either textual | |
35 | descriptions of what to do or join points. You can also include a | |
36 | join point as part of a longer chain, so the above recipe could also | |
37 | be written as | |
38 | ||
39 | ``` | |
40 | nicer scrambled eggs v2 { | |
41 | [1/2] onion + [1 clove] garlic | |
42 | -> chop coarsely -> sautee & butter -> $mix -> stir & salt -> DONE; | |
43 | [2] eggs -> whisk -> $mix; | |
44 | } | |
45 | ``` | |
46 | ||
47 | So the handwavey grammar of recipe descriptions is | |
48 | ||
49 | ``` | |
50 | recipe ::= text '{' rule* '}' | |
51 | rule ::= ( ingredients | join ) '->' action ('->' action) * ';' | |
52 | ingredients ::= ingredient ('+' ingredient) | |
53 | ingredient ::= ( '[' text ']' )? text | |
54 | action ::= join | text ('&' ingredients)? | |
55 | ``` |