1 unstable release

Uses new Rust 2024

new 0.8.0 Apr 8, 2026

#1018 in Algorithms


Used in 3 crates

Apache-2.0 OR MIT

465KB
10K SLoC

GLR parser generation algorithms for Adze This module implements the core GLR state machine generation and conflict resolution

Contracts & Invariants

This crate maintains several critical invariants for correct parsing:

EOF Symbol Invariants

  • EOF symbol must be a terminal sentinel id at or beyond the terminal boundary (token_count + external_token_count).
  • EOF symbol must not be the internal ERROR sentinel (parse_forest::ERROR_SYMBOL, currently 0xFFFF).
  • EOF symbol is always present in the symbol_to_index mapping
  • EOF column actions are byte-for-byte copies of the TS "end" column, guaranteeing per-state equality.

Error Recovery Invariants

  • has_error: true if any error chunks exist in the parse forest
  • missing: count of unique missing terminal symbols inserted
  • cost: total error recovery cost (insertions + deletions)
  • No double counting: each missing symbol counted exactly once
  • Extras (whitespace/comments) are never inserted during recovery

Table Normalization

  • Action cells are sorted deterministically by action type and value
  • Duplicate actions are removed from cells
  • Action ordering: Shift < Reduce < Accept < Error < Recover < Fork

API Stability

  • ForestView trait is sealed and cannot be implemented outside this crate
  • Action enum is marked #[non_exhaustive] for future extensibility
  • Test-only APIs are gated behind test-helpers feature

Validation

Enable the strict-invariants feature to validate parse tables at runtime. This adds overhead but catches invariant violations early in development.


adze-glr-core

adze-glr-core implements the GLR parser generation pipeline used by the core adze toolchain. It provides conflict handling, table construction, and supporting APIs for deterministic and non-deterministic parse processing.

Dependencies

~1.4–3MB
~56K SLoC