MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / parse

Function parse

std/re/src/main/parser.rs:7–21  ·  view source on GitHub ↗

Parse a pattern into a Program or fail with a positioned error. */

(pattern: &str)

Source from the content-addressed store, hash-verified

5
6/* Parse a pattern into a Program or fail with a positioned error. */
7pub fn parse(pattern: &str) -> Result<Program, ParseError> {
8 let chars: Vec<char> = pattern.chars().collect();
9 let mut p = Parser {
10 p: &chars,
11 pos: 0,
12 group_count: 0,
13 names: Vec::new(),
14 flags: Flags::default(),
15 };
16 let root = p.alternation()?;
17 if p.pos != p.p.len() {
18 return Err(p.err("unbalanced parenthesis"));
19 }
20 Ok(Program { root, group_count: p.group_count, names: p.names, flags: p.flags })
21}
22
23struct Parser<'a> {
24 p: &'a [char],

Callers 7

compileMethod · 0.70
finalize_prev_slotsMethod · 0.50
parse_or_bareMethod · 0.50
ssa_stripFunction · 0.50
with_limitsMethod · 0.50
build_function_tableMethod · 0.50
mainFunction · 0.50

Calls 4

collectMethod · 0.80
alternationMethod · 0.80
lenMethod · 0.45
errMethod · 0.45

Tested by

no test coverage detected