{"id":20248024,"url":"https://github.com/eddiecorrigall/elang","last_synced_at":"2026-06-08T00:31:23.353Z","repository":{"id":83993679,"uuid":"437205333","full_name":"eddiecorrigall/elang","owner":"eddiecorrigall","description":"Toy programming language interpreted with Python","archived":false,"fork":false,"pushed_at":"2022-10-17T13:12:56.000Z","size":12034,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-03T16:11:23.704Z","etag":null,"topics":["ast","interpreter","lexer","parser","python","walker"],"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/eddiecorrigall.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":"2021-12-11T06:22:28.000Z","updated_at":"2023-07-12T13:05:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"e845f568-837f-424f-bd84-0f842a33e90f","html_url":"https://github.com/eddiecorrigall/elang","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eddiecorrigall/elang","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddiecorrigall%2Felang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddiecorrigall%2Felang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddiecorrigall%2Felang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddiecorrigall%2Felang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eddiecorrigall","download_url":"https://codeload.github.com/eddiecorrigall/elang/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddiecorrigall%2Felang/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34043822,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-07T02:00:07.652Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["ast","interpreter","lexer","parser","python","walker"],"created_at":"2024-11-14T09:44:44.272Z","updated_at":"2026-06-08T00:31:23.336Z","avatar_url":"https://github.com/eddiecorrigall.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"elang\n=====\n\nToy programming language written by yours truely.\n- Purely Python with standard library\n- Parser: recursive descent\n- Expressions in polish notation\n- Abstract Syntax Tree Walker\n- Literals: integer, character, string, array, map\n- Scope / name binding\n\n![Mandlebrot Demo](./demo.gif)\n\n## Use CLI\n\n```bash\n# Create virtual environment\npython3 -m venv venv\n\n# Activate virual environment\nsource venv/bin/activate\n\n# Install depedencies\npip3 install -r requirements.txt\n\n# Add parent working directory to PATH\nexport PATH=\"$(pwd):$PATH\"\n\n# List help contents for elang\nelang --help\n\n# Run test suit\nelang test\n\n# Deactivate virtual environment\ndeactivate\n```\n\n### Example\n\nProduce Abstract Syntax Tree as standard output in JSON format.\n\n```bash\n$ echo 'print(\"Hello world\");' | elang lex | elang parse --format json\n{\n  \"type\": \"SEQUENCE\",\n  \"left\": {\n    \"type\": \"PRINT_STRING\",\n    \"left\": {\n      \"type\": \"STR\",\n      \"value\": \"\\\"Hello world\\\"\"\n    }\n  }\n}\n```\n\nRun program.\n\n```bash\n$ echo 'print(\"Hello world\");' | elang run\nHello world\n```\n\n## Python API\n\n```python\nlex = Lexer()\ntokens = Lexer.from_token_file(file)\ntokens = lex.from_program_file(file)\ntokens = lex.from_program_lines(lines)\ntokens = lex(program_line)\nline_generator = Lexer.as_lines(tokens)\n```\n\n```python\nparse = Parser()\nast = parse(tokens)\nast_dict = ast.as_dict()\njson_str = ast.as_json()\nline_generator = ast.as_lines()\n```\n\n```python\nwalk = Walker()\nwalk(ast)\n```\n\n## Run Tests\n\n```bash\nexport PYTHONPATH=\"$(pwd)\"\n\n# Run all tests\npython3 -m unittest discover --verbose --start-directory tests/\n\n# Run specific test suite\npython3 -m unittest --verbose tests/test_lexer_tokens.py\n\n# Run specific test\npython3 -m unittest --verbose tests.test_lexer_integer_literal.TestIntegerLiteral.test_positive_integers\n```\n\n## References\n- https://rosettacode.org/wiki/Compiler/lexical_analyzer\n- https://en.wikibooks.org/wiki/Compiler_Construction/Syntax_Analysis\n- https://docs.python.org/3/library/re.html#writing-a-tokenizer\n- https://en.wikipedia.org/wiki/Operator-precedence_parser\n\n## TODO\n\n- [ ] boolean\n- [ ] implement static array\n  - [x] assign single value\n  - [x] assign row\n  - [ ] binary operation (eg multiply) row\n  - [x] print\n  - [x] access single value\n  - [x] access row\n- [ ] implement hash table\n  - [x] default value\n  - [x] assign single value\n  - [x] access single value\n  - [x] print\n  - [ ] access keys\n  - [ ] access values\n- [ ] loop\n  - [x] while with condition and statement\n  - [ ] halt loop\n  - [ ] continue loop\n- [ ] variables\n  - [x] int\n  - [x] char\n  - [x] string\n  - [x] array\n  - [x] map\n  - [ ] constants / immutable value\n  - [x] typing / immutable type\n  - [x] variable scope\n- [ ] provide token context with AST error\n- [x] print statement with multiple arguments\n- [x] handle print string escape characters\n- [x] assert statement throws error and causes walker to exist with non-zero status code\n\n- test `putc('');` =\u003e error\n- test `putc('x');` =\u003e 'x'\n- test `putc(120);` =\u003e 'x'\n- test `print(\"\");` =\u003e ''\n- test `print(\"x\");` =\u003e 'x'\n- test `print('x');` =\u003e '120'\n- test `print(120);` =\u003e '120'\n- test `print([\"Hello\", \" \", \"world\", ]);` =\u003e 'Hello world'\n- test `print([[\"Hello\", \" \", \"wolrd\",]]);` =\u003e 'Hello world'\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feddiecorrigall%2Felang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feddiecorrigall%2Felang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feddiecorrigall%2Felang/lists"}