Sonntag, 18. Oktober 2009

xtext for recipes

Yesterday I was at my parent's place. The weather wasen't very well so we enjoyed one of my mother's delicious dishes for dinner. At that time my mother and my girl friend started to exchange recipes and I started to think about writing a cookbook. It's more like a male cookbook... that's why I think the following aspects should matter the most for my book:
  • You should get a fast overview about the dish
  • More headwords than prose
I thik both of these aspects can be reached by using a diagram notation. My diagram should be some kind of UML sequence diagram which looks like a UML flowchart diagram. Recipes should have a defined start state and multiple operations which can occure in parallel. As I am more one of the text guys I prefere a textual notation for the recipies. The diagram should be generated from the textual recipe notation. The idea is a TeX approach: Define your document in a specialized language, then render the document. As cooking is much like executing a Makefile :-) there should be many subtasks which depend on each other. Dependencies are very easy for humans to express and dependencies are enough for the recipe generator to determine which tasks can be executed in parallel. So last but not least here is my recipe language draft. I mixed the concepts from above with some meta information about the ingredients, cooking duration, etc.
measure Prise {
}

measure Gramm {
}

measure Liter {
}

measure Blaetter {
}

ingredient Wasser;
ingredient Salz;
ingredient Nudeln;
ingredient Tomatenmark;
ingredient Basilikum;

recipe Tomatennudeln {
     step WasserKochen {
             title "Wasser zum kochen bringen";

             ingredient 0.5 Liter Wasser;

             duration 10 minutes;
     }
     step WasserSalzen {
             title "Wasser salzen";

             ingredient 1 Prise Salz;

             duration 10 seconds;
     }
     step NudelnInWasser {
             title "Nudeln weichkochen";

             depends WasserKochen;
             depends WasserSalzen;

             ingredient 200 Gramm Nudeln;

             duration 5 minutes;
     }
     step NudelnAbgiessen {
             title "Nudeln abgiessen"
          
             depends NudelnInWasser

             duration 30 seconds;
     }
     step TomatenmarkErhitzen {
             title "Tomatenmark wuerzen und erhitzen"

             depends NudelnAbgiessen;

             ingredient 10 Blaetter Basilikum;

             duration 2 minutes;
     }
     step AllesVerruehren {
             title "Nudeln und Tomatensosse verruehren"

             depends NudelnAbgiessen;
             depends TomatenmarkErhitzen;

             duration 30 seconds;
     }
  
}
Hopefully I will get some time soon to implement a prototype using TMF Xtext.

Keine Kommentare:

Kommentar veröffentlichen