1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//! # Ferroni
//!
//! Pure-Rust regex engine based on [Oniguruma](https://github.com/kkos/oniguruma),
//! with SIMD-accelerated search via [`memchr`](https://crates.io/crates/memchr).
//!
//! Ferroni is a line-by-line port of Oniguruma's C source into Rust -- same
//! structure, same function names, same semantics. No bindings, no FFI.
//!
//! ## Quick Start
//!
//! ```rust
//! use ferroni::prelude::*;
//!
//! let re = Regex::new(r"\d{4}-\d{2}-\d{2}").unwrap();
//! let m = re.find("Date: 2026-02-12").unwrap();
//! assert_eq!(m.as_str(), "2026-02-12");
//! assert_eq!(m.start(), 6);
//! ```
//!
//! For fine-grained control, use [`RegexBuilder`]:
//!
//! ```rust
//! use ferroni::prelude::*;
//!
//! let re = Regex::builder(r"hello")
//! .case_insensitive(true)
//! .build()
//! .unwrap();
//! assert!(re.is_match("Hello World"));
//! ```
//!
//! ## Low-Level C-Style API
//!
//! The full C-ported API is also available for advanced usage:
//!
//! ```rust
//! use ferroni::regcomp::onig_new;
//! use ferroni::regexec::onig_search;
//! use ferroni::oniguruma::*;
//! use ferroni::regsyntax::OnigSyntaxOniguruma;
//!
//! let reg = onig_new(
//! b"\\d{4}-\\d{2}-\\d{2}",
//! ONIG_OPTION_NONE,
//! &ferroni::encodings::utf8::ONIG_ENCODING_UTF8,
//! &OnigSyntaxOniguruma,
//! ).unwrap();
//!
//! let input = b"Date: 2026-02-12";
//! let (result, region) = onig_search(
//! ®, input, input.len(), 0, input.len(),
//! Some(OnigRegion::new()), ONIG_OPTION_NONE,
//! );
//!
//! assert!(result >= 0);
//! assert_eq!(result, 6); // match starts at byte 6
//! ```
//!
//! ## Module Structure
//!
//! Each C source file maps 1:1 to a Rust module:
//!
//! | C File | Rust Module | Purpose |
//! |--------|-------------|---------|
//! | `regparse.c` | [`regparse`] | Pattern parser |
//! | `regcomp.c` | [`regcomp`] | AST-to-bytecode compiler |
//! | `regexec.c` | [`regexec`] | VM executor |
//! | `regint.h` | [`regint`] | Internal types and opcodes |
//! | `oniguruma.h` | [`oniguruma`] | Public types and constants |
//! | `regenc.c` | [`regenc`] | Encoding trait |
//! | `regsyntax.c` | [`regsyntax`] | 12 syntax definitions |
//! | `regset.c` | [`regset`] | Multi-regex search (RegSet) |
//! | `regerror.c` | [`regerror`] | Error messages |
//! | `regtrav.c` | [`regtrav`] | Capture tree traversal |
// Allow patterns inherent to the C port.
// Enable #[coverage(off)] attribute when running under cargo-llvm-cov on nightly.