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

Method induct

regex/regex-syntax/src/ast/visitor.rs:271–299  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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`.

Callers 1

visitMethod · 0.45

Calls 4

visit_classMethod · 0.80
RepetitionClass · 0.70
GroupClass · 0.70
is_emptyMethod · 0.45

Tested by

no test coverage detected