{"id":24506759,"url":"https://github.com/olegkorol/pylox","last_synced_at":"2025-03-15T08:45:47.870Z","repository":{"id":268931859,"uuid":"905879402","full_name":"olegkorol/pylox","owner":"olegkorol","description":"A simple language implementation of Lox, written in Python. Includes a lexer, parser and interpreter.","archived":false,"fork":false,"pushed_at":"2025-01-21T17:19:21.000Z","size":117,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-21T18:28:21.486Z","etag":null,"topics":["interpreter","language","lexer","lox-interpreter","parser"],"latest_commit_sha":null,"homepage":"","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/olegkorol.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-12-19T17:51:26.000Z","updated_at":"2025-01-21T17:19:25.000Z","dependencies_parsed_at":"2025-01-11T15:32:24.230Z","dependency_job_id":"c0b8f76f-a78b-43a8-8f07-8d0c8895476e","html_url":"https://github.com/olegkorol/pylox","commit_stats":null,"previous_names":["olegkorol/codecrafters-interpreter-python","olegkorol/pylox"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olegkorol%2Fpylox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olegkorol%2Fpylox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olegkorol%2Fpylox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olegkorol%2Fpylox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/olegkorol","download_url":"https://codeload.github.com/olegkorol/pylox/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243707307,"owners_count":20334615,"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":["interpreter","language","lexer","lox-interpreter","parser"],"created_at":"2025-01-21T23:39:42.303Z","updated_at":"2025-03-15T08:45:47.852Z","avatar_url":"https://github.com/olegkorol.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyLox\n\n![image](https://craftinginterpreters.com/image/a-map-of-the-territory/mountain.png)\n\u003csup\u003e*Image from [Crafting Interpreters](https://craftinginterpreters.com/) by Robert Nystrom*\u003c/sup\u003e\n\nThis is a language implementation of the [Lox programming language](https://craftinginterpreters.com/the-lox-language.html), written in Python.\nIt includes:\n\n- A **lexer** (aka. scanner)\n- An AST (Abstract Syntax Tree) **parser**\n- A tree-walk **interpreter**\n\nThe implementation is based on the book [Crafting Interpreters](https://craftinginterpreters.com/) by Robert Nystrom and\nwas crafted with the help of the unit tests from the [\"Build your own Interpreter\"](https://app.codecrafters.io/courses/interpreter/overview) challenge by CodeCrafters.\n\n## Grammar\n\n### Program Structure\n\n```text\nprogram        → declaration* EOF ;\n```\n\n### Declarations and Statements\n\n```text\ndeclaration    → funDecl\n               | varDecl\n               | statement ;\n\nfunDecl        → \"fun\" function ;\nfunction       → IDENTIFIER \"(\" parameters? \")\" block ;\nparameters     → IDENTIFIER ( \",\" IDENTIFIER )* ;\n\nvarDecl        → \"var\" IDENTIFIER ( \"=\" expression )? \";\" ;\n\nstatement      → exprStmt\n               | forStmt\n               | ifStmt\n               | printStmt\n               | returnStmt\n               | whileStmt\n               | block ;\n\nblock          → \"{\" declaration* \"}\" ;\nexprStmt       → expression \";\" ;\nforStmt        → \"for\" \"(\" ( varDecl | exprStmt | \";\" )\n                 expression? \";\"\n                 expression? \")\" statement ;\nifStmt         → \"if\" \"(\" expression \")\" statement\n                 ( \"else\" statement )? ;\nprintStmt      → \"print\" expression \";\" ;\nreturnStmt     → \"return\" expression? \";\" ;\nwhileStmt      → \"while\" \"(\" expression \")\" statement ;\n```\n\n### Expressions\n\n```text\nexpression     → assignment ;\nassignment     → IDENTIFIER \"=\" assignment\n               | logic_or ;\nlogic_or       → logic_and ( \"or\" logic_and )* ;\nlogic_and      → equality ( \"and\" equality )* ;\nequality       → comparison ( ( \"!=\" | \"==\" ) comparison )* ;\ncomparison     → term ( ( \"\u003e\" | \"\u003e=\" | \"\u003c\" | \"\u003c=\" ) term )* ;\nterm           → factor ( ( \"-\" | \"+\" ) factor )* ;\nfactor         → unary ( ( \"/\" | \"*\" ) unary )* ;\nunary          → ( \"!\" | \"-\" ) unary | call ;\ncall           → primary ( \"(\" arguments? \")\" )* ;\nprimary        → NUMBER | STRING | \"true\" | \"false\" | \"nil\" | \"(\" expression \")\" | IDENTIFIER ;\n\narguments      → expression ( \",\" expression )* ;\n```\n\n## Usage\n\nWrite your code in e.g. `test.lox` and run it with:\n\n```sh\n./lox.sh run test.lox\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folegkorol%2Fpylox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folegkorol%2Fpylox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folegkorol%2Fpylox/lists"}