Struct beancount_parser_lima::BeancountParser
source · pub struct BeancountParser<'s, 't> { /* private fields */ }Expand description
The Beancount parser itself, which tokenizes and parses the source files
contained in BeancountSources.
§Examples
use beancount_parser_lima::{BeancountParser, BeancountSources, ParseError, ParseSuccess};
fn main() {
let sources = BeancountSources::from(PathBuf::from("examples/data/full.beancount"));
let parser = BeancountParser::new(&sources);
parse(&sources, &parser, &io::stderr());
}
fn parse<W>(sources: &BeancountSources, parser: &BeancountParser, error_w: W)
where
W: Write + Copy,
{
match parser.parse() {
Ok(ParseSuccess {
directives,
options: _,
plugins: _,
warnings,
}) => {
for directive in directives {
println!("{}\n", &directive);
}
sources.write(error_w, warnings).unwrap();
}
Err(ParseError { errors, warnings }) => {
sources.write(error_w, errors).unwrap();
sources.write(error_w, warnings).unwrap();
}
}
}Implementations§
source§impl<'s, 't> BeancountParser<'s, 't>where
's: 't,
impl<'s, 't> BeancountParser<'s, 't>where
's: 't,
sourcepub fn new(sources: &'s BeancountSources) -> Self
pub fn new(sources: &'s BeancountSources) -> Self
Create a BeancountParser from BeancountSources read from all input files.
sourcepub fn parse(&'t self) -> Result<ParseSuccess<'t>, ParseError>where
's: 't,
pub fn parse(&'t self) -> Result<ParseSuccess<'t>, ParseError>where
's: 't,
Parse the sources, returning date-sorted directives and options, or errors, along with warnings in both cases.
Auto Trait Implementations§
impl<'s, 't> RefUnwindSafe for BeancountParser<'s, 't>
impl<'s, 't> Send for BeancountParser<'s, 't>
impl<'s, 't> Sync for BeancountParser<'s, 't>
impl<'s, 't> Unpin for BeancountParser<'s, 't>
impl<'s, 't> UnwindSafe for BeancountParser<'s, 't>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more