Patchwork D7581: rust-configparser: regenerate parser.rs

login
register
mail settings
Submitter phabricator
Date Dec. 7, 2019, 10:57 p.m.
Message ID <differential-rev-PHID-DREV-l6tnsbhztwxa64hcena6-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/43641/
State Superseded
Headers show

Comments

phabricator - Dec. 7, 2019, 10:57 p.m.
indygreg created this revision.
Herald added subscribers: mercurial-devel, kevincox, durin42.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I couldn't get generate_parser.py to work without modification
  because my version of cargo-expand didn't accept a --release
  argument. I assume --release isn't supported in the newest version
  of this tool.
  
  Once I did get it to run, the auto-generated file wasn't formatted
  at all and was literally just a wall of unreadable tokens. It appears
  we were disabling rustfmt as part of generating the file. So I
  removed that and got a working generation of parser.rs!
  
  The changes to parser.rs reflect the new auto-generated content.
  
  I also snuck in the addition of a `rustfmt::skip` attribute. This
  is needed to avoid rustfmt complaining about the content of this
  file.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D7581

AFFECTED FILES
  rust/hg-core/src/configparser/generate_parser.py
  rust/hg-core/src/configparser/parser.rs

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: durin42, kevincox, mercurial-devel
phabricator - Dec. 8, 2019, 3:04 a.m.
indygreg added a comment.
indygreg abandoned this revision.


  The autogenerated parser.rs and its Python script to generate it have been removed in the latest version of this series.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7581/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7581

To: indygreg, #hg-reviewers
Cc: durin42, kevincox, mercurial-devel

Patch

diff --git a/rust/hg-core/src/configparser/parser.rs b/rust/hg-core/src/configparser/parser.rs
--- a/rust/hg-core/src/configparser/parser.rs
+++ b/rust/hg-core/src/configparser/parser.rs
@@ -1,8 +1,3 @@ 
-// Copyright 2018 Facebook, Inc.
-//
-// This software may be used and distributed according to the terms of the
-// GNU General Public License version 2 or any later version.
-
 
 // Generated by generate_parser.py. Do not edit manually. Instead, edit
 // spec.pest, then run generate_parser.py (require cargo-expand).
@@ -46,18 +41,20 @@ 
 
 pub(crate) struct ConfigParser;
 
+#[rustfmt::skip]
 impl ::pest::Parser<Rule> for ConfigParser {
-    fn parse<'i>(rule: Rule, input: &'i str)
-     ->
-         ::std::result::Result<::pest::iterators::Pairs<'i, Rule>,
-                               ::pest::error::Error<Rule>> {
+    fn parse<'i>(
+        rule: Rule,
+        input: &'i str,
+    ) -> ::std::result::Result<::pest::iterators::Pairs<'i, Rule>, ::pest::error::Error<Rule>> {
         mod rules {
             pub mod hidden {
                 use super::super::Rule;
                 #[inline]
                 #[allow(dead_code, non_snake_case, unused_variables)]
-                pub fn skip(state: Box<::pest::ParserState<Rule>>)
-                 -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+                pub fn skip(
+                    state: Box<::pest::ParserState<Rule>>,
+                ) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
                     Ok(state)
                 }
             }
@@ -65,587 +62,403 @@ 
                 use super::super::Rule;
                 #[inline]
                 #[allow(non_snake_case, unused_variables)]
-                pub fn new_line(state: Box<::pest::ParserState<Rule>>)
-                 -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
-                    state.rule(Rule::new_line,
-                               |state|
-                                   {
-                                       state.match_string("\n").or_else(|state|
-                                                                            {
-                                                                                state.match_string("\r\n")
-                                                                            })
-                                   })
+                pub fn new_line(
+                    state: Box<::pest::ParserState<Rule>>,
+                ) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+                    state.rule(Rule::new_line, |state| {
+                        state
+                            .match_string("\n")
+                            .or_else(|state| state.match_string("\r\n"))
+                    })
                 }
                 #[inline]
                 #[allow(non_snake_case, unused_variables)]
-                pub fn space(state: Box<::pest::ParserState<Rule>>)
-                 -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
-                    state.rule(Rule::space,
-                               |state|
-                                   {
-                                       state.match_string(" ").or_else(|state|
-                                                                           {
-                                                                               state.match_string("\t")
-                                                                           })
-                                   })
+                pub fn space(
+                    state: Box<::pest::ParserState<Rule>>,
+                ) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+                    state.rule(Rule::space, |state| {
+                        state
+                            .match_string(" ")
+                            .or_else(|state| state.match_string("\t"))
+                    })
                 }
                 #[inline]
                 #[allow(non_snake_case, unused_variables)]
