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

Method push_group

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

Parse and push a group AST (and its parent concatenation) on to the parser's internal stack. Return a fresh concatenation corresponding to the group's sub-AST. If a set of flags was found (with no group), then the concatenation is returned with that set of flags added. This assumes that the parser is currently positioned on the opening parenthesis. It advances the parser to the character at the

(&self, mut concat: ast::Concat)

Source from the content-addressed store, hash-verified

694 /// If there was a problem parsing the start of the group, then an error
695 /// is returned.
696 fn push_group(&self, mut concat: ast::Concat) -> Result<ast::Concat> {
697 assert_eq!(self.char(), '(');
698 match self.parse_group()? {
699 Either::Left(set) => {
700 let ignore = set.flags.flag_state(ast::Flag::IgnoreWhitespace);
701 if let Some(v) = ignore {
702 self.parser().ignore_whitespace.set(v);
703 }
704
705 concat.asts.push(Ast::Flags(set));
706 Ok(concat)
707 }
708 Either::Right(group) => {
709 let old_ignore_whitespace = self.ignore_whitespace();
710 let new_ignore_whitespace = group
711 .flags()
712 .and_then(|f| f.flag_state(ast::Flag::IgnoreWhitespace))
713 .unwrap_or(old_ignore_whitespace);
714 self.parser().stack_group.borrow_mut().push(GroupState::Group {
715 concat: concat,
716 group: group,
717 ignore_whitespace: old_ignore_whitespace,
718 });
719 self.parser().ignore_whitespace.set(new_ignore_whitespace);
720 Ok(ast::Concat {
721 span: self.span(),
722 asts: vec![],
723 })
724 }
725 }
726 }
727
728 /// Pop a group AST from the parser's internal stack and set the group's
729 /// AST to the given concatenation. Return the concatenation containing

Callers 1

parse_with_commentsMethod · 0.80

Calls 8

parse_groupMethod · 0.80
flag_stateMethod · 0.80
parserMethod · 0.80
FlagsClass · 0.70
pushMethod · 0.45
ignore_whitespaceMethod · 0.45
flagsMethod · 0.45
spanMethod · 0.45

Tested by

no test coverage detected