jsinger67 / parol

LL(k) and LALR(1) parser generator for Rust
https://jsinger67.github.io/
Apache License 2.0
190 stars 19 forks source link

Add #![allow(clippy::too_many_arguments)] to template_data.rs. #302

Closed kishiguro closed 8 months ago

kishiguro commented 8 months ago

Recently I had following clippy warnings for generated grammar trait. Here is a patch to suppress the warning.

$ ~/rust/libyang main* cargo clippy
warning: this function has too many arguments (10/7)
    --> src/yang_grammar_trait.rs:7844:5
     |
7844 | /     fn module_stmt(
7845 | |         &mut self,
7846 | |         _module: &ParseTreeType<'t>,
7847 | |         _identifier_arg_str: &ParseTreeType<'t>,
...    |
7854 | |         _r_brace: &ParseTreeType<'t>,
7855 | |     ) -> Result<()> {
     | |___________________^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
     = note: `#[warn(clippy::too_many_arguments)]` on by default

warning: this function has too many arguments (10/7)
    --> src/yang_grammar_trait.rs:8068:5
     |
8068 | /     fn submodule_stmt(
8069 | |         &mut self,
8070 | |         _submodule: &ParseTreeType<'t>,
8071 | |         _identifier_arg_str: &ParseTreeType<'t>,
...    |
8078 | |         _r_brace: &ParseTreeType<'t>,
8079 | |     ) -> Result<()> {
     | |___________________^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments

warning: `libyang` (lib) generated 2 warnings
    Finished dev [unoptimized + debuginfo] target(s) in 0.04s
jsinger67 commented 8 months ago

Hello @kishiguro, first of all thanks a lot for dealing with parol. I appreciate any kind of feedback and contribution.

The problem you encountered is actually already forseen. The command line tool provides an argument named --inner-attributes and the Builder provides a similar API called inner_attributes(). On both you can specifiy so called inner attributes, i.e. the ones at the beginning of a file (#![). They are later inserted into the generated files for you.

I know that there is a little shortage of tests regarding this feature. Therefore I would like you to test this for me and report me whether it worked for you.

Let me know if you need more information about applying one of those ways. I will give you further support.

kishiguro commented 8 months ago

@jsinger67 oh, i see. thanks for the detailed explanation. let me close this PR. parol is really great tool. i really admire your great work!