-                pub fn comment_start(state: Box<::pest::ParserState<Rule>>)
-                 -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
-                    state.rule(Rule::comment_start,
-                               |state|
-                                   {
-                                       state.match_string("#").or_else(|state|
-                                                                           {
-                                                                               state.match_string(";")
-                                                                           })
-                                   })
+                pub fn comment_start(
+                    state: Box<::pest::ParserState<Rule>>,
+                ) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+                    state.rule(Rule::comment_start, |state| {
+                        state
+                            .match_string("#")
+                            .or_else(|state| state.match_string(";"))
+                    })
                 }
                 #[inline]
                 #[allow(non_snake_case, unused_variables)]
-                pub fn line(state: Box<::pest::ParserState<Rule>>)
-                 -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
-                    state.rule(Rule::line,
-                               |state|
-                                   {
-                                       state.atomic(::pest::Atomicity::Atomic,
-                                                    |state|
-                                                        {
-                                                            state.repeat(|state|
-                                                                             {
-                                                                                 state.sequence(|state|
-                                                                                                    {
-                                                                                                        state.lookahead(false,
-                                                                                                                        |state|
-                                                                                                                            {
-                                                                                                                                self::new_line(state)
-                                                                                                                            }).and_then(|state|
-                                                                                                                                            {
-                                                                                                                                                self::ANY(state)
-                                                                                                                                            })
-                                                                                                    })
-                                                                             })
-                                                        })
-                                   })
+                pub fn line(
+                    state: Box<::pest::ParserState<Rule>>,
+                ) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+                    state.rule(Rule::line, |state| {
+                        state.atomic(::pest::Atomicity::Atomic, |state| {
+                            state.repeat(|state| {
+                                state.sequence(|state| {
+                                    state
+                                        .lookahead(false, |state| self::new_line(state))
+                                        .and_then(|state| self::ANY(state))
+                                })
+                            })
+                        })
+                    })
                 }
                 #[inline]
                 #[allow(non_snake_case, unused_variables)]
-                pub fn value(state: Box<::pest::ParserState<Rule>>)
-                 -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
-                    state.atomic(::pest::Atomicity::CompoundAtomic,
-                                 |state|
-                                     {
-                                         state.rule(Rule::value,
-                                                    |state|
-                                                        {
-                                                            state.sequence(|state|
-                                                                               {
-                                                                                   self::line(state).and_then(|state|
-                                                                                                                  {
-                                                                                                                      state.repeat(|state|
-                                                                                                                                       {
-                                                                                                                                           state.sequence(|state|
-                                                                                                                                                              {
-                                                                                                                                                                  self::new_line(state).and_then(|state|
-                                                                                                                                                                                                     {
-                                                                                                                                                                                                         state.sequence(|state|
-                                                                                                                                                                                                                            {
-                                                                                                                                                                                                                                self::space(state).and_then(|state|
-                                                                                                                                                                                                                                                                {
-                                                                                                                                                                                                                                                                    state.repeat(|state|
-                                                                                                                                                                                                                                                                                     {
-                                                                                                                                                                                                                                                                                         self::space(state)
-                                                                                                                                                                                                                                                                                     })
-                                                                                                                                                                                                                                                                })
-                                                                                                                                                                                                                            })
-                                                                                                                                                                                                     }).and_then(|state|
-                                                                                                                                                                                                                     {
-                                                                                                                                                                                                                         self::line(state)
-                                                                                                                                                                                                                     })
-                                                                                                                                                              })
-                                                                                                                                       })
-                                                                                                                  })
-                                                                               })
+                pub fn value(
+                    state: Box<::pest::ParserState<Rule>>,
+                ) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+                    state.atomic(::pest::Atomicity::CompoundAtomic, |state| {
+                        state.rule(Rule::value, |state| {
+                            state.sequence(|state| {
+                                self::line(state).and_then(|state| {
+                                    state.repeat(|state| {
+                                        state.sequence(|state| {
+                                            self::new_line(state)
+                                                .and_then(|state| {
+                                                    state.sequence(|state| {
+                                                        self::space(state).and_then(|state| {
+                                                            state.repeat(|state| self::space(state))
                                                         })
-                                     })
+                                                    })
+                                                })
+                                                .and_then(|state| self::line(state))
+                                        })
+                                    })
+                                })
+                            })
+                        })
+                    })
                 }
                 #[inline]
                 #[allow(non_snake_case, unused_variables)]
-                pub fn equal_sign(state: Box<::pest::ParserState<Rule>>)
-                 -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
-                    state.rule(Rule::equal_sign,
-                               |state|
-                                   {
-                                       state.atomic(::pest::Atomicity::Atomic,
-                                                    |state|
-                                                        {
-                                                            state.sequence(|state|
-                                                                               {
-                                                                                   state.match_string("=").and_then(|state|
-                                                                                                                        {
-                                                                                                                            state.repeat(|state|
-                                                                                                                                             {
-                                                                                                                                                 self::space(state)
-                                                                                                                                             })
-                                                                                                                        })
-                                                                               })
-                                                        })
-                                   })
+                pub fn equal_sign(
+                    state: Box<::pest::ParserState<Rule>>,
+                ) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+                    state.rule(Rule::equal_sign, |state| {
+                        state.atomic(::pest::Atomicity::Atomic, |state| {
+                            state.sequence(|state| {
+                                state
+                                    .match_string("=")
+                                    .and_then(|state| state.repeat(|state| self::space(state)))
+                            })
+                        })
+                    })
                 }
                 #[inline]
                 #[allow(non_snake_case, unused_variables)]
