Skip to content

Is it possible to get a report on which production was being handled when an error arose? #419

Open

Description

@filmil

Here's an error message I encountered while using participle to parse a value change dump (VCD) file. See: filmil/go-vcd-parser#2.

unexpected token "V" (expected <kwend>)

Now participle is of course correct. But it is not exactly helpful. It does not tell me which production was parsed when the error occurred. I have multiple productions that may end with keyword $end. And one of the issues may be that my grammar has started parsing a wrong production somehow.

Perhaps this is already supported?

Activity

  1. alecthomas commented on Jan 7, 2025

    @alecthomas
    Owner

    No, this is not possible. Errors don't currently track the production that triggered them.

  2. Pastalikek65 commented on Aug 9, 2026

    @Pastalikek65
    Contributor

    As follow-up: #463 (merged into the parser now) improves this case — the error now includes the token type, e.g. unexpected token "V" of type Ident (expected <kwend>), which helps distinguish "wrong production started" from "wrong token type". A full production-stack report would require threading production context through the error path; that's a bigger change, but with #463 a good chunk of the confusion is addressed. Suggest closing this as partially addressed by #265/#463.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions