diff --git a/developer-workflow/grammar.rst b/developer-workflow/grammar.rst index 7d6b40993f..2ba18ec225 100644 --- a/developer-workflow/grammar.rst +++ b/developer-workflow/grammar.rst @@ -28,18 +28,19 @@ Note: sometimes things mysteriously don't work. Before giving up, try ``make cl * :cpy-file:`Grammar/python.gram`: The grammar, with actions that build AST nodes. After changing it, run ``make regen-pegen`` (or ``build.bat --regen`` on Windows), to regenerate :cpy-file:`Parser/parser.c`. - (This runs Python's parser generator, ``Tools/peg_generator``). + (This runs Python's parser generator, :cpy-file:`Tools/peg_generator`). * :cpy-file:`Grammar/Tokens` is a place for adding new token types. After - changing it, run ``make regen-token`` to regenerate :cpy-file:`Include/token.h`, - :cpy-file:`Parser/token.c`, :cpy-file:`Lib/token.py` and - :cpy-file:`Doc/library/token-list.inc`. If you change both ``python.gram`` - and ``Tokens``, run ``make regen-token`` before ``make regen-pegen``. + changing it, run ``make regen-token`` to regenerate + :cpy-file:`Include/internal/pycore_token.h`, :cpy-file:`Parser/token.c`, + :cpy-file:`Lib/token.py` and :cpy-file:`Doc/library/token-list.inc`. + If you change both ``python.gram`` and ``Tokens``, + run ``make regen-token`` before ``make regen-pegen``. On Windows, ``build.bat --regen`` will regenerate both at the same time. * :cpy-file:`Parser/Python.asdl` may need changes to match the grammar. - Then run ``make regen-ast`` to regenerate :cpy-file:`Include/Python-ast.h` - and :cpy-file:`Python/Python-ast.c`. + Then run ``make regen-ast`` to regenerate + :cpy-file:`Include/internal/pycore_ast.h` and :cpy-file:`Python/Python-ast.c`. * :cpy-file:`Parser/tokenizer.c` contains the tokenization code. This is where you would add a new type of comment or string literal, for example. diff --git a/internals/compiler.rst b/internals/compiler.rst index 2785aab51d..a820ef2603 100644 --- a/internals/compiler.rst +++ b/internals/compiler.rst @@ -490,7 +490,7 @@ Finally, you need to introduce the use of the new bytecode. Altering places to change. You must add the case for a new opcode into the 'switch' statement in the ``stack_effect()`` function in :cpy-file:`Python/compile.c`. If the new opcode has a jump target, you will need to update macros and -'switch' statements in :cpy-file:`Python/peephole.c`. If it affects a control +'switch' statements in :cpy-file:`Python/compile.c`. If it affects a control flow or the block stack, you may have to update the ``frame_setlineno()`` function in :cpy-file:`Objects/frameobject.c`. :cpy-file:`Lib/dis.py` may need an update if the new opcode interprets its argument in a special way (like @@ -514,7 +514,8 @@ Code Objects ============ The result of ``PyAST_CompileObject()`` is a ``PyCodeObject`` which is defined in -:cpy-file:`Include/code.h`. And with that you now have executable Python bytecode! +:cpy-file:`Include/cpython/code.h`. And with that you now have executable +Python bytecode! The code objects (byte code) are executed in :cpy-file:`Python/ceval.c`. This file will also need a new case statement for the new opcode in the big switch @@ -579,18 +580,14 @@ Important Files * :cpy-file:`Python/symtable.c`: Generates a symbol table from AST. - * :cpy-file:`Python/peephole.c`: Optimizes the bytecode. - * :cpy-file:`Python/pyarena.c`: Implementation of the arena memory manager. - * :cpy-file:`Python/wordcode_helpers.h`: Helpers for generating bytecode. - * :cpy-file:`Python/opcode_targets.h`: One of the files that must be modified if :cpy-file:`Lib/opcode.py` is. * :cpy-file:`Include/` - * :cpy-file:`Include/code.h`: Header file for :cpy-file:`Objects/codeobject.c`; - contains definition of ``PyCodeObject``. + * :cpy-file:`Include/cpython/code.h`: Header file for + :cpy-file:`Objects/codeobject.c`; contains definition of ``PyCodeObject``. * :cpy-file:`Include/opcode.h`: One of the files that must be modified if :cpy-file:`Lib/opcode.py` is.