{"id":18162729,"url":"https://github.com/sco1/pylox","last_synced_at":"2025-05-07T22:47:00.896Z","repository":{"id":37951962,"uuid":"421557693","full_name":"sco1/pylox","owner":"sco1","description":"A Python implementation of the Lox programming language. Check out https://craftinginterpreters.com/","archived":false,"fork":false,"pushed_at":"2025-04-08T14:32:10.000Z","size":420,"stargazers_count":4,"open_issues_count":14,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-07T22:46:51.144Z","etag":null,"topics":["lox","lox-interpreter","python","python3","python310"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sco1.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2021-10-26T19:26:33.000Z","updated_at":"2025-04-08T14:32:16.000Z","dependencies_parsed_at":"2024-01-01T18:32:24.043Z","dependency_job_id":"0ad34dfb-1cbc-49a9-9c54-3f1bb4093aac","html_url":"https://github.com/sco1/pylox","commit_stats":{"total_commits":125,"total_committers":2,"mean_commits":62.5,"dds":0.128,"last_synced_commit":"0e8e595f81ac1f90d3fce2ab2f26beef8a8d89c3"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":"sco1/py-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sco1%2Fpylox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sco1%2Fpylox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sco1%2Fpylox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sco1%2Fpylox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sco1","download_url":"https://codeload.github.com/sco1/pylox/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252967984,"owners_count":21833247,"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":["lox","lox-interpreter","python","python3","python310"],"created_at":"2024-11-02T10:05:04.773Z","updated_at":"2025-05-07T22:47:00.884Z","avatar_url":"https://github.com/sco1.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pylox\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/sco1-pylox/0.5.1?logo=python\u0026logoColor=FFD43B)](https://pypi.org/project/sco1-pylox/)\n[![PyPI](https://img.shields.io/pypi/v/sco1-pylox?logo=Python\u0026logoColor=FFD43B)](https://pypi.org/project/sco1-pylox/)\n[![PyPI - License](https://img.shields.io/pypi/l/sco1-pylox?color=magenta)](https://github.com/sco1/sco1-pylox/blob/main/LICENSE)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/sco1/pylox/main.svg)](https://results.pre-commit.ci/latest/github/sco1/pylox/main)\n\n## Introduction\nThis is my Python implementation of an interpreter for the Lox programming language from Robert Nystrom's *[Crafting Interpreters](https://craftinginterpreters.com/)*.\n\n## Python?\nWhile the text is implemented in Java and C as its high \u0026 low-level implementations, I have no idea how to write either of them! Instead, I'll be using Python for the high-level implementation \u0026 eventually Rust for the low-level imeplementation.\n\n## Differences From Text\nFor the sake of fitting within a decently sized text, the fully implemented Lox spec omits features that users of other programming languages may miss. Often these are discussed as notes within a chapter, or presented as challenges at the end of a chapter. Significant difference in this implementation from the text reference are noted below.\n### Defined by Challenges\n  * (Chapter 4): Arbitrarily nested block comments (`/* ... */`)\n  * (Chapter 9): `break` statements are available for `for` and `while` loops\n### User Choice\n  * Division by zero returns `NaN` (Python's `float('nan')`)\n  * Strings may be defined using either `\"` or `'`\n  * Modulo operator (`%`)\n  * Power operator (`^`)\n  * Integer division operator (`\\`)\n  * Both floats and integers are represented\n    * Return type from operations follows Python3's semantics\n  * Containers\n    * `array()`\n  * A basic `include` header system\n    * Supports \"stdlib\" imports (`\u003cheader_name\u003e`) and path imports (`\"path/to/file\"`)\n    * Recursive `include` not supported\n    * Imported source assumed to be valid code\n\n### Additional Built-ins:\nUnless otherwise noted, behavior mirrors the similarly named Python function.\n\n#### General\n  * `input`\n  * `len`\n  * `ord`\n  * `read_text` (via `pathlib.Path.read_text`)\n  * `str2num`\n  * `string_array`\n    * Gives a `LoxArray` whose contents are equivalent to `collections.deque(\u003csome string\u003e)`\n\n#### Math\n  * `abs`\n  * `ceil`\n  * `divmod`\n  * `floor`\n  * `max`\n  * `min`\n\n#### Regex\nFor methods whose Python equivalent returns [Match objects](https://docs.python.org/3/library/re.html#match-objects), a `LoxArray` is returned. The first value in the array will always correspond to `match.group(0)`; if the pattern contains one or more groups then the array will match the output of `match.groups()`\n\n  * `re_findall`\n  * `re_match`\n  * `re_search`\n  * `re_sub`\n\n#### Stats\n  * `mean`\n  * `median`\n  * `mode`\n  * `std`\n\n### Pure lox headers\n  * `\u003carray_sum\u003e`\n  * `\u003chello_world\u003e`\n  * `\u003cmap\u003e`\n  * `\u003csplit_on\u003e`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsco1%2Fpylox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsco1%2Fpylox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsco1%2Fpylox/lists"}