MCPcopy Index your code
hub / github.com/asajeffrey/parsell

github.com/asajeffrey/parsell @v0.6.5

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.6.5 ↗ · + Follow
193 symbols 556 edges 9 files 64 documented · 33%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Parsell: an LL(1) streaming parser combinator library for Rust

The goal of this library is to provide parser combinators that:

  • are optimized for LL(1) grammars,
  • support streaming input,
  • do as little buffering or copying as possible, and
  • do as little dynamic method dispatch as possible.

It is based on:

Rustdoc | Video | Slides | Crate | CI

Example

extern crate parsell;
use parsell::{character,Parser,UncommittedStr,StatefulStr};
use parsell::ParseResult::{Done,Continue};
#[allow(non_snake_case)]
fn main() {

    // A sequence of alphanumerics, saved in a string buffer
    let ALPHANUMERIC = character(char::is_alphanumeric);
    let ALPHANUMERICS = ALPHANUMERIC.plus(String::new);

    // If you provide unmatching input to the parser, you'll get back a None response:
    match ALPHANUMERICS.init_str("!$?") {
        None => (),
        _ => panic!("Can't happen."),
    }

    // If you provide complete input to the parser, you'll get back a Done response:
    match ALPHANUMERICS.init_str("abc123!") {
        Some(Done(result)) => assert_eq!(result, "abc123"),
        _ => panic!("Can't happen."),
    }

    // If you provide incomplete input to the parser, you'll get back a Continue response:
    match ALPHANUMERICS.init_str("abc") {
        Some(Continue(parsing)) => match parsing.more_str("123!") {
            Done(result) => assert_eq!(result, "abc123"),
            _ => panic!("Can't happen."),
        },
        _ => panic!("Can't happen."),
    }

}

Example tested with Skeptic.

Extension points exported contracts — how you extend this code

HasOutput (Interface)
A trait for parsers which can infer their output type from their input types. [22 implementers]
src/lib.rs
Stateful (Interface)
A trait for stateful parsers. Stateful parsers are typically constructed by calling an `init` method of a stateless par [13 …
src/lib.rs
Parser (Interface)
A trait for stateless parsers. Parsers are implemented either as committed parsers, which cannot backtrack, or uncommit [15 …
src/lib.rs
Committed (Interface)
A trait for committed parsers. A parser is committed if it is guaranteed only to backtrack on empty input. CommittedInf [11 …
src/lib.rs
Uncommitted (Interface)
A trait for uncommitted parsers. An uncommitted parser can decide based on the first token of input whether it will com [15 …
src/lib.rs

Core symbols most depended-on inside this repo

or_else
called by 53
src/lib.rs
map
called by 39
src/lib.rs
and_then
called by 38
src/lib.rs
character
called by 22
src/lib.rs
init
called by 9
src/lib.rs
apply
called by 9
src/impls.rs
isListMode
called by 9
doc/talks/sf-rust-2016-02-18/scripts/script.js
variant_map
called by 8
src/lib.rs

Shape

Function 67
Method 65
Class 37
Interface 20
Enum 4

Languages

Rust88%
TypeScript12%

Modules by API surface

src/lib.rs117 symbols
src/impls.rs47 symbols
doc/talks/sf-rust-2016-02-18/scripts/script.js24 symbols
tests/typecheck-time4.rs1 symbols
tests/typecheck-time3.rs1 symbols
tests/typecheck-time2.rs1 symbols
tests/typecheck-time1.rs1 symbols
build.rs1 symbols

For agents

$ claude mcp add parsell \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page