Open nobodxbodon opened 3 years ago
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.
Take the test case for example:
https://github.com/alex/rply/blob/19a9e08c486b2723a2e2378df6edb6a26e2df4a5/tests/test_warnings.py#L83
Below are three cases with changed
unused
production rule:case 1 -- No Warning
case 2 -- Show Warning
case 3 -- No Warning
Now I'm quite puzzled about the meaning of this warning.