{"id":29598898,"url":"https://github.com/sec-ant/lezer-python-regex","last_synced_at":"2025-07-20T10:38:00.564Z","repository":{"id":301935722,"uuid":"1010717897","full_name":"Sec-ant/lezer-python-regex","owner":"Sec-ant","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-29T17:35:03.000Z","size":0,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-29T17:49:07.046Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/Sec-ant.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,"zenodo":null}},"created_at":"2025-06-29T16:57:02.000Z","updated_at":"2025-06-29T17:40:36.000Z","dependencies_parsed_at":"2025-06-29T17:49:11.226Z","dependency_job_id":"ab9a5e26-8e75-4e01-ba3e-0ee74dfacf64","html_url":"https://github.com/Sec-ant/lezer-python-regex","commit_stats":null,"previous_names":["sec-ant/lezer-python-regex"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Sec-ant/lezer-python-regex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sec-ant%2Flezer-python-regex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sec-ant%2Flezer-python-regex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sec-ant%2Flezer-python-regex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sec-ant%2Flezer-python-regex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sec-ant","download_url":"https://codeload.github.com/Sec-ant/lezer-python-regex/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sec-ant%2Flezer-python-regex/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266111489,"owners_count":23877980,"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":[],"created_at":"2025-07-20T10:37:56.065Z","updated_at":"2025-07-20T10:38:00.550Z","avatar_url":"https://github.com/Sec-ant.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lezer-python-regex\n\n[![npm](https://img.shields.io/npm/v/lezer-python-regex)](https://www.npmjs.com/package/lezer-python-regex/v/latest) [![npm bundle size](https://img.shields.io/bundlephobia/minzip/lezer-python-regex)](https://www.npmjs.com/package/lezer-python-regex/v/latest) [![jsDelivr hits](https://img.shields.io/jsdelivr/npm/hm/lezer-python-regex?color=%23ff5627)](https://cdn.jsdelivr.net/npm/lezer-python-regex@latest/)\n\nA [Lezer](https://lezer.codemirror.net/) grammar for parsing Python regular expressions with incremental parsing support and TypeScript definitions.\n\n## Install\n\n```bash\nnpm i lezer-python-regex\n```\n\n## Features\n\n- Basic patterns, character classes, quantifiers, groups\n- Lookarounds, backreferences, conditionals, alternation\n- Inline flags, embedded comments, escape sequences\n- Named groups `(?P\u003cname\u003e)`, atomic groups `(?\u003e)`\n- Full Python regex syntax compliance\n\n## Usage\n\n### Basic\n\n```ts\nimport { parser } from \"lezer-python-regex\";\n\nconst tree = parser.parse(`(?P\u003cword\u003e\\w+)\\s+(?P=word)`);\nconsole.log(tree.toString());\n```\n\n### With CodeMirror\n\n```ts\nimport { parser, pythonRegexHighlighting } from \"lezer-python-regex\";\nimport { LRLanguage } from \"@codemirror/language\";\nimport { HighlightStyle, syntaxHighlighting } from \"@codemirror/language\";\n\nconst pythonRegexLanguage = LRLanguage.define({\n  parser,\n  languageData: { name: \"python-regex\" },\n});\n\nconst highlightStyle = HighlightStyle.define([pythonRegexHighlighting]);\nconst extensions = [pythonRegexLanguage, syntaxHighlighting(highlightStyle)];\n```\n\n### Tree Navigation\n\n```ts\nimport { parser } from \"lezer-python-regex\";\nimport * as terms from \"lezer-python-regex\";\n\nconst tree = parser.parse(`(?P\u003cemail\u003e[^@]+@[^@]+)`);\nconst cursor = tree.cursor();\n\n// Find named groups\ncursor.iterate((node) =\u003e {\n  if (node.type.id === terms.NamedCapturingGroup) {\n    console.log(\"Named group found:\", node);\n  }\n});\n```\n\n### Error Handling\n\n```ts\nimport { parser } from \"lezer-python-regex\";\n\nfunction parseWithErrors(pattern: string) {\n  const tree = parser.parse(pattern);\n  const errors: any[] = [];\n\n  tree.cursor().iterate((node) =\u003e {\n    if (node.type.isError) {\n      errors.push({\n        from: node.from,\n        to: node.to,\n        message: `Syntax error at ${node.from}-${node.to}`,\n      });\n    }\n  });\n\n  return { tree, errors };\n}\n```\n\n## API\n\n### Exports\n\n- `parser` - Lezer parser instance\n- `pythonRegexHighlighting` - CodeMirror syntax highlighting\n- Grammar terms - Node type constants for tree navigation\n\n### Types\n\n```ts\nparser.parse(input: string, fragments?: TreeFragment[], ranges?: {from: number, to: number}[]): Tree\n```\n\n## Development\n\n```bash\ngit clone https://github.com/Sec-ant/lezer-python-regex\ncd lezer-python-regex\npnpm install\npnpm build\npnpm test\n```\n\nTest categories: basic patterns, character classes, quantifiers, groups, lookarounds, backreferences, conditionals, alternation, comments, complex patterns, edge cases.\n\nCommands:\n\n- `pnpm test:run` - Run all tests\n- `pnpm test:ui` - Interactive test UI\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Add tests in `tests/fixtures/`\n4. Ensure tests pass\n5. Submit a pull request\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsec-ant%2Flezer-python-regex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsec-ant%2Flezer-python-regex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsec-ant%2Flezer-python-regex/lists"}