Struct yaml_peg::parser::Parser [−][src]
Expand description
A PEG parser with YAML grammar, support UTF-8 characters.
A simple example for parsing YAML only:
use yaml_peg::{parser::Parser, node}; let n = Parser::new(b"true").parse().unwrap(); assert_eq!(n, vec![node!(true)]);
For matching partial grammar, each methods are the sub-parser. The methods have some behaviers:
- They will move the current cursor if matched.
- Returned value:
Result<(), ()>represents the sub-parser can be matched and mismatched.PErrorrepresents the sub-parser can be totally breaked when mismatched.
- Use
?to match a condition. - Use
Result::unwrap_or_defaultto match an optional condition. - Method
Parser::forwardis used to move on. - Method
Parser::textis used to get the matched string. - Method
Parser::backwardis used to get back if mismatched.
Fields
pos: usizeCurrent position.
eaten: usizeRead position.
Implementations
The low level grammar implementation for YAML.
These sub-parser returns Result<R, ()>, and calling Parser::backward if mismatched.
Match invisible boundaries and keep the gaps. (must matched once)
Match complex mapping indicator (?).
Match quoted string.
Match plain string.
Match flow string and return the content.
Match wrapped string.
Match valid YAML identifier.
Match anchor used.
Match any invisible characters except newline.
Match indent with previous level.
Return true if downgrading indent is allowed.
Match any optional invisible characters between two lines.
The implementation of string pointer.
The low level grammar implementation.
These sub-parser returns Result<(), ()>, and calling Parser::backward if mismatched.
Match until the condition failed.
The argument opt matches different terminate requirement.
A wrapper for saving local checkpoint.
The basic implementation.
These sub-parser returns PError, and failed immediately for PError::Terminate.
Additionally, they should eat the string by themself.
Match scalar.
Match flow scalar.
Match flow scalar terminal.
Auto Trait Implementations
impl<'a> RefUnwindSafe for Parser<'a>impl<'a> UnwindSafe for Parser<'a>