# ohmjs/ohm

**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/ohmjs-ohm).**

5,471 stars · 225 forks · JavaScript · mit

## Links

- GitHub: https://github.com/ohmjs/ohm
- awesome-repositories: https://awesome-repositories.com/repository/ohmjs-ohm.md

## Topics

`compiler` `grammars` `javascript` `parser` `parsing` `peg` `typescript`

## Description

Ohm is a formal grammar parser generator and domain-specific language framework. It provides a system for defining custom languages to parse, validate, and extract data from input text, transforming raw strings into hierarchical abstract syntax trees based on specified formal rules.

The project utilizes an Earley parsing algorithm, which allows it to support all context-free grammars, including those with left recursion and ambiguity, without requiring predefined operator precedence. It also includes a dedicated debugging toolkit for tracing and visualizing the step-by-step state transitions and rule applications the parser makes when processing input.

The framework covers language definition, input string validation, and semantic value extraction from parsed structures.

## Tags

### Development Tools & Productivity

- [Grammar Rule Specification](https://awesome-repositories.com/f/development-tools-productivity/rule-definition-languages/grammar-rule-specification.md) — Provides a high-level syntax for specifying the rules and structure of custom formal grammars. ([source](https://cdn.jsdelivr.net/gh/ohmjs/ohm@main/README.md))
- [Abstract Syntax Tree Generators](https://awesome-repositories.com/f/development-tools-productivity/project-scaffolding-config-code-generation/code-generation/abstract-syntax-tree-generators.md) — Transforms raw input strings into hierarchical abstract syntax trees based on a defined formal grammar.
- [Context-Free Grammar Frameworks](https://awesome-repositories.com/f/development-tools-productivity/rule-definition-languages/grammar-rule-specification/context-free-grammar-frameworks.md) — Provides a framework for specifying language rules that support left recursion and ambiguous grammars.
- [Parser Debugging Tools](https://awesome-repositories.com/f/development-tools-productivity/parser-debugging-tools.md) — Provides a dedicated toolkit for tracing and visualizing the step-by-step decisions the parser makes when processing input.
- [Parsing Debugging Toolkits](https://awesome-repositories.com/f/development-tools-productivity/parsing-debugging-toolkits.md) — Includes a dedicated toolkit for tracing and visualizing the step-by-step state transitions of the parsing engine.

### Programming Languages & Runtimes

- [Domain Specific Languages](https://awesome-repositories.com/f/programming-languages-runtimes/domain-specific-languages.md) — Acts as a comprehensive framework for creating custom domain-specific languages through syntactic rules and semantic value extraction.
- [Domain Specific Languages](https://awesome-repositories.com/f/programming-languages-runtimes/programming-language-varieties/domain-specific-languages.md) — Implements specialized parsing for languages designed for particular application domains.
- [String Parsing](https://awesome-repositories.com/f/programming-languages-runtimes/string-parsing.md) — Converts textual representations into structured data types and validates they match defined rules. ([source](https://github.com/ohmjs/ohm/tree/main/doc/))
- [Language Definition Frameworks](https://awesome-repositories.com/f/programming-languages-runtimes/domain-specific-languages/language-definition-frameworks.md) — Provides a framework for specifying the rules and structure of custom domain-specific languages.

### Artificial Intelligence & ML

- [Rule-Based Text Parsers](https://awesome-repositories.com/f/artificial-intelligence-ml/rule-based-ai-systems/rule-based-text-parsers.md) — Uses predefined linguistic grammars to tokenize, tag, and map text into structured data.

### Part of an Awesome List

- [Language Development](https://awesome-repositories.com/f/awesome-lists/devtools/language-development.md) — Provides utilities for building new programming or configuration languages using formal grammar rules.
- [Earley](https://awesome-repositories.com/f/awesome-lists/devtools/parser-generators/earley.md) — Uses the Earley parsing algorithm to support all context-free grammars, including those with left recursion.
- [Parsing and Grammars](https://awesome-repositories.com/f/awesome-lists/devtools/parsing-and-grammars.md) — Implements libraries for lexical analysis, parsing, and formal grammar definition to convert raw text into structured data.
- [Text Processing and Parsing](https://awesome-repositories.com/f/awesome-lists/devtools/text-processing-and-parsing.md) — Provides libraries for matching input text against a grammar to produce a data structure. ([source](https://cdn.jsdelivr.net/gh/ohmjs/ohm@main/README.md))
- [Parser Execution Tracing](https://awesome-repositories.com/f/awesome-lists/devtools/debugging-and-tracing/parser-execution-tracing.md) — Records state transitions and rule applications to visualize the decision process of the parsing engine.
- [Grammar Debugging Tools](https://awesome-repositories.com/f/awesome-lists/devtools/grammar-debugging-tools.md) — Traces the decision process of a parser to identify and fix errors in a formal language definition.
- [Parser Decision Visualizations](https://awesome-repositories.com/f/awesome-lists/devtools/parser-decision-visualizations.md) — Generates text traces or graphical visualizations of the steps and decisions a parser takes. ([source](https://cdn.jsdelivr.net/gh/ohmjs/ohm@main/README.md))

### Data & Databases

- [Data Parsing and Extraction](https://awesome-repositories.com/f/data-databases/data-processing-pipelines/data-transformation/data-parsing-extraction.md) — Identifies, isolates, and converts raw input into structured, schema-validated formats. ([source](https://github.com/ohmjs/ohm/tree/main/doc/))
- [Semantic Value Extraction](https://awesome-repositories.com/f/data-databases/data-transformation-functions/recursive-processors/recursive-logic-implementations/recursive-descent-parsers/semantic-value-extraction.md) — Walks the generated parse tree using semantic operations to retrieve specific data from matched nodes.
- [Text Extraction](https://awesome-repositories.com/f/data-databases/text-processing-utilities/text-extraction.md) — Isolates and retrieves specific meaningful segments of data from larger raw text inputs.

### Software Engineering & Architecture

- [Abstract Syntax Tree Parsing](https://awesome-repositories.com/f/software-engineering-architecture/abstract-syntax-tree-parsing.md) — Converts source code or template strings into a structured tree representation for analysis.
- [String Format Specification](https://awesome-repositories.com/f/software-engineering-architecture/string-formatting-utilities/string-format-specification.md) — Validates that string content conforms to specific formal grammar patterns.
- [Formal Grammar Parser Generators](https://awesome-repositories.com/f/software-engineering-architecture/trees/syntax-tree-construction/formal-grammar-parser-generators.md) — Provides a tool for defining custom languages using formal grammars to parse, validate, and extract data.
- [Grammar-Based Parsers](https://awesome-repositories.com/f/software-engineering-architecture/trees/syntax-tree-construction/grammar-based-parsers.md) — Creates hierarchical syntax trees based on specialized formal grammar rules.
- [Earley Parser Implementations](https://awesome-repositories.com/f/software-engineering-architecture/trees/syntax-tree-construction/grammar-based-parsers/earley-parser-implementations.md) — Uses a non-deterministic Earley parsing engine to handle complex context-free grammars including left recursion.
- [Earley Parsers](https://awesome-repositories.com/f/software-engineering-architecture/trees/syntax-tree-construction/grammar-based-parsers/earley-parsers.md) — Implements an Earley parser to support all context-free grammars including those with left recursion and ambiguity.
- [Non-Deterministic Parsing State Tracking](https://awesome-repositories.com/f/software-engineering-architecture/non-deterministic-parsing-state-tracking.md) — Tracks multiple parallel parsing hypotheses to handle ambiguous grammar rules without predefined operator precedence.

### Testing & Quality Assurance

- [Grammar Validation Tools](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/testing-frameworks/test-frameworks/assertions-and-validation/test-case-definitions/grammar-validation-tools.md) — Provides tools for validating that input strings conform to specific formal grammar definitions.

### System Administration & Monitoring

- [Parser State Recording](https://awesome-repositories.com/f/system-administration-monitoring/diagnostic-tools/diagnostics/execution-tracers/kernel-tracing-frameworks/system-call-tracing/trace-recording/parser-state-recording.md) — Logs every rule application and state transition to visualize the internal decision process during parsing.
