asajeffrey / parsell Goto Github PK
View Code? Open in Web Editor NEWParsell: an LL(1) parser combinator library for Rust
License: Other
Parsell: an LL(1) parser combinator library for Rust
License: Other
The type for and_then should be that it Cow's p's output. For instance:
let p = character(char::is_alphabetic).plus().buffer();
let q = character(char::is_numeric).star().buffer();
p.and_then(q).parse("abc1").unContinue().parse("23!")
should return (Owned(String::from("abc")),Owned(String::from("123")))
. At the moment. "abc"
is borrowed rather than owned, which is producing lifetime issues.
At the moment, committed parsers call init()
to create a stateful parser. For boxed parers, this usually means calling Box::new(parser.init().boxable())
, so we are boxing the parser every time it is initialized. It would be better to call init_parse
, which avoid boxing the parser unless we need to save its state.
Really, the interface should be an applicative functor. The idea would be:
interface Parser { ... fn apply<P>(self, p: P) -> Apply<Self, P> { ... } ... }
impl<P,Q,Str> Uncommitted<Str> for Apply<P,Q>
where P: Uncommitted<Str>,
Q: Committed<Str>,
P::Output: Function<Q::Output>,
{ ... }
so you could write something like:
character(...).emitting(myfun).apply(this).apply(that);
This would support Kleene Star as well, with something like:
interface Parser { ... fn apply_star<P>(self, p: P) -> ApplyStar<Self, P> { ... } ... }
impl<P,Q,Str> Uncommitted<Str> for ApplyStar<P,Q>
where P: Uncommitted<Str>,
Q: Uncommitted<Str>,
P::Output: Function<Q::Output, Output = P::Output>,
{ ... }
For example, the current p.star(f)
would be:
emit(f).apply_star(p)
and the current p.plus(f)
would be:
p.map(|x| f().apply(x)).apply_star(p)
this uses F: FnOnce(X) -> F
as a replacement for Consumer<F>
.
It would be nice to get a type error from p.and_then(q)
in the case that q isn't committed. At the moment the type error isn't until much later, and is pretty incomprehensible.
We should be able to discard results easily, with something like p.discard_and_then(q)
, p.and_then_discard(q)
etc.
The library takes a lot of time to typecheck, for example travis (https://travis-ci.org/asajeffrey/parsell/builds/107310315) reports 1 min 15 sec for stable, 2 min 46 sec for beta and 3 min 41 sec for nightly.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.