Next: , Previous: %doc, Up: Top

10 %typedef and %type

Field values are, by default, unrestricted text strings. However, it is often useful to impose some restrictions on the values of certain fields. For example, consider the following record:

     Id: 111
     Name: Jose E. Marchesi
     Age: 30
     MaritalStatus: single
     Phone: +49 666 666 66

Where Id is a numeric identifier for a person. Name will never use several lines. Age will tipically be in the range 0..120, and there are only a few valid values for MaritalStatus: single, married and widow. Phones may be restricted to some standard format as well to be valid. All those restrictions (and many others) can be enforced by using field types.

There are two kind of field types: anonymous and named. Those are described in the following subsections.