-                pub fn config_name(state: Box<::pest::ParserState<Rule>>)
-                 -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
-                    state.rule(Rule::config_name,
-                               |state|
-                                   {
-                                       state.atomic(::pest::Atomicity::Atomic,
-                                                    |state|
-                                                        {
-                                                            state.sequence(|state|
-                                                                               {
-                                                                                   state.lookahead(false,
-                                                                                                   |state|
-                                                                                                       {
-                                                                                                           state.match_string("[").or_else(|state|
-                                                                                                                                               {
-                                                                                                                                                   state.match_string("=")
-                                                                                                                                               }).or_else(|state|
-                                                                                                                                                              {
-                                                                                                                                                                  state.match_string("%")
-                                                                                                                                                              }).or_else(|state|
-                                                                                                                                                                             {
-                                                                                                                                                                                 self::space(state)
-                                                                                                                                                                             }).or_else(|state|
-                                                                                                                                                                                            {
-                                                                                                                                                                                                self::comment_start(state)
-                                                                                                                                                                                            }).or_else(|state|
-                                                                                                                                                                                                           {
-                                                                                                                                                                                                               self::new_line(state)
-                                                                                                                                                                                                           })
-                                                                                                       }).and_then(|state|
-                                                                                                                       {
-                                                                                                                           self::ANY(state)
-                                                                                                                       }).and_then(|state|
-                                                                                                                                       {
-                                                                                                                                           state.repeat(|state|
-                                                                                                                                                            {
-                                                                                                                                                                state.sequence(|state|
-                                                                                                                                                                                   {
-                                                                                                                                                                                       state.lookahead(false,
-                                                                                                                                                                                                       |state|
-                                                                                                                                                                                                           {
-                                                                                                                                                                                                               state.match_string("=").or_else(|state|
-                                                                                                                                                                                                                                                   {
-                                                                                                                                                                                                                                                       self::new_line(state)
-                                                                                                                                                                                                                                                   })
-                                                                                                                                                                                                           }).and_then(|state|
-                                                                                                                                                                                                                           {
-                                                                                                                                                                                                                               self::ANY(state)
-                                                                                                                                                                                                                           })
-                                                                                                                                                                                   })
-                                                                                                                                                            })
-                                                                                                                                       })
-                                                                               })
-                                                        })
-                                   })
+                pub fn config_name(
+                    state: Box<::pest::ParserState<Rule>>,
+                ) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+                    state.rule(Rule::config_name, |state| {
+                        state.atomic(::pest::Atomicity::Atomic, |state| {
+                            state.sequence(|state| {
+                                state
+                                    .lookahead(false, |state| {
+                                        state
+                                            .match_string("[")
+                                            .or_else(|state| state.match_string("="))
+                                            .or_else(|state| state.match_string("%"))
+                                            .or_else(|state| self::space(state))
+                                            .or_else(|state| self::comment_start(state))
+                                            .or_else(|state| self::new_line(state))
+                                    })
+                                    .and_then(|state| self::ANY(state))
+                                    .and_then(|state| {
+                                        state.repeat(|state| {
+                                            state.sequence(|state| {
+                                                state
+                                                    .lookahead(false, |state| {
+                                                        state
+                                                            .match_string("=")
+                                                            .or_else(|state| self::new_line(state))
+                                                    })
+                                                    .and_then(|state| self::ANY(state))
+                                            })
+                                        })
+                                    })
+                            })
+                        })
+                    })
                 }
                 #[inline]
                 #[allow(non_snake_case, unused_variables)]
