racc icon indicating copy to clipboard operation
racc copied to clipboard

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

Open rmosolgo opened this issue 8 years ago • 4 comments

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!

rmosolgo avatar Nov 02 '17 14:11 rmosolgo

This is a great idea! It would require modifying the Racc engine, which is something almost no-one since the original author has done.

alexdowad avatar Nov 02 '17 18:11 alexdowad

Cool, thanks for your response! If I get a chance to take a look, I'll be sure to report back :)

rmosolgo avatar Nov 02 '17 19:11 rmosolgo

@rmosolgo... Not sure why you closed this. Perhaps you thought that "it would require modifying the Racc engine" was a secret code for "no"? It wasn't.

alexdowad avatar Nov 03 '17 16:11 alexdowad

I got the answer to my question, and I don't have the bandwidth to work on a fix now (:'() so I figured I'd close it out. Feel free to keep it open if you want to thought!

rmosolgo avatar Nov 03 '17 17:11 rmosolgo