Sedlex_compiler.IrSourceIntermediate 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.tMatch a single code point in the given set.
*)| Seq of t list| Alt of t list| Star of tKleene star (zero or more).
*)| Plus of tOne or more.
*)| Rep of t * int * intRep (r, n, m): between n and m repetitions.
| EpsEmpty string (epsilon).
*)| Capture of string * tNamed capture: Capture (name, inner) wraps inner with an as binding. The compiler decides tag allocation strategy.
A pattern with named captures.
Constructors that enforce structural invariants return result.
alt checks name consistency across branches.capture checks for shadowed inner bindings.seq rejects duplicate capture names across elements.star, plus, rep reject inner captures.reject_captures ctx t returns Ok t if t contains no Capture nodes, or Error msg mentioning ctx otherwise.
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.