Attributes
The behavior of individual subparsers or units can be controlled with attributes.
type Version = unit {
major: bytes &until=b".";
minor: bytes &until=b".";
patch: bytes &eod;
} &convert="v%s.%s.%s" % (self.major, self.minor, self.patch);
There are a wide range of both generic and type-specific attributes, e.g.,
- the
&sizeand&max-sizeattributes to control how much data should be parsed, - attributes
&parse-fromand&parse-atallowing to change where from where data is parsed, &convertto transform the value and/or type of parsed data, or&requiresto enforce post conditions.
Type-specific attributes are documented together with their type.