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
&size
and&max-size
attributes to control how much data should be parsed, - attributes
&parse-from
and&parse-at
allowing to change where from where data is parsed, &convert
to transform the value and/or type of parsed data, or&requires
to enforce post conditions.
Type-specific attributes are documented together with their type.