-                pub fn config_item(state: Box<::pest::ParserState<Rule>>)
-                 -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
-                    state.atomic(::pest::Atomicity::CompoundAtomic,
-                                 |state|
-                                     {
-                                         state.rule(Rule::config_item,
-                                                    |state|
-                                                        {
-                                                            state.sequence(|state|
-                                                                               {
-                                                                                   self::config_name(state).and_then(|state|
-                                                                                                                         {
-                                                                                                                             self::equal_sign(state)
-                                                                                                                         }).and_then(|state|
-                                                                                                                                         {
-                                                                                                                                             self::value(state)
-                                                                                                                                         })
-                                                                               })
-                                                        })
-                                     })
+                pub fn config_item(
+                    state: Box<::pest::ParserState<Rule>>,
+                ) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+                    state.atomic(::pest::Atomicity::CompoundAtomic, |state| {
+                        state.rule(Rule::config_item, |state| {
+                            state.sequence(|state| {
+                                self::config_name(state)
+                                    .and_then(|state| self::equal_sign(state))
+                                    .and_then(|state| self::value(state))
+                            })
+                        })
+                    })
                 }
                 #[inline]
                 #[allow(non_snake_case, unused_variables)]
-                pub fn left_bracket(state: Box<::pest::ParserState<Rule>>)
-                 -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
-                    state.rule(Rule::left_bracket,
-                               |state|
-                                   {
-                                       state.atomic(::pest::Atomicity::Atomic,
-                                                    |state|
-                                                        {
-                                                            state.match_string("[")
-                                                        })
-                                   })
+                pub fn left_bracket(
+                    state: Box<::pest::ParserState<Rule>>,
+                ) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+                    state.rule(Rule::left_bracket, |state| {
+                        state.atomic(::pest::Atomicity::Atomic, |state| state.match_string("["))
+                    })
                 }
                 #[inline]
                 #[allow(non_snake_case, unused_variables)]
-                pub fn right_bracket(state: Box<::pest::ParserState<Rule>>)
-                 -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
-                    state.rule(Rule::right_bracket,
-                               |state|
-                                   {
-                                       state.atomic(::pest::Atomicity::Atomic,
-                                                    |state|
-                                                        {
-                                                            state.match_string("]")
-                                                        })
-                                   })
+                pub fn right_bracket(
+                    state: Box<::pest::ParserState<Rule>>,
+                ) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+                    state.rule(Rule::right_bracket, |state| {
+                        state.atomic(::pest::Atomicity::Atomic, |state| state.match_string("]"))
+                    })
                 }
                 #[inline]
                 #[allow(non_snake_case, unused_variables)]
-                pub fn section_name(state: Box<::pest::ParserState<Rule>>)
-                 -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
-                    state.rule(Rule::section_name,
-                               |state|
-                                   {
-                                       state.atomic(::pest::Atomicity::Atomic,
-                                                    |state|
-                                                        {
-                                                            state.sequence(|state|
-                                                                               {
-                                                                                   state.sequence(|state|
-                                                                                                      {
-                                                                                                          state.lookahead(false,
-                                                                                                                          |state|
-                                                                                                                              {
-                                                                                                                                  state.match_string("]").or_else(|state|
-                                                                                                                                                                      {
-                                                                                                                                                                          self::new_line(state)
-                                                                                                                                                                      })
-                                                                                                                              }).and_then(|state|
-                                                                                                                                              {
-                                                                                                                                                  self::ANY(state)
-                                                                                                                                              })
-                                                                                                      }).and_then(|state|
-                                                                                                                      {
-                                                                                                                          state.repeat(|state|
-                                                                                                                                           {
-                                                                                                                                               state.sequence(|state|
-                                                                                                                                                                  {
-                                                                                                                                                                      state.lookahead(false,
-                                                                                                                                                                                      |state|
-                                                                                                                                                                                          {
-                                                                                                                                                                                              state.match_string("]").or_else(|state|
-                                                                                                                                                                                                                                  {
-                                                                                                                                                                                                                                      self::new_line(state)
-                                                                                                                                                                                                                                  })
-                                                                                                                                                                                          }).and_then(|state|
-                                                                                                                                                                                                          {
-                                                                                                                                                                                                              self::ANY(state)
-                                                                                                                                                                                                          })
-                                                                                                                                                                  })
-                                                                                                                                           })
-                                                                                                                      })
-                                                                               })
-                                                        })
-                                   })
+                pub fn section_name(
+                    state: Box<::pest::ParserState<Rule>>,
+                ) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+                    state.rule(Rule::section_name, |state| {
+                        state.atomic(::pest::Atomicity::Atomic, |state| {
+                            state.sequence(|state| {
+                                state
+                                    .sequence(|state| {
+                                        state
+                                            .lookahead(false, |state| {
+                                                state
+                                                    .match_string("]")
+                                                    .or_else(|state| self::new_line(state))
+                                            })
+                                            .and_then(|state| self::ANY(state))
+                                    })
+                                    .and_then(|state| {
+                                        state.repeat(|state| {
+                                            state.sequence(|state| {
+                                                state
+                                                    .lookahead(false, |state| {
+                                                        state
+                                                            .match_string("]")
+                                                            .or_else(|state| self::new_line(state))
+                                                    })
+                                                    .and_then(|state| self::ANY(state))
+                                            })
+                                        })
+                                    })
+                            })
+                        })
+                    })
                 }
                 #[inline]
                 #[allow(non_snake_case, unused_variables)]
