{"id":13500590,"url":"https://github.com/mattgreen/hython","last_synced_at":"2025-04-05T21:08:10.193Z","repository":{"id":18703235,"uuid":"21913596","full_name":"mattgreen/hython","owner":"mattgreen","description":"Haskell-powered Python 3 interpreter","archived":false,"fork":false,"pushed_at":"2017-08-01T00:18:19.000Z","size":562,"stargazers_count":580,"open_issues_count":0,"forks_count":29,"subscribers_count":23,"default_branch":"master","last_synced_at":"2024-10-06T04:07:00.697Z","etag":null,"topics":["haskell","interpreter","language","python"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattgreen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-16T19:11:46.000Z","updated_at":"2024-09-18T08:48:35.000Z","dependencies_parsed_at":"2022-09-07T10:41:46.496Z","dependency_job_id":null,"html_url":"https://github.com/mattgreen/hython","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattgreen%2Fhython","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattgreen%2Fhython/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattgreen%2Fhython/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattgreen%2Fhython/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattgreen","download_url":"https://codeload.github.com/mattgreen/hython/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399877,"owners_count":20932876,"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":["haskell","interpreter","language","python"],"created_at":"2024-07-31T22:01:06.251Z","updated_at":"2025-04-05T21:08:10.168Z","avatar_url":"https://github.com/mattgreen.png","language":"Haskell","readme":"# hython\n\nA toy Python 3 interpreter implemented in Haskell.\n\n## Introduction\n\nI wanted to learn Haskell, and I wanted a big project, so I decided to write a Python 3 interpreter. The result was extremely educational and easily the coolest project I've ever worked on. Because it's implemented in a naive fashion, it won't ever be a replacement for real Python implementations.\n\n**Note:** Hython only implements most of the Python3 _language_. It doesn't contain much of a standard library, which is a big part of what makes Python pleasant to use. Adding all of the necessary machinery needed for the existing Python 3 standard library to function is an enormous undertaking that I'm not interested in.\n\n## Status\n\nIt's finally done! Or at least, I'm declaring it that way.\n\n## Features\n\n * [x] Lexer\n * [x] Parser\n * [x] Most built-in data types, including `int`, `bool`, `string`, `list`, `dict` and `range`\n * [x] Common unary and binary operators on common data types\n * [x] A few built-in functions, including `print`\n * [x] Variable assignment and lookup, with support for `nonlocal` and `global` keywords\n * [x] Conditional expressions with `if` and `else`\n * [x] All loop constructs: `for` and `while` with support for `break` and `continue` within them\n * [x] Support for the `with` statement\n * [x] Destructuring (`(a,b) = [1,2]`)\n * [x] Functions, including nested functions, default parameters, and keyword parameters\n * [x] Splat (`*` and `**`) operators in caller argument lists\n * [x] Lambda expressions, with proper environment capture\n * [x] Classes, including inheritance and proper method resolution order\n * [x] Objects\n * [x] Exception handling via `try`, with support for handlers, frame unwinding, `finally` handlers, and `else`, along with some built-in exception classes\n * [x] Basic support for loading modules with the `import` statement\n * [x] Simple REPL\n * [x] Support for the `is` operator\n * [ ] Support for generators and `yield`\n * [ ] List/generator/dict/set comprehensions\n * [ ] Index slicing\n * [ ] Support for decorators / metaclasses\n * [ ] Multi-line input for the REPL\n\n## Code Metrics\n`sloccount` output as of 10/1/16:\n\n    Totals grouped by language (dominant language first):\n    haskell:       2159 (70.83%)\n    yacc:           580 (19.03%) # parser\n    python:         309 (10.14%) # lib\n\n## Examples\n\nSee the [test](https://github.com/mattgreen/hython/tree/master/test) directory for example code that works\n\n## Building and running\n\n1. Install [Stack](https://github.com/commercialhaskell/stack)\n\n2. Clone the repository:\n\n        $ git clone https://github.com/mattgreen/hython.git\n        $ cd hython\n\n3. Build:\n\n        $ make\n\n4. Run a file:\n\n        $ ./hython test/fib.py\n\n## REPL\n\nHython includes a simple REPL, which you can play around with:\n\n    $ ./hython\n\n## Test Suite\n\nHython's test suite is rather simple: it ensures the output of Hython matches that of the system's `python3` for each test file.\n\nTo run the automated test suite:\n\n    $ make test\n\n## Reference Information\n * [Python 3.4 Language Reference](https://docs.python.org/3.4/reference/)\n * [Alex + Happy Whitespace Handling](https://github.com/jmoy/alexhappy)\n * [berp](https://github.com/bjpop/berp)\n * [Language.Python](https://github.com/bjpop/language-python)\n","funding_links":[],"categories":["Haskell","Compilers and Interpreters"],"sub_categories":["Educational and Toy Projects"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattgreen%2Fhython","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattgreen%2Fhython","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattgreen%2Fhython/lists"}