Creates a repetition HIR expression.
(rep: Repetition)
| 347 | |
| 348 | /// Creates a repetition HIR expression. |
| 349 | pub fn repetition(rep: Repetition) -> Hir { |
| 350 | let mut info = HirInfo::new(); |
| 351 | info.set_always_utf8(rep.hir.is_always_utf8()); |
| 352 | info.set_all_assertions(rep.hir.is_all_assertions()); |
| 353 | // If this operator can match the empty string, then it can never |
| 354 | // be anchored. |
| 355 | info.set_anchored_start( |
| 356 | !rep.is_match_empty() && rep.hir.is_anchored_start() |
| 357 | ); |
| 358 | info.set_anchored_end( |
| 359 | !rep.is_match_empty() && rep.hir.is_anchored_end() |
| 360 | ); |
| 361 | info.set_line_anchored_start( |
| 362 | !rep.is_match_empty() && rep.hir.is_anchored_start() |
| 363 | ); |
| 364 | info.set_line_anchored_end( |
| 365 | !rep.is_match_empty() && rep.hir.is_anchored_end() |
| 366 | ); |
| 367 | info.set_any_anchored_start(rep.hir.is_any_anchored_start()); |
| 368 | info.set_any_anchored_end(rep.hir.is_any_anchored_end()); |
| 369 | info.set_match_empty(rep.is_match_empty() || rep.hir.is_match_empty()); |
| 370 | info.set_literal(false); |
| 371 | info.set_alternation_literal(false); |
| 372 | Hir { |
| 373 | kind: HirKind::Repetition(rep), |
| 374 | info: info, |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | /// Creates a group HIR expression. |
| 379 | pub fn group(group: Group) -> Hir { |
nothing calls this directly
no test coverage detected