Skip to main content

parse_with_empty_loop

Function parse_with_empty_loop 

Source
pub fn parse_with_empty_loop(
    src: &str,
) -> Result<(Pattern, EmptyLoop), ParseError>
Expand description

Parse a pattern that may open with (?empty:perl) or (?empty:thompson), returning the tree beside the reading it named.

The directive is zero-width and governs the whole pattern, so it is read off the front rather than compiled into a node: a reading carried in the tree is one every consumer of the tree can forget to look at, and the consequence of forgetting is a wrong match rather than a failure to build.

parse accepts the same directive and discards it, so a caller that does not ask for the reading is not silently given a pattern whose reading it is not honouring - it gets EmptyLoop::Thompson, which is what it would have got anyway.

ยงErrors

Returns a ParseError when the pattern is malformed, and when the directive names a reading that does not exist.