banjin
Simple code generator for manual parsing
Attributes
Struct
There are several attributes that control behaviour of parser Each, attached to struct's field
starts_with = <prefix>
- Specifies string with which next parse step should start(can be stacked). Errors if prefix is missing.ends_with = <prefix>
- Specifies string with which parse step should end(can be stacked). Errors if suffix is missing. If empty, expects EOF.skip = <chars>
- Specifies to skip characters, until not meeting character outside of specified in string.skip(ws)
- Specifies to skip all white space characters.format(<format>)
- Specifies list of characters that should contain value to parse from.format(not(<format>))
- Specifies list of characters that should contain value to parse from.
Formats
- Literal string - When string is specified as argument to
format
, it is used as set of characters. numeric
- When specified, match usingchar::is_numeric()
digit(<base>)
- When specified, match usingchar::is_digit(<base>)
ascii
- When specified, match usingchar::is_ascii()
alphabetic
- When specified, match usingchar::is_alphabetic()
Enum
format = <format>
- Specifies string to match against.case
- Specifies case sensitive match. By default it is insensitive.default
- Specifies variant as taking default value. Should take only singleString
and there can be only one
Usage
Struct
use FromStr;
Enum
use FromStr;