Giter Site home page Giter Site logo

Comments (7)

josevalim avatar josevalim commented on July 28, 2024 1

Hi @jeffrom! The idea is to do something more efficient, where we read the size and then we perform <<x::size(y)-binary>>.

from nimble_parsec.

jeffrom avatar jeffrom commented on July 28, 2024

Just curious: I've implemented something that i think achieves this, which basically does a traverse to get the length from the input and adds it to the context, and then a repeat_while to increment a counter, also in the context, and repeats ascii_char([0..255]) until the counter has reached the input size. Would what you have in mind be more efficient than this approach?

from nimble_parsec.

jeffrom avatar jeffrom commented on July 28, 2024

definitely looking forward to that!

from nimble_parsec.

w-sanches avatar w-sanches commented on July 28, 2024

@josevalim is this still wanted and has no one working on it? I could give it a try.

from nimble_parsec.

josevalim avatar josevalim commented on July 28, 2024

Still wanted, yes. :)

from nimble_parsec.

teamon avatar teamon commented on July 28, 2024

I stumbled upon a similar (I think) case: parsing <N><...something...><N times X>

In theory, it could be represented as (name pretty random):

def times_from_count(count_combinator, next_combinator, repeated_combinator)

and used like this:

times_from_prefix(integer(), string("---"), ascii_char(?a..?c))

and it would parse the following examples:

"2---a"             -> error, expected 2 chars after "---", got 1
"2---ab"            -> ok("ab"), "" left
"2---abc"           -> ok("ab"), "c" left
"10---abcabcabca"   -> ok("abcabcabca"), "" left

Is this anyhow similar to what sized_binary would do?
Is there any way to implement it with current nimble_parsec?

I could try to implement it with a bit of guidance of how it all works inside 🙃

from nimble_parsec.

josevalim avatar josevalim commented on July 28, 2024

I have just pushed the ability to return rest from post_traverse which would allow someone to implement this by hand, so this is no longer relevant. :)

from nimble_parsec.

Related Issues (20)

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.