Expand description
Parsing C literals from byte slices.
This will parse a representation of a C literal into a Rust type.
§characters
Character literals are stored into the CChar
type, which can hold values
that are not valid Unicode code points. ASCII characters are represented as
char
, literal bytes with the high byte set are converted into the raw
representation. Escape sequences are supported. If hex and octal escapes
map to an ASCII character, that is used, otherwise, the raw encoding is
used, including for values over 255. Unicode escapes are checked for
validity and mapped to char
. Character sequences are not supported. Width
prefixes are ignored.
§strings
Strings are interpreted as byte vectors. Escape sequences are supported. If hex and octal escapes map onto multi-byte characters, they are truncated to one 8-bit character. Unicode escapes are converted into their UTF-8 encoding. Width prefixes are ignored.
§integers
Integers are read into i64
. Binary, octal, decimal and hexadecimal are
all supported. If the literal value is between i64::MAX
and u64::MAX
,
it is bit-cast to i64
. Values over u64::MAX
cannot be parsed. Width and
sign suffixes are ignored. Sign prefixes are not supported.
§real numbers
Reals are read into f64
. Width suffixes are ignored. Sign prefixes are
not supported in the significand. Hexadecimal floating points are not
supported.
Enums§
- Representation of a C character
Functions§
- ensures the child parser consumes the whole input
- Parse a C literal.