]> granicus.if.org Git - python/commit
Refactor Parser/pgen and add documentation and explanations (GH-15373)
authorPablo Galindo <Pablogsal@gmail.com>
Thu, 22 Aug 2019 01:38:39 +0000 (02:38 +0100)
committerGitHub <noreply@github.com>
Thu, 22 Aug 2019 01:38:39 +0000 (02:38 +0100)
commit71876fa438f706b211360d8c205cb985906212ee
treea8804ad4a3a62b234c0b6e18a9f5c31836c22bc1
parent374be59b8e479afa8c7a8ae6e77e98915e2f6d45
Refactor Parser/pgen and add documentation and explanations (GH-15373)

* Refactor Parser/pgen and add documentation and explanations

To improve the readability and maintainability of the parser
generator perform the following transformations:

    * Separate the metagrammar parser in its own class to simplify
      the parser generator logic.

    * Create separate classes for DFAs and NFAs and move methods that
      act exclusively on them from the parser generator to these
      classes.

    * Add docstrings and comment documenting the process to go from
      the grammar file into NFAs and then DFAs. Detail some of the
      algorithms and give some background explanations of some concepts
      that will helps readers not familiar with the parser generation
      process.

    * Select more descriptive names for some variables and variables.

    * PEP8 formatting and quote-style homogenization.

The output of the parser generator remains the same (Include/graminit.h
and Python/graminit.c remain untouched by running the new parser generator).
Parser/pgen/__main__.py
Parser/pgen/automata.py [new file with mode: 0644]
Parser/pgen/grammar.py
Parser/pgen/keywordgen.py
Parser/pgen/metaparser.py [new file with mode: 0644]
Parser/pgen/pgen.py
Parser/pgen/token.py