Writing a donut recipe in TableGen
With the knowledge from previous sections, it's time to write our own donut recipe! We'll proceed as follows:
- The first file to create is
Kitchen.td
. It defines the environment for cooking, including measuring units, equipment, and procedures, to name but a few aspects. We are going to start with the measuring units, as follows:class Unit { string Text; bit Imperial; }
Here, the
Text
field is the textual format showing on the recipe, andImperial
is just a Boolean flag marking whether this unit is imperial or metric. Each weight or volume unit will be a record inheriting from this class—have a look at the following code snippet for an example of this:def gram_unit : Unit { let Imperial = false; let Text = "g"; } def tbsp_unit : Unit { let Imperial = true; let Text = "tbsp"; }
There are plenty of measuring units we want to create, but...