softdevteam / grmtools

Rust grammar tool libraries and binaries
Other
494 stars 32 forks source link

lpar:Unused rule #452

Closed liluyue closed 2 months ago

liluyue commented 2 months ago

Can we introduce a deliberate ignore pattern similar to the one that ignores variables starting with _ in Rust? Many times, new rules are introduced, but these rules are not mature enough. In order to avoid affecting existing functions, it is usually necessary to clean up or cut branches during compilation, which can be a bit troublesome

ltratt commented 2 months ago

I think %expect-unused (described in https://softdevteam.github.io/grmtools/master/book/errorrecovery.html#turning-lexing-errors-into-parsing-errors) covers this case.

liluyue commented 2 months ago

I see it. Just like Rust's error report, adding a doc information or repair method prompt makes it easy to know how to do it

ltratt commented 2 months ago

Just to make sure I've understood: %expect-unused covers your use case?

liluyue commented 2 months ago

Yes, but it's a bit cumbersome

ltratt commented 2 months ago

To some extent we're limited a bit by compatibility with Yacc. Maybe there's a neater way to do this, but I don't immediately have a good idea.

ratmice commented 2 months ago

One other thing worth mentioning is the unused rule error is a warning, which is often being treated as an error by default CTParserBuilder has show_warnings warnings_are_errors

though I don't recall off hand how nimbleparse behaves by default and if it differs.