Module grammar

Module grammar 

Source
Expand description

Core structures and parsing logic for Tree-sitter grammars.

This module defines how Sapling understands and manipulates the declarative shape of a language: the grammar itself. Everything else in the compiler builds upon these types. Core structures and parsing logic for Tree-sitter grammars.

This module defines the internal representation of a grammar as parsed from Tree-sitter’s JSON format. It uses facet_json for deserialization and provides ergonomic accessors for inspecting rule properties and structure.

Structs§

Grammar
Represents a full Tree-sitter grammar definition.
Rule
Represents a grammar rule in the Tree-sitter format.

Enums§

GrammarError
Possible errors raised during grammar parsing or validation.
Precedence
A single precedence entry, either a named symbol or a literal string value.
RuleType
The enumeration of all recognized Tree-sitter rule types.
RuleValue
A literal or numeric value attached to a rule node.

Functions§

parse_grammar
Parse a JSON grammar definition into a strongly typed Grammar structure.