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

Method alternation

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

Lowest precedence, branches split on the pipe. */

(&mut self)

Source from the content-addressed store, hash-verified

45
46 /* Lowest precedence, branches split on the pipe. */
47 fn alternation(&mut self) -> Result<Node, ParseError> {
48 let mut branches = Vec::new();
49 branches.push(self.concat()?);
50 while self.peek() == Some('|') {
51 self.bump();
52 branches.push(self.concat()?);
53 }
54 if branches.len() == 1 { Ok(branches.pop().unwrap()) }
55 else { Ok(Node::Alt(branches)) }
56 }
57
58 /* A run of quantified atoms until pipe, close paren, or end. */
59 fn concat(&mut self) -> Result<Node, ParseError> {

Callers 4

parseFunction · 0.80
groupMethod · 0.80
lookMethod · 0.80
named_groupMethod · 0.80

Calls 6

pushMethod · 0.80
concatMethod · 0.80
bumpMethod · 0.80
peekMethod · 0.45
lenMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected