Build a stack frame for the given AST if one is needed (which occurs if and only if there are child nodes in the AST). Otherwise, return None. If this visits a class, then the underlying visitor implementation may return an error which will be passed on here.
(
&mut self,
ast: &'a Ast,
visitor: &mut V,
)
| 269 | /// If this visits a class, then the underlying visitor implementation may |
| 270 | /// return an error which will be passed on here. |
| 271 | fn induct<V: Visitor>( |
| 272 | &mut self, |
| 273 | ast: &'a Ast, |
| 274 | visitor: &mut V, |
| 275 | ) -> Result<Option<Frame<'a>>, V::Err> { |
| 276 | Ok(match *ast { |
| 277 | Ast::Class(ast::Class::Bracketed(ref x)) => { |
| 278 | self.visit_class(x, visitor)?; |
| 279 | None |
| 280 | } |
| 281 | Ast::Repetition(ref x) => Some(Frame::Repetition(x)), |
| 282 | Ast::Group(ref x) => Some(Frame::Group(x)), |
| 283 | Ast::Concat(ref x) if x.asts.is_empty() => None, |
| 284 | Ast::Concat(ref x) => { |
| 285 | Some(Frame::Concat { |
| 286 | head: &x.asts[0], |
| 287 | tail: &x.asts[1..], |
| 288 | }) |
| 289 | } |
| 290 | Ast::Alternation(ref x) if x.asts.is_empty() => None, |
| 291 | Ast::Alternation(ref x) => { |
| 292 | Some(Frame::Alternation { |
| 293 | head: &x.asts[0], |
| 294 | tail: &x.asts[1..], |
| 295 | }) |
| 296 | } |
| 297 | _ => None, |
| 298 | }) |
| 299 | } |
| 300 | |
| 301 | /// Pops the given frame. If the frame has an additional inductive step, |
| 302 | /// then return it, otherwise return `None`. |
no test coverage detected