{"id":22026057,"url":"https://github.com/amazingcoderpro/simple_interpreter","last_synced_at":"2025-03-23T11:14:46.087Z","repository":{"id":254547111,"uuid":"846866063","full_name":"amazingcoderpro/simple_interpreter","owner":"amazingcoderpro","description":"一个用 python 实现的简单python解释器，分版本逐步实现一个简单的python解释器功能，适合初学者了解解释器的工作原理。","archived":false,"fork":false,"pushed_at":"2025-03-14T07:16:55.000Z","size":111,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-14T08:26:32.136Z","etag":null,"topics":["demo","interpreter","python","python-interpreter","tutorial-code"],"latest_commit_sha":null,"homepage":"https://www.blog.amazingcoder.xyz","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amazingcoderpro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-24T07:01:43.000Z","updated_at":"2025-03-14T07:16:58.000Z","dependencies_parsed_at":"2024-11-30T07:25:29.306Z","dependency_job_id":"fe1c2108-90e7-48c5-b114-1ab462b419e8","html_url":"https://github.com/amazingcoderpro/simple_interpreter","commit_stats":null,"previous_names":["amazingcoderpro/simple_interpreter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amazingcoderpro%2Fsimple_interpreter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amazingcoderpro%2Fsimple_interpreter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amazingcoderpro%2Fsimple_interpreter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amazingcoderpro%2Fsimple_interpreter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amazingcoderpro","download_url":"https://codeload.github.com/amazingcoderpro/simple_interpreter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245090874,"owners_count":20559298,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["demo","interpreter","python","python-interpreter","tutorial-code"],"created_at":"2024-11-30T07:24:50.838Z","updated_at":"2025-03-23T11:14:46.063Z","avatar_url":"https://github.com/amazingcoderpro.png","language":"Python","readme":"# simple_interpreter (A python interpreter implemented in python.)\n一个用 python 实现的简单python解释器，分版本（与分支对应）逐步实现一个简单的python解释器功能，适合初学者了解解释器的工作原理\n\n## 版本说明\n为了方便渐进式学习进度，每一个版本都创建了一个独立的分支，比如 v1.0版本对应的分支名为 v1.0, 该分支只实现了 v1.0 的功能，以此类推，逐步进行功能迭代。\n### v1.0 \nonly support single-digit integers +\n\n支持整数的加法运算\n### v2.0 \nsupport multi-digit integers +/-, support process whitespace\n\n支持加法减法，支持处理表达式中的空格\n### v3.0 \nsupport to parse (recognize) and interpret arithmetic expressions that have any number of plus or minus operators in it, for example “7 - 3 + 2 - 1”.\n\n支持包含多个数字的加减表达式\n### v4.0 \nsupport to parse and interpret arithmetic expressions with any number of multiplication and division operators in them, for example “7 * 4 / 2 * 3”\n\n支持包含多个数字的乘除表达式\n### v5.0 \nsupport to handle valid arithmetic expressions containing integers and any number of addition, subtraction, multiplication, and division operators.\n\n支持包含多个数字的加减乘除混合表达式\n### v6.0 \nsupport to evaluates arithmetic expressions that have different operators and parentheses.\n\n支持包含括号的混合表达式处理\n### v7.0 \nusing ASTs represent the operator-operand model of arithmetic expressions.\n支持使用 AST (abstract syntax tree 抽象语法树）来表示算术表达式\n#### 语法树可视化\n```shell\npython genastdot.py \"7 + 3 * (10 / (12 / (3 + 1) - 1))\" \u003e ast.dot \u0026\u0026 dot -Tpng -o ast.png ast.dot\n```\n![ast.png](ast.png)\n\n执行之前需要先按照dot, 参考：https://graphviz.org/ \n\n### v8.0 \nsupport unary operators (+, -)\n```shell\n python genastdot.py \"5---2\" \u003e ast.dot \u0026\u0026 dot -Tpng -o ast_v8.png ast.dot    \n```\n![ast_v8.png](ast_v8.png)\n\n\n### v9.0 \nsupport to handle python assignment statements.\n\n```shell\npython interpreter.py assignments.txt\n```\n\n```shell\npython genastdot.py assignments.txt \u003e ast.dot \u0026\u0026 dot -Tpng -o ast_v9.png ast.dot  \n```\n\n### v10.0\n增加符号表记录变量的定义，以处理使用未处理的变量\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famazingcoderpro%2Fsimple_interpreter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famazingcoderpro%2Fsimple_interpreter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famazingcoderpro%2Fsimple_interpreter/lists"}