# lark-parser/lark

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/lark-parser-lark).**

5,914 stars · 484 forks · Python · MIT

## Links

- GitHub: https://github.com/lark-parser/lark
- awesome-repositories: https://awesome-repositories.com/repository/lark-parser-lark.md

## Topics

`cyk` `earley` `grammar` `lalr` `lark` `parse` `parser` `parser-library` `parsing-engine` `parsing-library` `python` `tree`

## Description

Lark is a Python parsing toolkit used to define grammars and convert raw text into annotated parse trees. It serves as an abstract syntax tree generator and a grammar definition language for specifying language rules through terminals and regular expressions.

The library provides two primary parsing implementations: an Earley parsing library capable of handling all context-free languages, including those with ambiguity and left-recursion, and a high-performance LALR parsing library designed for deterministic languages with low memory overhead.

Beyond core parsing, the toolkit includes capabilities for modular grammar composition, rule-based tree transformation, and coordinate tracking for source positions. It also supports the serialization of LALR grammars into standalone parser modules.

## Tags

### Programming Languages & Runtimes

- [Parsing Toolkits](https://awesome-repositories.com/f/programming-languages-runtimes/parsing-toolkits.md) — Provides a comprehensive suite of parsing algorithms and grammar definition tools for transforming raw text into structured parse trees.
- [Annotated Parse Trees](https://awesome-repositories.com/f/programming-languages-runtimes/abstract-syntax-tree-parsing/parse-tree-frameworks/annotated-parse-trees.md) — Transforms raw text into hierarchical parse trees annotated with grammar rule matches and source positions. ([source](https://github.com/lark-parser/lark#readme))
- [Domain Specific Language Parsers](https://awesome-repositories.com/f/programming-languages-runtimes/domain-specific-language-parsers.md) — Provides tools to build specialized parsers for custom data formats and complex recursive configuration languages.
- [Parsing Optimizations](https://awesome-repositories.com/f/programming-languages-runtimes/parsing-optimizations.md) — Implements high-performance LALR parsing to increase execution speed and reduce memory overhead. ([source](https://github.com/lark-parser/lark/blob/master/docs/json_tutorial.md))
- [Source Coordinate Tracking](https://awesome-repositories.com/f/programming-languages-runtimes/source-coordinate-tracking.md) — Provides line and column offset tracking for tokens to map parse tree nodes back to the original source code.
- [Standalone Parser Generators](https://awesome-repositories.com/f/programming-languages-runtimes/standalone-parser-generators.md) — Compiles LALR grammars into self-contained parser modules to remove dependencies on the full toolkit.

### Software Engineering & Architecture

- [AST Generators](https://awesome-repositories.com/f/software-engineering-architecture/abstract-syntax-tree-parsing/ast-generators.md) — Acts as a toolkit for transforming raw input text into hierarchical abstract syntax trees based on predefined grammars.
- [Abstract Syntax Tree Parsing](https://awesome-repositories.com/f/software-engineering-architecture/abstract-syntax-tree-parsing.md) — Automatically generates a hierarchical tree representation of the input text based on the defined grammar. ([source](https://github.com/lark-parser/lark/blob/master/README.md))
- [Concrete Parse Tree Generation](https://awesome-repositories.com/f/software-engineering-architecture/abstract-syntax-tree-parsing/concrete-parse-tree-generation.md) — Automatically builds full, annotated hierarchical parse trees based on the specified grammar structure. ([source](https://github.com/lark-parser/lark#readme))
- [AST Generators](https://awesome-repositories.com/f/software-engineering-architecture/trees/syntax-tree-construction/formal-grammar-parser-generators/ast-generators.md) — Automatically generates hierarchical abstract syntax trees by matching input tokens against defined grammar rules.
- [LALR Parsers](https://awesome-repositories.com/f/software-engineering-architecture/trees/syntax-tree-construction/formal-grammar-parser-generators/lalr-parsers.md) — Implements a high-performance LALR parser using look-ahead left-to-right shift-reduce algorithms for deterministic languages.
- [Earley Parser Implementations](https://awesome-repositories.com/f/software-engineering-architecture/trees/syntax-tree-construction/grammar-based-parsers/earley-parser-implementations.md) — Implements the Earley parsing algorithm to support all context-free languages, including those with left-recursion.
- [Earley Parsers](https://awesome-repositories.com/f/software-engineering-architecture/trees/syntax-tree-construction/grammar-based-parsers/earley-parsers.md) — Implements the Earley parsing algorithm to handle all context-free grammars, including those with ambiguity and left-recursion.
- [Coordinate Tracking](https://awesome-repositories.com/f/software-engineering-architecture/error-handling/parse-error-reporters/coordinate-tracking.md) — Tracks line and column numbers for every element in the parse tree to facilitate precise error reporting and debugging. ([source](https://github.com/lark-parser/lark#readme))
- [Grammar Extensions](https://awesome-repositories.com/f/software-engineering-architecture/extensible-plugin-architectures/grammar-extensions.md) — Imports terminals and rules from external libraries to reuse common language patterns within a grammar. ([source](https://github.com/lark-parser/lark#readme))
- [Grammar Compositions](https://awesome-repositories.com/f/software-engineering-architecture/modular-configuration-composition/grammar-compositions.md) — Supports importing and combining separate grammar definitions to build complex languages from reusable components.
- [Syntax Tree Transformers](https://awesome-repositories.com/f/software-engineering-architecture/trees/syntax-tree-construction/syntax-tree-transformers.md) — Uses a visitor-pattern mechanism to transform parse trees into custom data structures via specific grammar branch mappings.

### Part of an Awesome List

- [Parsing and Grammars](https://awesome-repositories.com/f/awesome-lists/devtools/parsing-and-grammars.md) — Converts raw text into annotated parse trees based on user-defined grammar rules. ([source](https://github.com/lark-parser/lark/blob/master/docs/json_tutorial.md))
- [Interactive Grammar Debugging](https://awesome-repositories.com/f/awesome-lists/devtools/grammar-debugging-tools/interactive-grammar-debugging.md) — Offers tools to design and debug language grammars by inspecting parser decisions interactively.
- [Ambiguity Management](https://awesome-repositories.com/f/awesome-lists/devtools/parsing-and-grammars/ambiguity-management.md) — Supports marking multiple valid interpretations of a single input string when using the Earley parsing algorithm. ([source](https://github.com/lark-parser/lark/tree/master/examples/fruitflies.py))

### Development Tools & Productivity

- [Custom Language Definitions](https://awesome-repositories.com/f/development-tools-productivity/custom-language-definitions.md) — Enables the definition of custom language structures using grammar rules and regular expressions.
- [Grammar Rule Specification](https://awesome-repositories.com/f/development-tools-productivity/rule-definition-languages/grammar-rule-specification.md) — Allows users to define the structure of a language using a high-level syntax for recursive rules and regular expressions. ([source](https://github.com/lark-parser/lark/blob/master/docs/json_tutorial.md))
- [Context-Free Grammar Frameworks](https://awesome-repositories.com/f/development-tools-productivity/rule-definition-languages/grammar-rule-specification/context-free-grammar-frameworks.md) — Implements a framework capable of parsing all context-free languages, including those with ambiguity and left-recursion. ([source](https://github.com/lark-parser/lark#readme))
- [Formal Grammar Specifications](https://awesome-repositories.com/f/development-tools-productivity/rule-definition-languages/grammar-rule-specification/formal-grammar-specifications.md) — Allows the definition of recursive rules and terminals using extended Backus-Naur Form (EBNF) syntax.
- [Grammar Compositions](https://awesome-repositories.com/f/development-tools-productivity/parser-modules/dynamic-grammar-compilation/grammar-compositions.md) — Provides the ability to import terminals and rules from multiple external grammar files to build complex parsing logic. ([source](https://github.com/lark-parser/lark#readme))

### Data & Databases

- [High-Performance Text Processing](https://awesome-repositories.com/f/data-databases/high-performance-text-processing.md) — Uses LALR algorithms to process large volumes of text with high efficiency and low memory usage.
