package sedlex
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=b8efae9d2a9a39c2ca2c43a2684f3fb686a8775329f7f9b07c3e3d8a2b7682d6
sha512=ae6ac8282b9e899a510745d64a817d06d908bc61f29530568323eb4145b3db38cf61a82575e2b4c15825f570f2b270ab885c3d27adedbbbe7cdad12510de6d80
doc/sedlex.compiler/Sedlex_compiler/Ir/index.html
Module Sedlex_compiler.IrSource
Intermediate representation for sedlex patterns.
This IR captures the regexp structure including named capture annotations (as bindings) but before tag allocation, fixed-length optimization, or discriminator handling. The compiler processes this IR to produce a compiled DFA with binding extraction information.
The IR does not depend on ppxlib and can be constructed directly in tests.
type t = | Chars of Cset.t(*Match a single code point in the given set.
*)| Seq of t list| Alt of t list| Star of t(*Kleene star (zero or more).
*)| Plus of t(*One or more.
*)| Rep of t * int * int(*
*)Rep (r, n, m): betweennandmrepetitions.| Eps(*Empty string (epsilon).
*)| Capture of string * t(*Named capture:
*)Capture (name, inner)wrapsinnerwith anasbinding. The compiler decides tag allocation strategy.
A pattern with named captures.
Smart constructors
Constructors that enforce structural invariants return result.
altchecks name consistency across branches.capturechecks for shadowed inner bindings.seqrejects duplicate capture names across elements.star,plus,repreject inner captures.
reject_captures ctx t returns Ok t if t contains no Capture nodes, or Error msg mentioning ctx otherwise.
Analysis
fixed_length t returns Some n if t always matches exactly n code points, or None if the length is variable.
Invariant checking
All structural constraints are enforced by the smart constructors. check_invariant asserts these hold. Use for debugging.