{"id":17026248,"url":"https://github.com/chlohal/python-parser","last_synced_at":"2025-04-12T11:33:15.058Z","repository":{"id":118031567,"uuid":"383647555","full_name":"chlohal/python-parser","owner":"chlohal","description":"A parser for Python in *pure* Javascript","archived":false,"fork":false,"pushed_at":"2022-11-21T02:08:20.000Z","size":39,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T06:11:46.943Z","etag":null,"topics":["javascript","parser","python"],"latest_commit_sha":null,"homepage":"","language":"PEG.js","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/chlohal.png","metadata":{"files":{"readme":"README.md","changelog":null,"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-07-07T02:08:02.000Z","updated_at":"2023-09-18T08:13:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"4b1f164c-96eb-4dda-89cf-753b2434b531","html_url":"https://github.com/chlohal/python-parser","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/chlohal%2Fpython-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chlohal%2Fpython-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chlohal%2Fpython-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chlohal%2Fpython-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chlohal","download_url":"https://codeload.github.com/chlohal/python-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248560118,"owners_count":21124594,"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":["javascript","parser","python"],"created_at":"2024-10-14T07:31:18.836Z","updated_at":"2025-04-12T11:33:15.019Z","avatar_url":"https://github.com/chlohal.png","language":"PEG.js","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python Parser\n\nThis is a naive Python parser in pure Javascript: no WASM, shell calls, or any non-JS. It has *no* runtime dependencies.\n\nIf you want to parse Python in the browser, then this is your project! I made this with PegJS when I couldn't find any pure-JS Python parsers. It's designed to be as easily usable as possible.\n\n\n## How to Use\n\n### Using in the Browser\n\n1) Add the [parser.js](./parser.js) file to your page\n2) Call the `pythonParser.parse(/*...code...*/)` method.\n\n### Using in NodeJS\n\n1) `require(\"parser.js\")`\n2) Call the `pythonParser.parse(/*...code...*/)` method.\n\n## Parser Output\n\nI hope that the output object can be understood with a glance at the [test output](./test-output.json). You can also take a look at the [Python grammar](./python.pegjs) to see the exact format.\n\n## PegJS\n\nThis project uses [PegJS](https://github.com/pegjs/pegjs) for parsing, which is [available under the MIT License](https://github.com/pegjs/pegjs/blob/master/LICENSE). The PegJS-generated parser is 1 Javascript file that doesn't depend on anything!\n\n## Questions\n\n**How is this different from [Skulpt](https://skulpt.org/)?**  \nSkulpt runs Python. This project *only* parses it and then gives you a syntax tree. You can use that for whatever you like: code formatting; static code analysis; even making your own interpreter!\n\n**I'm getting syntax errors!**\n\nTry adding newlines to the end of your input: e.g. instead of `pythonParser.parse(input)`, try `pythonParser.parse(input + \"\\n\\n\")`. If you're experiencing a larger error, please open an issue.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchlohal%2Fpython-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchlohal%2Fpython-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchlohal%2Fpython-parser/lists"}