Skip to content

meaning of "Production 'xxx' is not reachable"? #108

Description

@nobodxbodon

Take the test case for example:

def test_unused_production(self):

Below are three cases with changed unused production rule:

case 1 -- No Warning

        @pg.production("main : VALUE")
        def main(p):
            return p[0]

        @pg.production("unused : main") 
        def unused(p):
            pass

case 2 -- Show Warning

        @pg.production("main : VALUE")
        def main(p):
            return p[0]

        @pg.production("unused : OTHER main")
        def unused(p):
            pass

case 3 -- No Warning

        @pg.production("main : VALUE")
        def main(p):
            return p[0]

        @pg.production("unused : VALUE main")
        def unused(p):
            pass

Now I'm quite puzzled about the meaning of this warning.

Activity

  1. nobodxbodon commented on Jun 8, 2021

    @nobodxbodon
    ContributorAuthor

    With some debugging, I realize that case 1 and 3 failed not because there was no warning, but because there were 2 warnings instead of 1. The additional warning was Token 'OTHER' is unused.

    So I adjust the case by removing 'OTHER', and it still gives warning "Production 'unused' is not reachable":

            pg = ParserGenerator(["VALUE"])
    
            @pg.production("main : VALUE")
            def main(p):
                return p[0]
    
            @pg.production("unused : main")
            def unused(p):
                pass

    Then, switch the order of the two production rules:

            pg = ParserGenerator(["VALUE"])
    
            @pg.production("unused : main")
            def unused(p):
                pass
    
            @pg.production("main : VALUE")
            def main(p):
                return p[0]

    Now it gives no warning.

    Seems a bug to me, as the order of production rules shouldn't have effects on the parsing outcome.

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