MCPcopy Index your code
hub / github.com/2kai2kai2/ere

github.com/2kai2kai2/ere @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
360 symbols 560 edges 23 files 132 documented · 37% updated 5mo ago★ 372 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Crates.io Version docs.rs

This crate provides tools for compiling and using regular expressions. It is intended as a simple but compiler-checked version of the regex crate, as it does regular expression compilation at compile-time, but only supports POSIX Extended Regular Expressions*.

Usage

use ere::prelude::*;

const PHONE_REGEX: Regex<2> = compile_regex!(r"^(\+1 )?[0-9]{3}-[0-9]{3}-[0-9]{4}$");
fn test() {
    assert!(PHONE_REGEX.test("012-345-6789"));
    assert!(PHONE_REGEX.test("987-654-3210"));
    assert!(PHONE_REGEX.test("+1 555-555-5555"));
    assert!(PHONE_REGEX.test("123-555-9876"));

    assert!(!PHONE_REGEX.test("abcd"));
    assert!(!PHONE_REGEX.test("0123456789"));
    assert!(!PHONE_REGEX.test("012--345-6789"));
    assert!(!PHONE_REGEX.test("(555) 555-5555"));
    assert!(!PHONE_REGEX.test("1 555-555-5555"));
}

const COLOR_REGEX: Regex<5> = compile_regex!(
    r"^#?([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})?$"
);
fn exec() {
    assert_eq!(
        COLOR_REGEX.exec("#000000"),
        Some([
            Some("#000000"),
            Some("00"),
            Some("00"),
            Some("00"),
            None,
        ]),
    );
    assert_eq!(
        COLOR_REGEX.exec("1F2e3D"),
        Some([
            Some("1F2E3D"),
            Some("1F"),
            Some("2e"),
            Some("3D"),
            None,
        ]),
    );
    assert_eq!(
        COLOR_REGEX.exec("ffffff80"),
        Some([
            Some("ffffff80"),
            Some("ff"),
            Some("ff"),
            Some("ff"),
            Some("80"),
        ]),
    );

    assert_eq!(PHONE_REGEX.exec("green"), None);
    assert_eq!(PHONE_REGEX.exec("%FFFFFF"), None);
    assert_eq!(PHONE_REGEX.exec("#2"), None);
}

To minimize memory overhead and binary size, it is recommended to create a single instance of each regular expression (using a const variable) rather than creating multiple.

*Some features are not fully implemented, such as POSIX-mode ambiguous submatch rules (we currently use greedy mode, which is the much more common and efficient method). See the roadmap for more details.

Alternatives

ere is intended as an alternative to regex that provides compile-time checking and regex compilation. However, ere is less featureful, so here are a few reasons you might prefer regex:

  • You require more complex regular expressions with features like backreferences and word boundary checking (which are unavailable in POSIX EREs).
  • You need run-time-compiled regular expressions (such as when provided by the user).
  • Your regular expression runs significantly more efficiently on a specific regex engine not currently available in ere.

Extension points exported contracts — how you extend this code

VecExt (Interface)
(no doc) [1 implementers]
ere-core/src/working_u8_dfa.rs
BuildLayout (Interface)
(no doc) [1 implementers]
ere-core/src/visualization/layout.rs

Core symbols most depended-on inside this repo

start
called by 32
ere-core/src/working_u8_nfa.rs
end
called by 29
ere-core/src/working_u8_nfa.rs
repeat
called by 28
ere-core/src/simplified_tree.rs
to_ranges
called by 10
ere-core/src/parse_tree.rs
num_capture_groups
called by 9
ere-core/src/working_nfa.rs
escape_latex
called by 6
ere-core/src/visualization/latex_graph.rs
add_offset
called by 4
ere-core/src/working_u8_nfa.rs
take
called by 4
ere-core/src/parse_tree.rs

Shape

Method 177
Function 87
Class 71
Enum 23
Interface 2

Languages

Rust100%

Modules by API surface

ere-core/src/working_nfa.rs54 symbols
ere-core/src/working_u8_nfa.rs52 symbols
ere-core/src/parse_tree.rs41 symbols
ere-core/src/working_u8_dfa.rs33 symbols
ere-core/src/engines/one_pass_u8.rs24 symbols
ere-core/src/engines/flat_lockstep_nfa_u8.rs20 symbols
ere-core/src/engines/flat_lockstep_nfa.rs20 symbols
tests/pure_regex.rs19 symbols
ere-core/src/simplified_tree.rs17 symbols
ere-core/src/lib.rs14 symbols
ere-core/src/engines/nfa_static.rs10 symbols
ere-core/src/config.rs10 symbols

For agents

$ claude mcp add ere \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact