MCPcopy Create free account
hub / github.com/davidblewett/rure-python / push_or_add_alternation

Method push_or_add_alternation

regex/regex-syntax/src/ast/parse.rs:669–681  ·  view source on GitHub ↗

Pushes or adds the given branch of an alternation to the parser's internal stack of state.

(&self, concat: ast::Concat)

Source from the content-addressed store, hash-verified

667 /// Pushes or adds the given branch of an alternation to the parser's
668 /// internal stack of state.
669 fn push_or_add_alternation(&self, concat: ast::Concat) {
670 use self::GroupState::*;
671
672 let mut stack = self.parser().stack_group.borrow_mut();
673 if let Some(&mut Alternation(ref mut alts)) = stack.last_mut() {
674 alts.asts.push(concat.into_ast());
675 return;
676 }
677 stack.push(Alternation(ast::Alternation {
678 span: Span::new(concat.span.start, self.pos()),
679 asts: vec![concat.into_ast()],
680 }));
681 }
682
683 /// Parse and push a group AST (and its parent concatenation) on to the
684 /// parser's internal stack. Return a fresh concatenation corresponding

Callers 1

push_alternateMethod · 0.80

Calls 5

AlternationClass · 0.85
parserMethod · 0.80
pushMethod · 0.45
into_astMethod · 0.45
posMethod · 0.45

Tested by

no test coverage detected