There is "Exploring large-scale software" as an experiment that can be selected by the Department of Electronic and Information Engineering / Department of Electrical and Electronic Engineering (eeic), Faculty of Engineering, University of Tokyo. This is an improvement / extension of a large-scale program published as OSS (open source software), and it is difficult to grasp the whole picture, which cannot be touched by a small-scale program that is usually handled in class. It's about learning how to handle programs. We decided to explore Python, which we are familiar with in class.
-** Overview (a story of modifying Python and adding functions) ** ← Imma here
-Add C-like grammar to Python
・ As a logical operator&&Or||Or!To add
-Make logical values True and False correspond to true and false
・ Support not only else if but also else if
-Add auto-indent function to Python
-(Bonus) Add unless statement to Python
First, create a working directory (here ~ / cpython).
Duplicate the repository from Python3.10 (cpython) on Github using git clone.
terminal
$ mkdir cpython
$ cd cpython
$ git clone https://github.com/python/cpython
Create a Makefile with configure. At this time, use the --prefix option to finally decide where to place the program (here ~ / python-install). You can also add -O0 to the environment variable CFLAGS to lower the optimization level, and add -g to include the" debug symbol "in the executable file. This allows you to use gdb to follow the behavior of your program line by line.
Once you have created a Makefile with configure, compile and install it with make and make install.
terminal
$ CFLAGS="-g -O0" ./configure --prefix=/home/[username]/python-install/
$ make
$ make install
This completes the build, and you can start python by running ~ / python-install / bin / python3.
If you change the code, you need to do make clean and then make.
Start Emacs and go to ~ / python-install / bin / with the M-x shell command.
Once I was able to move it, I hit M-x gud-gdb and gdb --fullname python3 to start gdb and used it to track the program.
** Exploring large-scale software **
--This is the homepage of the experiment.
** Official CPython documentation (Changing CPython ’s Grammar) ** ** Official CPython documentation (Design of CPython ’s Compiler) **
--It describes which files should be changed when adding the syntax to python.
** GNU readline official documentation **
--This is the document referred to in Adding auto-indent function to Python.
** Introduction to modifying Python **
-This is an article by an EEIC senior who added an unless statement to Python. When modifying Python, I referred to what to start with.
Recommended Posts