-                pub fn section(state: Box<::pest::ParserState<Rule>>)
-                 -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
-                    state.atomic(::pest::Atomicity::CompoundAtomic,
-                                 |state|
-                                     {
-                                         state.rule(Rule::section,
-                                                    |state|
-                                                        {
-                                                            state.sequence(|state|
-                                                                               {
-                                                                                   self::left_bracket(state).and_then(|state|
-                                                                                                                          {
-                                                                                                                              self::section_name(state)
-                                                                                                                          }).and_then(|state|
-                                                                                                                                          {
-                                                                                                                                              self::right_bracket(state)
-                                                                                                                                          }).and_then(|state|
-                                                                                                                                                          {
-                                                                                                                                                              state.repeat(|state|
-                                                                                                                                                                               {
-                                                                                                                                                                                   self::space(state)
-                                                                                                                                                                               })
-                                                                                                                                                          })
-                                                                               })
-                                                        })
-                                     })
+                pub fn section(
+                    state: Box<::pest::ParserState<Rule>>,
+                ) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+                    state.atomic(::pest::Atomicity::CompoundAtomic, |state| {
+                        state.rule(Rule::section, |state| {
+                            state.sequence(|state| {
+                                self::left_bracket(state)
+                                    .and_then(|state| self::section_name(state))
+                                    .and_then(|state| self::right_bracket(state))
+                                    .and_then(|state| state.repeat(|state| self::space(state)))
+                            })
+                        })
+                    })
                 }
                 #[inline]
                 #[allow(non_snake_case, unused_variables)]
-                pub fn comment_line(state: Box<::pest::ParserState<Rule>>)
-                 -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
-                    state.rule(Rule::comment_line,
-                               |state|
-                                   {
-                                       state.atomic(::pest::Atomicity::Atomic,
-                                                    |state|
-                                                        {
-                                                            state.sequence(|state|
-                                                                               {
-                                                                                   self::comment_start(state).and_then(|state|
-                                                                                                                           {
-                                                                                                                               self::line(state)
-                                                                                                                           })
-                                                                               })
-                                                        })
-                                   })
+                pub fn comment_line(
+                    state: Box<::pest::ParserState<Rule>>,
+                ) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+                    state.rule(Rule::comment_line, |state| {
+                        state.atomic(::pest::Atomicity::Atomic, |state| {
+                            state.sequence(|state| {
+                                self::comment_start(state).and_then(|state| self::line(state))
+                            })
+                        })
+                    })
                 }
                 #[inline]
                 #[allow(non_snake_case, unused_variables)]
-                pub fn blank_line(state: Box<::pest::ParserState<Rule>>)
-                 -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
-                    state.rule(Rule::blank_line,
-                               |state|
-                                   {
-                                       state.atomic(::pest::Atomicity::Atomic,
-                                                    |state|
-                                                        {
-                                                            state.repeat(|state|
-                                                                             {
-                                                                                 self::space(state)
-                                                                             })
-                                                        })
-                                   })
+                pub fn blank_line(
+                    state: Box<::pest::ParserState<Rule>>,
+                ) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+                    state.rule(Rule::blank_line, |state| {
+                        state.atomic(::pest::Atomicity::Atomic, |state| {
+                            state.repeat(|state| self::space(state))
+                        })
+                    })
                 }
                 #[inline]
                 #[allow(non_snake_case, unused_variables)]
-                pub fn directive(state: Box<::pest::ParserState<Rule>>)
-                 -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
-                    state.atomic(::pest::Atomicity::CompoundAtomic,
-                                 |state|
-                                     {
-                                         state.rule(Rule::directive,
-                                                    |state|
-                                                        {
-                                                            state.sequence(|state|
-                                                                               {
-                                                                                   state.match_string("%").and_then(|state|
-                                                                                                                        {
-                                                                                                                            self::include(state).or_else(|state|
-                                                                                                                                                             {
-                                                                                                                                                                 self::unset(state)
-                                                                                                                                                             })
-                                                                                                                        })
-                                                                               })
-                                                        })
-                                     })
+                pub fn directive(
+                    state: Box<::pest::ParserState<Rule>>,
+                ) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+                    state.atomic(::pest::Atomicity::CompoundAtomic, |state| {
+                        state.rule(Rule::directive, |state| {
+                            state.sequence(|state| {
+                                state.match_string("%").and_then(|state| {
+                                    self::include(state).or_else(|state| self::unset(state))
+                                })
+                            })
+                        })
+                    })
                 }
                 #[inline]
                 #[allow(non_snake_case, unused_variables)]
