MCPcopy Index your code
hub / github.com/Lucretiel/ctreg

github.com/Lucretiel/ctreg @1.0.3

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.0.3 ↗ · + Follow
28 symbols 43 edges 4 files 1 documented · 4%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

ctreg

ctreg (pronounced cuh-tredge, in the style of Cthulhu) is a macro providing static typing to your regular expressions, allowing syntax errors to be detected at compile time and capture groups to be matched infallibly.

use ctreg::regex;

// Create a regular expression with the macro. This regular expression is
// analyzed at compile time and its parsed, normalized representation is
// emitted as the `HelloWorld` type.
regex! { pub HelloWorld = "(?<greeting>[a-zA-Z0-9-_.]+)(, (?<target>[a-zA-Z0-9-_.]+))?!" }

// Create an instance of the regular expression.
let regex = HelloWorld::new();

// Use `is_match` to test if there was a match
assert!(regex.is_match("Hello, World!"));
assert!(regex.is_match("Goodbye!"));
assert!(!regex.is_match("Nothing to see here."));

// Use `find` to find the location of a match
let cap = regex.find("abc Greetings, Rustacean! 123").unwrap();
assert_eq!(cap.content, "Greetings, Rustacean!");
assert_eq!(cap.start, 4);
assert_eq!(cap.end, 25);

assert!(regex.find("Nothing to see here.").is_none());

// Use `captures` to find all of the named capture groups of a match (`greeting`
// and `target`, in this case). Capture groups are emitted at compile time and
// evaluated infallibly.
let groups = regex.captures("ah, Bonjour, reader!").unwrap();
assert_eq!(groups.greeting.content, "Bonjour");
assert_eq!(groups.target.unwrap().content, "reader");

let groups = regex.captures("This is goodbye!").unwrap();
assert_eq!(groups.greeting.content, "goodbye");
assert!(groups.target.is_none());

assert!(regex.captures("nothing to see here.").is_none());

Core symbols most depended-on inside this repo

and
called by 2
ctreg-macro/src/lib.rs
captures
called by 2
ctreg/src/lib.rs
render_class
called by 1
ctreg-macro/src/render.rs
hir_expression
called by 1
ctreg-macro/src/render.rs
with
called by 1
ctreg-macro/src/lib.rs
get_group_index
called by 1
ctreg-macro/src/lib.rs
process_hir_recurse
called by 1
ctreg-macro/src/lib.rs
process_hir
called by 1
ctreg-macro/src/lib.rs

Shape

Function 12
Method 9
Class 5
Enum 2

Languages

Rust100%

Modules by API surface

ctreg-macro/src/lib.rs13 symbols
ctreg/src/lib.rs8 symbols
ctreg/tests/tests.rs5 symbols
ctreg-macro/src/render.rs2 symbols

For agents

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

⬇ download graph artifact