Reject lookbehind whose width is not fixed, which the engine cannot run. */
(node: &Node)
| 182 | |
| 183 | /* Reject lookbehind whose width is not fixed, which the engine cannot run. */ |
| 184 | fn validate(node: &Node) -> Result<(), ReError> { |
| 185 | match node { |
| 186 | Node::Look { node, behind: true, .. } => { |
| 187 | if fixed_len(node).is_none() { return Err(ReError::Syntax(String::from("lookbehind requires fixed width"))); } |
| 188 | validate(node) |
| 189 | } |
| 190 | Node::Look { node, .. } => validate(node), |
| 191 | Node::Concat(v) | Node::Alt(v) => { for n in v { validate(n)?; } Ok(()) } |
| 192 | Node::Group { node, .. } | Node::NonCap(node) | Node::Repeat { node, .. } => validate(node), |
| 193 | _ => Ok(()), |
| 194 | } |
| 195 | } |