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)
| 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 |
no test coverage detected