4 releases

0.2.5 Jun 9, 2023
0.2.4 Jun 8, 2023
0.2.3 Jun 7, 2023
0.2.2 Jun 7, 2023

#244 in Parser tooling

24 downloads per month

GPL-2.0 WITH Bison-exception-2.2

130KB
2.5K SLoC

Pacosso - a kind of streaming parser combinator framework for Rust

Pacosso is a framework for rapid parser development. It does not aim at building high-performance parsers - other frameworks are much more suitable for that - but rather at easy development for rapid prototyping and projects with moderate performance requirements.

Different from other streaming parser libraries, pacosso manages the incoming stream internally. The feature is intended to make writing parsers as easy as possible. Pacosso is able to handle any reader including in-memory buffers and strings, files, sockets and IO-chains combining such readers.

Documentation is available here.

Jsosso is a JSON parser that demonstrates the framework. It contains demo programs, benchmarks and more documentation.


lib.rs:

Pacosso is a framework for rapid parser development. It does not aim at building high-performance parsers - other frameworks are much more suitable for that - but rather at easy development for rapid prototyping and projects with moderate performance requirements.

Different from other streaming parser libraries, pacosso manages the incoming stream internally. The feature is intended to make writing parsers as easy as possible. Pacosso is able to handle any reader including in-memory buffers and strings, files, sockets and IO-chains combining such readers.

To see pacosso in action, have a look at Jsosso, a JSON parser that demonstrates the framework. It contains demo programs, benchmarks and more documentation.

Example:

use std::io;
use pacosso::{Stream, ParseResult};
use pacosso::options::Opts;

let parse = |p: &mut Stream<io::Cursor<Vec<u8>>>| -> ParseResult<()> {
    p.string("hello")?;
    p.whitespace()?;
    p.string("world")
};

let mut input = io::Cursor::new("hello world".as_bytes().to_vec());
let mut s = Stream::new(Opts::default().set_buf_size(8), &mut input);

assert!(match s.apply(parse) {
    Ok(()) => true,
    Err(e) => {
       eprintln!("error: {:?}", e);
       false
    },
});

No runtime deps