ruby / ruby/racc

How to add "... expected {TOKEN}" to error messages?

Open
#88 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Yacc
Stars
569
Forks
93
Avg merge
4d 19h
Merged PRs (30d)
4

Description

Hi! I've been using Racc very happily with graphql-ruby for a while now. It's easy-to-use and fast, so thanks for maintaining it!

I'd like to improve the error messages to have some helpful info, for example, instead of:

Parse error on ")" at [1, 17]

I'd like to say:

Parse error on ")" at [1,17] (expected ":")

However, in reviewing the on_error docs, I don't see a way to access which token was expected. Is it possible to do that with Racc?

Thanks!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Racc::Parser on_error documentation linked in the issue, then trace the parser's error-handling entry point to determine whether the expected token is available there. Compare the current error format with the requested example; done means establishing a documented, testable way to include expected-token information or clearly documenting why it cannot be exposed.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.