-                pub fn include(state: Box<::pest::ParserState<Rule>>)
-                 -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
-                    state.atomic(::pest::Atomicity::CompoundAtomic,
-                                 |state|
-                                     {
-                                         state.rule(Rule::include,
-                                                    |state|
-                                                        {
-                                                            state.sequence(|state|
-                                                                               {
-                                                                                   state.match_string("include").and_then(|state|
-                                                                                                                              {
-                                                                                                                                  state.sequence(|state|
-                                                                                                                                                     {
-                                                                                                                                                         self::space(state).and_then(|state|
-                                                                                                                                                                                         {
-                                                                                                                                                                                             state.repeat(|state|
-                                                                                                                                                                                                              {
-                                                                                                                                                                                                                  self::space(state)
-                                                                                                                                                                                                              })
-                                                                                                                                                                                         })
-                                                                                                                                                     })
-                                                                                                                              }).and_then(|state|
-                                                                                                                                              {
-                                                                                                                                                  self::line(state)
-                                                                                                                                              })
-                                                                               })
-                                                        })
-                                     })
+                pub fn include(
+                    state: Box<::pest::ParserState<Rule>>,
+                ) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+                    state.atomic(::pest::Atomicity::CompoundAtomic, |state| {
+                        state.rule(Rule::include, |state| {
+                            state.sequence(|state| {
+                                state
+                                    .match_string("include")
+                                    .and_then(|state| {
+                                        state.sequence(|state| {
+                                            self::space(state).and_then(|state| {
+                                                state.repeat(|state| self::space(state))
+                                            })
+                                        })
+                                    })
+                                    .and_then(|state| self::line(state))
+                            })
+                        })
+                    })
                 }
                 #[inline]
                 #[allow(non_snake_case, unused_variables)]
-                pub fn unset(state: Box<::pest::ParserState<Rule>>)
-                 -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
-                    state.atomic(::pest::Atomicity::CompoundAtomic,
-                                 |state|
-                                     {
-                                         state.rule(Rule::unset,
-                                                    |state|
-                                                        {
-                                                            state.sequence(|state|
-                                                                               {
-                                                                                   state.match_string("unset").and_then(|state|
-                                                                                                                            {
-                                                                                                                                state.sequence(|state|
-                                                                                                                                                   {
-                                                                                                                                                       self::space(state).and_then(|state|
-                                                                                                                                                                                       {
-                                                                                                                                                                                           state.repeat(|state|
-                                                                                                                                                                                                            {
-                                                                                                                                                                                                                self::space(state)
-                                                                                                                                                                                                            })
-                                                                                                                                                                                       })
-                                                                                                                                                   })
-                                                                                                                            }).and_then(|state|
-                                                                                                                                            {
-                                                                                                                                                self::config_name(state)
-                                                                                                                                            }).and_then(|state|
-                                                                                                                                                            {
-                                                                                                                                                                state.repeat(|state|
-                                                                                                                                                                                 {
-                                                                                                                                                                                     self::space(state)
-                                                                                                                                                                                 })
-                                                                                                                                                            })
-                                                                               })
-                                                        })
-                                     })
+                pub fn unset(
+                    state: Box<::pest::ParserState<Rule>>,
+                ) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+                    state.atomic(::pest::Atomicity::CompoundAtomic, |state| {
+                        state.rule(Rule::unset, |state| {
+                            state.sequence(|state| {
+                                state
+                                    .match_string("unset")
+                                    .and_then(|state| {
+                                        state.sequence(|state| {
+                                            self::space(state).and_then(|state| {
+                                                state.repeat(|state| self::space(state))
+                                            })
+                                        })
+                                    })
+                                    .and_then(|state| self::config_name(state))
+                                    .and_then(|state| state.repeat(|state| self::space(state)))
+                            })
+                        })
+                    })
+                }
+                #[inline]
+                #[allow(non_snake_case, unused_variables)]
+                pub fn compound(
+                    state: Box<::pest::ParserState<Rule>>,
+                ) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+                    self::config_item(state)
+                        .or_else(|state| self::section(state))
+                        .or_else(|state| self::comment_line(state))
+                        .or_else(|state| self::directive(state))
+                        .or_else(|state| self::blank_line(state))
                 }
                 #[inline]
                 #[allow(non_snake_case, unused_variables)]
