GithubHelp home page GithubHelp logo

parsell's People

Contributors

eddyb avatar kichjang avatar manishearth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

parsell's Issues

p.and_then(q) should Cow p's output

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.

Committed boxed parsers doing unnecessary allocation

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.

Applicative functor interface

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>.

Need examples

As far as I can find, the only examples are the ones in the readme. If there is a more comprehensive set of them, a link to them should be added to the readme as well. Even the tests are more or less empty

Better type errors

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.

Add discards

We should be able to discard results easily, with something like p.discard_and_then(q), p.and_then_discard(q) etc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.