{"id":13460277,"url":"https://github.com/lark-parser/lark","last_synced_at":"2025-12-12T01:05:16.851Z","repository":{"id":37732988,"uuid":"80946973","full_name":"lark-parser/lark","owner":"lark-parser","description":"Lark is a parsing toolkit for Python, built with a focus on ergonomics, performance and modularity.","archived":false,"fork":false,"pushed_at":"2025-04-23T05:38:24.000Z","size":2861,"stargazers_count":5239,"open_issues_count":135,"forks_count":437,"subscribers_count":57,"default_branch":"master","last_synced_at":"2025-05-05T20:36:49.928Z","etag":null,"topics":["cyk","earley","grammar","lalr","lark","parse","parser","parser-library","parsing-engine","parsing-library","python","tree"],"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/lark-parser.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"lark-parser","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2017-02-04T20:38:59.000Z","updated_at":"2025-05-05T02:42:33.000Z","dependencies_parsed_at":"2024-01-06T01:04:24.138Z","dependency_job_id":"dc726cd1-b329-4808-88a7-d3b099a131e6","html_url":"https://github.com/lark-parser/lark","commit_stats":{"total_commits":1566,"total_committers":128,"mean_commits":12.234375,"dds":0.6309067688378034,"last_synced_commit":"262ab71d497a8814f0ca42ca468b923fdb47a3c7"},"previous_names":[],"tags_count":52,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lark-parser%2Flark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lark-parser%2Flark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lark-parser%2Flark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lark-parser%2Flark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lark-parser","download_url":"https://codeload.github.com/lark-parser/lark/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253176895,"owners_count":21866232,"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":["cyk","earley","grammar","lalr","lark","parse","parser","parser-library","parsing-engine","parsing-library","python","tree"],"created_at":"2024-07-31T10:00:38.545Z","updated_at":"2025-12-12T01:05:16.809Z","avatar_url":"https://github.com/lark-parser.png","language":"Python","readme":"# Lark - a parsing toolkit for Python\n\nLark is a parsing toolkit for Python, built with a focus on ergonomics, performance and modularity.\n\nLark can parse all context-free languages. To put it simply, it means that it is capable of parsing almost any programming language out there, and to some degree most natural languages too.\n\n**Who is it for?**\n\n   - **Beginners**: Lark is very friendly for experimentation. It can parse any grammar you throw at it, no matter how complicated or ambiguous, and do so efficiently. It also constructs an annotated parse-tree for you, using only the grammar and an input, and it gives you convenient and flexible tools to process that parse-tree.\n\n   - **Experts**: Lark implements both Earley(SPPF) and LALR(1), and several different lexers, so you can trade-off power and speed, according to your requirements. It also provides a variety of sophisticated features and utilities.\n\n**What can it do?**\n\n - Parse all context-free grammars, and handle any ambiguity gracefully\n - Build an annotated parse-tree automagically, no construction code required.\n - Provide first-rate performance in terms of both Big-O complexity and measured run-time (considering that this is Python ;)\n - Run on every Python interpreter (it's pure-python)\n - Generate a stand-alone parser (for LALR(1) grammars)\n\nAnd many more features. Read ahead and find out!\n\nMost importantly, Lark will save you time and prevent you from getting parsing headaches.\n\n### Quick links\n\n- [Documentation @readthedocs](https://lark-parser.readthedocs.io/)\n- [Cheatsheet (PDF)](/docs/_static/lark_cheatsheet.pdf)\n- [Online IDE](https://lark-parser.org/ide)\n- [Tutorial](/docs/json_tutorial.md) for writing a JSON parser.\n- Blog post: [How to write a DSL with Lark](https://eshsoft.com/blog/write-dsl-in-python-with-lark)\n- [Gitter chat](https://gitter.im/lark-parser/Lobby)\n\n### Install Lark\n\n    $ pip install lark --upgrade\n\nLark has no dependencies.\n\n[![Tests](https://github.com/lark-parser/lark/actions/workflows/tests.yml/badge.svg)](https://github.com/lark-parser/lark/actions/workflows/tests.yml)\n\n### Syntax Highlighting\n\nLark provides syntax highlighting for its grammar files (\\*.lark):\n\n- [Sublime Text \u0026 TextMate](https://github.com/lark-parser/lark_syntax)\n- [vscode](https://github.com/lark-parser/vscode-lark)\n- [Intellij \u0026 PyCharm](https://github.com/lark-parser/intellij-syntax-highlighting)\n- [Vim](https://github.com/lark-parser/vim-lark-syntax)\n- [Atom](https://github.com/Alhadis/language-grammars)\n\n### Clones\n\nThese are implementations of Lark in other languages. They accept Lark grammars, and provide similar utilities.\n\n- [Lerche (Julia)](https://github.com/jamesrhester/Lerche.jl) - an unofficial clone, written entirely in Julia.\n- [Lark.js (Javascript)](https://github.com/lark-parser/lark.js) - a port of the stand-alone LALR(1) parser generator to Javascsript.\n\n### Hello World\n\nHere is a little program to parse \"Hello, World!\" (Or any other similar phrase):\n\n```python\nfrom lark import Lark\n\nl = Lark('''start: WORD \",\" WORD \"!\"\n\n            %import common.WORD   // imports from terminal library\n            %ignore \" \"           // Disregard spaces in text\n         ''')\n\nprint( l.parse(\"Hello, World!\") )\n```\n\nAnd the output is:\n\n```python\nTree(start, [Token(WORD, 'Hello'), Token(WORD, 'World')])\n```\n\nNotice punctuation doesn't appear in the resulting tree. It's automatically filtered away by Lark.\n\n### Fruit flies like bananas\n\nLark is great at handling ambiguity. Here is the result of parsing the phrase \"fruit flies like bananas\":\n\n![fruitflies.png](examples/fruitflies.png)\n\n[Read the code here](https://github.com/lark-parser/lark/tree/master/examples/fruitflies.py), and see [more examples here](https://lark-parser.readthedocs.io/en/latest/examples/index.html).\n\n\n## List of main features\n\n - Builds a parse-tree (AST) automagically, based on the structure of the grammar\n - **Earley** parser\n    - Can parse all context-free grammars\n    - Full support for ambiguous grammars\n - **LALR(1)** parser\n    - Fast and light, competitive with PLY\n    - Can generate a stand-alone parser ([read more](docs/tools.md#stand-alone-parser))\n - **EBNF** grammar\n - **Unicode** fully supported\n - Automatic line \u0026 column tracking\n - Interactive parser for advanced parsing flows and debugging\n - Grammar composition - Import terminals and rules from other grammars\n - Standard library of terminals (strings, numbers, names, etc.)\n - Import grammars from Nearley.js ([read more](/docs/tools.md#importing-grammars-from-nearleyjs))\n - Extensive test suite [![codecov](https://codecov.io/gh/lark-parser/lark/branch/master/graph/badge.svg?token=lPxgVhCVPK)](https://codecov.io/gh/lark-parser/lark)\n - Type annotations (MyPy support)\n - And much more!\n\nSee the full list of [features here](https://lark-parser.readthedocs.io/en/latest/features.html)\n\n\n### Comparison to other libraries\n\n#### Performance comparison\n\nLark is fast and light (lower is better)\n\n![Run-time Comparison](docs/_static/comparison_runtime.png)\n\n![Memory Usage Comparison](docs/_static/comparison_memory.png)\n\n\nCheck out the [JSON tutorial](/docs/json_tutorial.md#conclusion) for more details on how the comparison was made.\n\nFor thorough 3rd-party benchmarks, checkout the [Python Parsing Benchmarks](https://github.com/goodmami/python-parsing-benchmarks) repo.\n\n#### Feature comparison\n\n| Library | Algorithm | Grammar | Builds tree? | Supports ambiguity? | Can handle every CFG? | Line/Column tracking | Generates Stand-alone\n|:--------|:----------|:----|:--------|:------------|:------------|:----------|:----------\n| **Lark** | Earley/LALR(1) | EBNF | Yes! | Yes! | Yes! | Yes! | Yes! (LALR only) |\n| [PLY](http://www.dabeaz.com/ply/) | LALR(1) | BNF | No | No | No | No | No |\n| [PyParsing](https://github.com/pyparsing/pyparsing) | PEG | Combinators | No | No | No\\* | No | No |\n| [Parsley](https://pypi.python.org/pypi/Parsley) | PEG | EBNF | No | No | No\\* | No | No |\n| [Parsimonious](https://github.com/erikrose/parsimonious) | PEG | EBNF | Yes | No | No\\* | No | No |\n| [ANTLR](https://github.com/antlr/antlr4) | LL(*) | EBNF | Yes | No | Yes? | Yes | No |\n\n\n(\\* *PEGs cannot handle non-deterministic grammars. Also, according to Wikipedia, it remains unanswered whether PEGs can really parse all deterministic CFGs*)\n\n\n### Projects using Lark\n\n - [Poetry](https://github.com/python-poetry/poetry-core) - A utility for dependency management and packaging\n - [Vyper](https://github.com/vyperlang/vyper) - Pythonic Smart Contract Language for the EVM\n - [PyQuil](https://github.com/rigetti/pyquil) - Python library for quantum programming using Quil\n - [Preql](https://github.com/erezsh/preql) - An interpreted relational query language that compiles to SQL\n - [Hypothesis](https://github.com/HypothesisWorks/hypothesis) - Library for property-based testing\n - [mappyfile](https://github.com/geographika/mappyfile) - a MapFile parser for working with MapServer configuration\n - [tartiflette](https://github.com/dailymotion/tartiflette) - GraphQL server by Dailymotion\n - [synapse](https://github.com/vertexproject/synapse) - an intelligence analysis platform\n - [Datacube-core](https://github.com/opendatacube/datacube-core) - Open Data Cube analyses continental scale Earth Observation data through time\n - [SPFlow](https://github.com/SPFlow/SPFlow) - Library for Sum-Product Networks\n - [Torchani](https://github.com/aiqm/torchani) - Accurate Neural Network Potential on PyTorch\n - [Command-Block-Assembly](https://github.com/simon816/Command-Block-Assembly) - An assembly language, and C compiler, for Minecraft commands\n - [EQL](https://github.com/endgameinc/eql) - Event Query Language\n - [Fabric-SDK-Py](https://github.com/hyperledger/fabric-sdk-py) - Hyperledger fabric SDK with Python 3.x\n - [required](https://github.com/shezadkhan137/required) - multi-field validation using docstrings\n - [miniwdl](https://github.com/chanzuckerberg/miniwdl) - A static analysis toolkit for the Workflow Description Language\n - [pytreeview](https://gitlab.com/parmenti/pytreeview) - a lightweight tree-based grammar explorer\n - [harmalysis](https://github.com/napulen/harmalysis) - A language for harmonic analysis and music theory\n - [gersemi](https://github.com/BlankSpruce/gersemi) - A CMake code formatter\n - [MistQL](https://github.com/evinism/mistql) - A query language for JSON-like structures\n - [Outlines](https://github.com/outlines-dev/outlines) - Structured generation with Large Language Models\n\n[Full list](https://github.com/lark-parser/lark/network/dependents?package_id=UGFja2FnZS01MjI1OTE0NQ%3D%3D)\n\n## License\n\nLark uses the [MIT license](LICENSE).\n\n(The standalone tool is under MPL2)\n\n## Contributors\n\nLark accepts pull-requests. See [How to develop Lark](/docs/how_to_develop.md)\n\nBig thanks to everyone who contributed so far:\n\n  \u003cimg src=\"https://contributors-img.web.app/image?repo=lark-parser/lark\" /\u003e\n\u003ca href=\"https://github.com/lark-parser/lark/graphs/contributors\"\u003e\n\u003c/a\u003e\n\n## Sponsor\n\nIf you like Lark, and want to see us grow, please consider [sponsoring us!](https://github.com/sponsors/lark-parser)\n\n## Contact the author\n\nQuestions about code are best asked on [gitter](https://gitter.im/lark-parser/Lobby) or in the issues.\n\nFor anything else, I can be reached by email at erezshin at gmail com.\n\n -- [Erez](https://github.com/erezsh)\n","funding_links":["https://github.com/sponsors/lark-parser"],"categories":["Python","Tools","语言资源库"],"sub_categories":["python","Python libraries"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flark-parser%2Flark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flark-parser%2Flark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flark-parser%2Flark/lists"}