Code Monkey home page Code Monkey logo

Comments (5)

ltratt avatar ltratt commented on May 22, 2024

Should have been clear that I'm asking @ptersilie for thoughts.

from grmtools.

ptersilie avatar ptersilie commented on May 22, 2024

Does l.end().unwrap_or_else(|| l.start()) just return l.start(), which then makes &input[ return an empty string?

Maybe we can add a method l.was_inserted_by_error_recovery() that allows users to easily check if a lexeme is real or not. Or we add a function l.get_from_input(&input), which returns "" if the lexeme was inserted by error recovery, and then tell users to use that instead of indexing the input themselves?

from grmtools.

ltratt avatar ltratt commented on May 22, 2024

The inserted function allows you to tell if a lexeme was inserted by error recovery or not. My worry is that people will forget to test for that, then they'll do something like lexeme.end() and be surprised that they end up with a zero length lexeme (for a lexeme definition that seemingly could never be zero length). I'm just not sure if I'm being unduly paranoid or not.

from grmtools.

ptersilie avatar ptersilie commented on May 22, 2024

I think we can't reasonably worry about everything the user might forget, especially if that means we make the life of less forgetful users more difficult by forcing them to use workarounds like l.end().unwrap_or_else(|| l.start()). I rather have end/start return 0 if the lexeme was inserted. I'm sure users will quickly remember that these are inserted lexemes when they get zero length ones.

from grmtools.

ltratt avatar ltratt commented on May 22, 2024

OK, I'll raise a PR.

from grmtools.

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.