Giter Club home page Giter Club logo

Comments (14)

tstack avatar tstack commented on June 10, 2024

Did you have something in mind for how to handle this? Looking at the nom error management docs, the Merr pattern matching option seemed like a reasonable solution.

from angle-grinder.

rcoh avatar rcoh commented on June 10, 2024

from angle-grinder.

rcoh avatar rcoh commented on June 10, 2024

Looked into this a bit more -- we probably want to combine early-return from errors with merr. (Although merr might be overkill, the grammar is pretty stable)

from angle-grinder.

tstack avatar tstack commented on June 10, 2024

Cool. I'm finishing up a change to add the limit operator. I can try the different approaches for errors and see how it goes after I'm done with limit.

from angle-grinder.

rcoh avatar rcoh commented on June 10, 2024

from angle-grinder.

tstack avatar tstack commented on June 10, 2024

The "merr" stuff in nom doesn't seem to be working anymore. The return_error!() macro seems to be sufficient, though. I'll try to put together something that handles a couple error cases, like non-terminated string and no column names for count by and open a PR.

from angle-grinder.

tstack avatar tstack commented on June 10, 2024

If you have some time, can you check out this commit on my error-wip branch and say if you okay with the direction.

Here's a screenshot of the results so far:

image

from angle-grinder.

rcoh avatar rcoh commented on June 10, 2024

(this is from a fairly brief skim on my phone, more comments later)
First off, the results are gorgeous! I never would have thought to try to use the same library that rustc uses.

A couple of thoughts:

  • I'm not in love with sticking postions ad-hoc into operators. What if we did something like:
WithPosition<T> {
  position: [Positional information needed for syntax errors]
  obj: T
}

We could have the parser return a seq of Positioned<Operator>

I think I'd prefer that strategy in general (wrapping objects with their positions) rather than having positional information leak into the underlying structs. We could even push that all the way down the execution engine for generating nice error messages at some point.

I'd also probably refactor the grammar a bit to push the positioning down a little bit so that you didn't need to create start and end tokens manually in most cases.

from angle-grinder.

rcoh avatar rcoh commented on June 10, 2024

eg.

Limit {
  count: Positioned<f64>
}

WithPosition can define into for T to easily extract the underlying type

from angle-grinder.

rcoh avatar rcoh commented on June 10, 2024

Another note: If it simplifies things, I'd be totally fine only exposing the first error in a pipeline

from angle-grinder.

tstack avatar tstack commented on June 10, 2024

I don't like the position stuff either. I like your proposal, I'll see if I can make it work.

from angle-grinder.

tstack avatar tstack commented on June 10, 2024

I've updated my error-wip branch if you want to take a look again. Let me know if that's fine for a PR or if you want me to break it up or do some more changes.

I was able to get your Positioned suggestion working by adding a with_pos!() parser that wraps the result of the child parser with a Positioned object. It's a definite improvement.

Thanks!

from angle-grinder.

rcoh avatar rcoh commented on June 10, 2024

from angle-grinder.

rcoh avatar rcoh commented on June 10, 2024

Main work is done in #44 , remaining tasks are incremental, closing.

from angle-grinder.

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.