-                pub fn compound(state: Box<::pest::ParserState<Rule>>)
-                 -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
-                    self::config_item(state).or_else(|state|
-                                                         {
-                                                             self::section(state)
-                                                         }).or_else(|state|
-                                                                        {
-                                                                            self::comment_line(state)
-                                                                        }).or_else(|state|
-                                                                                       {
-                                                                                           self::directive(state)
-                                                                                       }).or_else(|state|
-                                                                                                      {
-                                                                                                          self::blank_line(state)
-                                                                                                      })
-                }
-                #[inline]
-                #[allow(non_snake_case, unused_variables)]
-                pub fn file(state: Box<::pest::ParserState<Rule>>)
-                 -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
-                    state.sequence(|state|
-                                       {
-                                           self::SOI(state).and_then(|state|
-                                                                         {
-                                                                             super::hidden::skip(state)
-                                                                         }).and_then(|state|
-                                                                                         {
-                                                                                             self::compound(state)
-                                                                                         }).and_then(|state|
-                                                                                                         {
-                                                                                                             super::hidden::skip(state)
-                                                                                                         }).and_then(|state|
-                                                                                                                         {
-                                                                                                                             state.sequence(|state|
-                                                                                                                                                {
-                                                                                                                                                    state.optional(|state|
-                                                                                                                                                                       {
-                                                                                                                                                                           state.sequence(|state|
-                                                                                                                                                                                              {
-                                                                                                                                                                                                  self::new_line(state).and_then(|state|
-                                                                                                                                                                                                                                     {
-                                                                                                                                                                                                                                         super::hidden::skip(state)
-                                                                                                                                                                                                                                     }).and_then(|state|
-                                                                                                                                                                                                                                                     {
-                                                                                                                                                                                                                                                         self::compound(state)
-                                                                                                                                                                                                                                                     })
-                                                                                                                                                                                              }).and_then(|state|
-                                                                                                                                                                                                              {
-                                                                                                                                                                                                                  state.repeat(|state|
-                                                                                                                                                                                                                                   {
-                                                                                                                                                                                                                                       state.sequence(|state|
-                                                                                                                                                                                                                                                          {
-                                                                                                                                                                                                                                                              super::hidden::skip(state).and_then(|state|
-                                                                                                                                                                                                                                                                                                      {
-                                                                                                                                                                                                                                                                                                          state.sequence(|state|
-                                                                                                                                                                                                                                                                                                                             {
-                                                                                                                                                                                                                                                                                                                                 self::new_line(state).and_then(|state|
-                                                                                                                                                                                                                                                                                                                                                                    {
-                                                                                                                                                                                                                                                                                                                                                                        super::hidden::skip(state)
-                                                                                                                                                                                                                                                                                                                                                                    }).and_then(|state|
-                                                                                                                                                                                                                                                                                                                                                                                    {
-                                                                                                                                                                                                                                                                                                                                                                                        self::compound(state)
-                                                                                                                                                                                                                                                                                                                                                                                    })
-                                                                                                                                                                                                                                                                                                                             })
-                                                                                                                                                                                                                                                                                                      })
-                                                                                                                                                                                                                                                          })
-                                                                                                                                                                                                                                   })
-                                                                                                                                                                                                              })
-                                                                                                                                                                       })
-                                                                                                                                                })
-                                                                                                                         }).and_then(|state|
-                                                                                                                                         {
-                                                                                                                                             super::hidden::skip(state)
-                                                                                                                                         }).and_then(|state|
-                                                                                                                                                         {
-                                                                                                                                                             self::EOI(state)
-                                                                                                                                                         })
-                                       })
+                pub fn file(
+                    state: Box<::pest::ParserState<Rule>>,
+                ) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+                    state.sequence(|state| {
+                        self::SOI(state)
+                            .and_then(|state| super::hidden::skip(state))
+                            .and_then(|state| self::compound(state))
+                            .and_then(|state| super::hidden::skip(state))
+                            .and_then(|state| {
+                                state.sequence(|state| {
+                                    state.optional(|state| {
+                                        state
+                                            .sequence(|state| {
+                                                self::new_line(state)
+                                                    .and_then(|state| super::hidden::skip(state))
+                                                    .and_then(|state| self::compound(state))
+                                            })
+                                            .and_then(|state| {
+                                                state.repeat(|state| {
+                                                    state.sequence(|state| {
+                                                        super::hidden::skip(state).and_then(
+                                                            |state| {
+                                                                state.sequence(|state| {
+                                                                    self::new_line(state)
+                                                                        .and_then(|state| {
+                                                                            super::hidden::skip(
+                                                                                state,
+                                                                            )
+                                                                        })
+                                                                        .and_then(|state| {
+                                                                            self::compound(state)
+                                                                        })
+                                                                })
+                                                            },
+                                                        )
+                                                    })
+                                                })
+                                            })
+                                    })
+                                })
+                            })
+                            .and_then(|state| super::hidden::skip(state))
+                            .and_then(|state| self::EOI(state))
+                    })
                 }
                 #[inline]
                 #[allow(dead_code, non_snake_case, unused_variables)]
-                pub fn SOI(state: Box<::pest::ParserState<Rule>>)
-                 -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+                pub fn ANY(
+                    state: Box<::pest::ParserState<Rule>>,
+                ) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+                    state.skip(1)
+                }
+                #[inline]
+                #[allow(dead_code, non_snake_case, unused_variables)]
+                pub fn SOI(
+                    state: Box<::pest::ParserState<Rule>>,
+                ) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
                     state.start_of_input()
                 }
                 #[inline]
                 #[allow(dead_code, non_snake_case, unused_variables)]
-                pub fn EOI(state: Box<::pest::ParserState<Rule>>)
-                 -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
+                pub fn EOI(
+                    state: Box<::pest::ParserState<Rule>>,
+                ) -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
                     state.rule(Rule::EOI, |state| state.end_of_input())
                 }
-                #[inline]
-                #[allow(dead_code, non_snake_case, unused_variables)]
-                pub fn ANY(state: Box<::pest::ParserState<Rule>>)
-                 -> ::pest::ParseResult<Box<::pest::ParserState<Rule>>> {
-                    state.skip(1)
-                }
             }
             pub use self::visible::*;
         }
-        ::pest::state(input,
-                      |state|
-                          {
-                              match rule {
-                                  Rule::new_line => rules::new_line(state),
-                                  Rule::space => rules::space(state),
-                                  Rule::comment_start =>
-                                  rules::comment_start(state),
-                                  Rule::line => rules::line(state),
-                                  Rule::value => rules::value(state),
-                                  Rule::equal_sign =>
-                                  rules::equal_sign(state),
-                                  Rule::config_name =>
-                                  rules::config_name(state),
-                                  Rule::config_item =>
-                                  rules::config_item(state),
-                                  Rule::left_bracket =>
-                                  rules::left_bracket(state),
-                                  Rule::right_bracket =>
-                                  rules::right_bracket(state),
-                                  Rule::section_name =>
-                                  rules::section_name(state),
-                                  Rule::section => rules::section(state),
-                                  Rule::comment_line =>
-                                  rules::comment_line(state),
-                                  Rule::blank_line =>
-                                  rules::blank_line(state),
-                                  Rule::directive => rules::directive(state),
-                                  Rule::include => rules::include(state),
-                                  Rule::unset => rules::unset(state),
-                                  Rule::compound => rules::compound(state),
-                                  Rule::file => rules::file(state),
-                                  Rule::EOI => rules::EOI(state),
-                              }
-                          })
+        ::pest::state(input, |state| match rule {
+            Rule::new_line => rules::new_line(state),
+            Rule::space => rules::space(state),
+            Rule::comment_start => rules::comment_start(state),
+            Rule::line => rules::line(state),
+            Rule::value => rules::value(state),
+            Rule::equal_sign => rules::equal_sign(state),
+            Rule::config_name => rules::config_name(state),
+            Rule::config_item => rules::config_item(state),
+            Rule::left_bracket => rules::left_bracket(state),
+            Rule::right_bracket => rules::right_bracket(state),
+            Rule::section_name => rules::section_name(state),
+            Rule::section => rules::section(state),
+            Rule::comment_line => rules::comment_line(state),
+            Rule::blank_line => rules::blank_line(state),
+            Rule::directive => rules::directive(state),
+            Rule::include => rules::include(state),
+            Rule::unset => rules::unset(state),
+            Rule::compound => rules::compound(state),
+            Rule::file => rules::file(state),
+            Rule::EOI => rules::EOI(state),
+        })
     }
 }
diff --git a/rust/hg-core/src/configparser/generate_parser.py b/rust/hg-core/src/configparser/generate_parser.py
--- a/rust/hg-core/src/configparser/generate_parser.py
+++ b/rust/hg-core/src/configparser/generate_parser.py
@@ -36,6 +36,8 @@ 
         with open(os.path.join(tmp_root, "src", "lib.rs"), "w") as f:
             f.write(
                 """
+use pest_derive::*;
+
 #[derive(Parser)]
 #[grammar = "spec.pest"]
 pub(crate) struct ConfigParser;
@@ -44,9 +46,8 @@ 
 
         # Run cargo-expand
         env = os.environ.copy()
-        env["RUSTFMT"] = "false"
         expanded = subprocess.check_output(
-            ["cargo-expand", "--release"], env=env, cwd=tmp_root
+            ["cargo-expand"], env=env, cwd=tmp_root
         )
         expanded = expanded.decode("utf-8")
 
@@ -67,6 +68,7 @@ 
 
 pub(crate) struct ConfigParser;
 
+#[rustfmt::skip]
 {parser_impl}
 """