Code Monkey home page Code Monkey logo

Comments (3)

wavebeem avatar wavebeem commented on September 26, 2024

I'm not sure I understand why you'd use bnb to implement a lexer, it's meant to be an all-in-one parser like Parsimmon without a separate lexing step.

I thin the amount of complication this would add to the API is not worth it considering you can manually track the "whitespace" of your language and use other combinators like .many() or whatever.

from bread-n-butter.

hillin avatar hillin commented on September 26, 2024

I'm sorry if lexing is not a potential use case of bnb (and Parsimmon). It's common for complex languages to have separate lexing and (semantical) parsing steps; it's also not unheard to only lex the input without actually parsing it (syntax highlighters and linters for example).

I thin the amount of complication this would add to the API is not worth it considering you can manually track the "whitespace" of your language and use other combinators like .many() or whatever.

I think the misconception here is, the separators discarded by sepBy can be potentially non-trivial. For instance, an arithmetic expression (e.g. 3+4-5*6) can be expressed by operand.sepBy(operator), but the operators are important tokens to keep.

sepBy itself surely can be replaced with other combinators (although cumbersome), I think the question here is where do we draw the line between a core feature (should be included in the lib) and a utility (may not be included).

btw this is actually an extension of the discussion in jneen/parsimmon#230, where I first addressed this issue. I don't mind if bnb doesn't have the non-discarding APIs (we implemented our language without them anyways), but I hope they can appear in Parsimmon v2.

from bread-n-butter.

wavebeem avatar wavebeem commented on September 26, 2024

I'm well aware of lexing as a separate step, it's just not part of bnb intentionally.

If you're looking for more control over various parsers, that's why I allow custom parser creation. I tried to make the custom parser API easier than Parsimmon, and I intentionally tried to keep the source code easier to read rather than speed optimized so folks can see how the library works.

Between custom parsers and .thru, I'm only going to add things to bnb if I want to. It's easy to extend or replace a lot of bnb, and right now working on this library is not my top priority.

from bread-n-butter.

Related Issues (10)

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.