Pylite
A tiny python interpreter for educational purpose
Install / Use
/learn @linuxmooc/PyliteREADME
What is pylite?
pylite is a hobby python interpreter, which can tell you how python compiler and virtual machine works. It serves for educational purposes, so the code is kept as simple as possible.
pylite consists of two executables: pycom and pyvm. pycom is the compiler, which has 5000 LOC. pyvm is the virtual machine, which has 6000 LOC.
How to build?
- build pycom and pyvm
- cd pylite && make DEBUG=0
- add pycom and pyvm to PATH vaiable
- PATH=`pwd`/com:`pwd`/vm:$PATH
- run tests
- cd tests && ./run
- run a simple HttpServer
- cd httpd && pyvm server.py
- open the browser and access http://localhost:8080
Implemented features:
- builtin objects: list/dict/tuple/slice/range
- if/while/for
- function (closure is not supported)
- class (only support single inheritance)
- module
- exception handling
- a simple GC
Known bugs:
- pylite only use 4 spaces or TAB for indentation
- list/dict/tuple literals must be in single line
pylite介绍
pylite是一个用于编译原理教学的python解释器,通过学习它的源代码可以了解python编译器和虚拟机是如何工作的。
pylite包含两个可执行程序:pycom和pyvm。pycom是编译器,由5000行代码构成。pyvm是虚拟机,由6000行代码构成。
如何编译?
- 编译pycom和pyvm
- cd pylite && make DEBUG=0
- 将pycom和pyvm所在的目录加入PATH环境变量
- PATH=`pwd`/com:`pwd`/vm:$PATH
- 运行测试
- cd tests && ./run
- 运行一个简单的http服务器(综合了大部分语言特性)
- cd httpd && pyvm server.py
- 打开浏览器,访问http://localhost:8080
已经实现的特征:
- 常见的内置对象list/dict/tuple/slice/range
- 控制流语句if/while/for
- 函数(不支持闭包)
- 类(只支持单继承)
- 模块
- 异常处理
- 垃圾回收
Known bugs:
- 在缩进中,只能使用4空格或则TAB
- 必须在一行完成list/dict/tuple的字面表示,不能跨行
Related Skills
YC-Killer
2.7kA library of enterprise-grade AI agents designed to democratize artificial intelligence and provide free, open-source alternatives to overvalued Y Combinator startups. If you are excited about democratizing AI access & AI agents, please star ⭐️ this repository and use the link in the readme to join our open source AI research team.
best-practices-researcher
The most comprehensive Claude Code skills registry | Web Search: https://skills-registry-web.vercel.app
groundhog
398Groundhog's primary purpose is to teach people how Cursor and all these other coding agents work under the hood. If you understand how these coding assistants work from first principles, then you can drive these tools harder (or perhaps make your own!).
isf-agent
a repo for an agent that helps researchers apply for isf funding
