90 captures
14 Dec 2017 - 20 Jun 2025
Oct NOV Dec
25
2019 2020 2021
success
fail

About this capture

COLLECTED BY

Collection: Common Crawl

Web crawl data from Common Crawl.
TIMESTAMPS

The Wayback Machine - http://web.archive.org/web/20201125085426/https://devguide.python.org/grammar/
 

Navigation



index

next |

previous |


Python »
  Python Developer's Guide »  
|  







24. Changing CPythons Grammar


24.1. Abstract


Theres more to changing Pythons grammar than editing Grammar/python.gram. Heres a checklist.

NOTE: These instructions are for Python 3.9 and beyond. Earlier versions use a different parser technology. You probably shouldnt try to change the grammar of earlier Python versions, but if you really want to, use GitHub to track down the earlier version of this file in the devguide. (Python 3.9 itself actually supports both parsers; the old parser can be invoked by passing -X oldparser.)


24.2. Checklist


Note: sometimes things mysteriously dont work. Before giving up, try make clean.


Grammar/python.gram: The grammar, with actions that build AST nodes. After changing it, run make regen-pegen, to regenerate Parser/parser.c. (This runs Pythons parser generator, Tools/peg_generator).

Grammar/Tokens is a place for adding new token types. After changing it, run make regen-token to regenerate Include/token.h, Parser/token.c, Lib/token.py and Doc/library/token-list.inc. If you change both python.gram and Tokens, run make regen-token before make regen-pegen.

Parser/Python.asdl may need changes to match the grammar. Then run make regen-ast to regenerate Include/Python-ast.h and Python/Python-ast.c.

Parser/tokenizer.c contains the tokenization code. This is where you would add a new type of comment or string literal, for example.

Python/ast.c will need changes to validate AST objects involved with the grammar change.

Python/ast_unparse.c will need changes to unparse AST objects involved with the grammar change (unparsing is used to turn annotations into strings per PEP 563).

The Design of CPythons Compiler has its own page.

_Unparser in the Lib/ast.py file may need changes to accommodate any modifications in the AST nodes.

Doc/library/ast.rst may need to be updated to reflect changes to AST nodes.

Add some usage of your new syntax to test_grammar.py.

Certain changes may require tweaks to the library module pyclbr.

Lib/tokenize.py needs changes to match changes to the tokenizer.

Documentation must be written! Specifically, one or more of the pages in Doc/reference/ will need to be updated.



 




Table of Contents



24. Changing CPythons Grammar

24.1. Abstract

24.2. Checklist



Sections



1. Getting Started

2. Where to Get Help

3. Lifecycle of a Pull Request

4. Running & Writing Tests

5. Increase Test Coverage

6. Helping with Documentation

7. Documenting Python

8. Silence Warnings From the Test Suite

9. Fixing easy Issues (and Beyond)

10. Issue Tracking

11. Triaging an Issue

12. Following Pythons Development

13. Porting Python to a new platform

14. How to Become a Core Developer

15. Developer Log

16. Accepting Pull Requests

17. Development Cycle

18. Continuous Integration

19. Adding to the Stdlib

20. Changing the Python Language

21. Experts Index

22. gdb Support

23. Exploring CPythons Internals

24. Changing CPythons Grammar

24.1. Abstract

24.2. Checklist



25. Design of CPythons Compiler

26. Design of CPythons Garbage Collector

27. Updating standard library extension modules

28. Coverity Scan

29. Dynamic Analysis with Clang

30. Running a buildbot worker

31. Core Developer Motivations and Affiliations

32. Git Bootcamp and Cheat Sheet

33. Appendix: Topics

Previous topic


23. Exploring CPythons Internals

Next topic


25. Design of CPythons Compiler

This Page



Show Source  







Navigation



index

next |

previous |


Python »
  Python Developer's Guide »  
|  



© Copyright 2011-2020, Python Software Foundation.  
The Python Software Foundation is a non-profit corporation. Please donate.
 
Last updated on Nov 10, 2020.  Found a bug?
 Created using Sphinx 1.8.5.