Skip to content

Internal parser panic due to %nonassoc #344

@andr3wsm

Description

@andr3wsm

I am trying to write a parser for a simple language that includes operators like == or > that should be nonassociative. The Happy (v 2.1.7) file was generated with BNFC (v 2.9.6.1), originally with ambiguities. At this point, an expression like a == b == c is recognized.

When adding %nonassoc '==' inside the Happy file (in the right position, after the tokens are declared and before the parser rules are defined) I would expect a syntax error (as it happen when I try to validate expressions that are not well formed), however I get this message when trying to parse the expression a == b == c.

TestElang: Internal Happy parser panic. This is not supposed to happen! Please open a bug report at https://github.com/haskell/happy/issues.

CallStack (from HasCallStack):
error, called at ./ParElang.hs:1615:17 in main:ParElang

The line 1615 in question is just the definition of notHappyAtAll. How to solve this?

This is the file that generates the error:
https://github.com/andr3wsm/elang-bug/blob/main/ParElang.y

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions