Skip to content

Commit b8ecc7f

Browse files
committed
syntax: rename 'hir' to 'sub'
Where 'sub' is short for 'sub-expression.'
1 parent ba6ce32 commit b8ecc7f

File tree

6 files changed

+35
-35
lines changed

6 files changed

+35
-35
lines changed

Diff for: regex-syntax/src/hir/literal.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ impl Extractor {
186186
}
187187
Class(hir::Class::Bytes(ref cls)) => self.extract_class_bytes(cls),
188188
Repetition(ref rep) => self.extract_repetition(rep),
189-
Capture(hir::Capture { ref hir, .. }) => self.extract(hir),
189+
Capture(hir::Capture { ref sub, .. }) => self.extract(sub),
190190
Concat(ref hirs) => match self.kind {
191191
ExtractKind::Prefix => self.extract_concat(hirs.iter()),
192192
ExtractKind::Suffix => self.extract_concat(hirs.iter().rev()),
@@ -448,7 +448,7 @@ impl Extractor {
448448
/// literals being extracted, which might actually be a better prefilter
449449
/// than just 'a'.
450450
fn extract_repetition(&self, rep: &hir::Repetition) -> Seq {
451-
let mut subseq = self.extract(&rep.hir);
451+
let mut subseq = self.extract(&rep.sub);
452452
match *rep {
453453
hir::Repetition { min: 0, max, greedy, .. } => {
454454
// When 'max=1', we can retain exactness, since 'a?' is

Diff for: regex-syntax/src/hir/mod.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ impl Hir {
323323
if rep.min == 0 && rep.max == Some(0) {
324324
return Hir::empty();
325325
} else if rep.min == 1 && rep.max == Some(1) {
326-
return *rep.hir;
326+
return *rep.sub;
327327
}
328328
let props = Properties::repetition(&rep);
329329
Hir { kind: HirKind::Repetition(rep), props }
@@ -1437,7 +1437,7 @@ pub struct Capture {
14371437
/// The name of the capture, if it exists.
14381438
pub name: Option<Box<str>>,
14391439
/// The expression inside the capturing group, which may be empty.
1440-
pub hir: Box<Hir>,
1440+
pub sub: Box<Hir>,
14411441
}
14421442

14431443
/// The high-level intermediate representation of a repetition operator.
@@ -1467,7 +1467,7 @@ pub struct Repetition {
14671467
/// not. However, this can be inverted via the `U` "ungreedy" flag.
14681468
pub greedy: bool,
14691469
/// The expression being repeated.
1470-
pub hir: Box<Hir>,
1470+
pub sub: Box<Hir>,
14711471
}
14721472

14731473
impl Repetition {
@@ -1523,8 +1523,8 @@ impl Drop for Hir {
15231523
| HirKind::Literal(_)
15241524
| HirKind::Class(_)
15251525
| HirKind::Look(_) => return,
1526-
HirKind::Capture(ref x) if !x.hir.kind.has_subexprs() => return,
1527-
HirKind::Repetition(ref x) if !x.hir.kind.has_subexprs() => return,
1526+
HirKind::Capture(ref x) if !x.sub.kind.has_subexprs() => return,
1527+
HirKind::Repetition(ref x) if !x.sub.kind.has_subexprs() => return,
15281528
HirKind::Concat(ref x) if x.is_empty() => return,
15291529
HirKind::Alternation(ref x) if x.is_empty() => return,
15301530
_ => {}
@@ -1538,10 +1538,10 @@ impl Drop for Hir {
15381538
| HirKind::Class(_)
15391539
| HirKind::Look(_) => {}
15401540
HirKind::Capture(ref mut x) => {
1541-
stack.push(mem::replace(&mut x.hir, Hir::empty()));
1541+
stack.push(mem::replace(&mut x.sub, Hir::empty()));
15421542
}
15431543
HirKind::Repetition(ref mut x) => {
1544-
stack.push(mem::replace(&mut x.hir, Hir::empty()));
1544+
stack.push(mem::replace(&mut x.sub, Hir::empty()));
15451545
}
15461546
HirKind::Concat(ref mut x) => {
15471547
stack.extend(x.drain(..));
@@ -1926,7 +1926,7 @@ impl Properties {
19261926

19271927
/// Create a new set of HIR properties for a repetition.
19281928
fn repetition(rep: &Repetition) -> Properties {
1929-
let p = rep.hir.properties();
1929+
let p = rep.sub.properties();
19301930
let minimum_len = p.minimum_len().map(|child_min| {
19311931
let rep_min = usize::try_from(rep.min).unwrap_or(usize::MAX);
19321932
child_min.saturating_mul(rep_min)
@@ -1957,7 +1957,7 @@ impl Properties {
19571957

19581958
/// Create a new set of HIR properties for a capture.
19591959
fn capture(capture: &Capture) -> Properties {
1960-
let p = capture.hir.properties();
1960+
let p = capture.sub.properties();
19611961
Properties(Box::new(PropertiesI {
19621962
captures_len: p.captures_len().saturating_add(1),
19631963
literal: false,
@@ -3054,13 +3054,13 @@ mod tests {
30543054
expr = Hir::capture(Capture {
30553055
index: 1,
30563056
name: None,
3057-
hir: Box::new(expr),
3057+
sub: Box::new(expr),
30583058
});
30593059
expr = Hir::repetition(Repetition {
30603060
min: 0,
30613061
max: Some(1),
30623062
greedy: true,
3063-
hir: Box::new(expr),
3063+
sub: Box::new(expr),
30643064
});
30653065

30663066
expr = Hir {

Diff for: regex-syntax/src/hir/print.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ mod tests {
478478
min: 1,
479479
max: None,
480480
greedy: true,
481-
hir: Box::new(Hir::literal("ab".as_bytes())),
481+
sub: Box::new(Hir::literal("ab".as_bytes())),
482482
}),
483483
Hir::literal("y".as_bytes()),
484484
]);
@@ -490,7 +490,7 @@ mod tests {
490490
min: 1,
491491
max: None,
492492
greedy: true,
493-
hir: Box::new(Hir::concat(alloc::vec![
493+
sub: Box::new(Hir::concat(alloc::vec![
494494
Hir::look(hir::Look::Start),
495495
Hir::look(hir::Look::End),
496496
])),
@@ -512,7 +512,7 @@ mod tests {
512512
min: 1,
513513
max: None,
514514
greedy: true,
515-
hir: Box::new(Hir::alternation(alloc::vec![
515+
sub: Box::new(Hir::alternation(alloc::vec![
516516
Hir::literal("cd".as_bytes()),
517517
Hir::literal("ef".as_bytes()),
518518
])),
@@ -527,7 +527,7 @@ mod tests {
527527
min: 1,
528528
max: None,
529529
greedy: true,
530-
hir: Box::new(Hir::alternation(alloc::vec![
530+
sub: Box::new(Hir::alternation(alloc::vec![
531531
Hir::look(hir::Look::Start),
532532
Hir::look(hir::Look::End),
533533
])),

Diff for: regex-syntax/src/hir/translate.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ impl<'t, 'p> TranslatorI<'t, 'p> {
912912
// in which the data type is defined handles this automatically.
913913
ast::GroupKind::NonCapturing(_) => return expr,
914914
};
915-
Hir::capture(hir::Capture { index, name, hir: Box::new(expr) })
915+
Hir::capture(hir::Capture { index, name, sub: Box::new(expr) })
916916
}
917917

918918
fn hir_repetition(&self, rep: &ast::Repetition, expr: Hir) -> Hir {
@@ -937,7 +937,7 @@ impl<'t, 'p> TranslatorI<'t, 'p> {
937937
min,
938938
max,
939939
greedy,
940-
hir: Box::new(expr),
940+
sub: Box::new(expr),
941941
})
942942
}
943943

@@ -1353,14 +1353,14 @@ mod tests {
13531353
}
13541354

13551355
fn hir_capture(index: u32, expr: Hir) -> Hir {
1356-
Hir::capture(hir::Capture { index, name: None, hir: Box::new(expr) })
1356+
Hir::capture(hir::Capture { index, name: None, sub: Box::new(expr) })
13571357
}
13581358

13591359
fn hir_capture_name(index: u32, name: &str, expr: Hir) -> Hir {
13601360
Hir::capture(hir::Capture {
13611361
index,
13621362
name: Some(name.into()),
1363-
hir: Box::new(expr),
1363+
sub: Box::new(expr),
13641364
})
13651365
}
13661366

@@ -1369,7 +1369,7 @@ mod tests {
13691369
min: 0,
13701370
max: Some(1),
13711371
greedy,
1372-
hir: Box::new(expr),
1372+
sub: Box::new(expr),
13731373
})
13741374
}
13751375

@@ -1378,7 +1378,7 @@ mod tests {
13781378
min: 0,
13791379
max: None,
13801380
greedy,
1381-
hir: Box::new(expr),
1381+
sub: Box::new(expr),
13821382
})
13831383
}
13841384

@@ -1387,7 +1387,7 @@ mod tests {
13871387
min: 1,
13881388
max: None,
13891389
greedy,
1390-
hir: Box::new(expr),
1390+
sub: Box::new(expr),
13911391
})
13921392
}
13931393

@@ -1396,7 +1396,7 @@ mod tests {
13961396
min,
13971397
max,
13981398
greedy,
1399-
hir: Box::new(expr),
1399+
sub: Box::new(expr),
14001400
})
14011401
}
14021402

Diff for: regex-syntax/src/hir/visitor.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ impl<'a> Frame<'a> {
195195
/// child HIR node to visit.
196196
fn child(&self) -> &'a Hir {
197197
match *self {
198-
Frame::Repetition(rep) => &rep.hir,
199-
Frame::Capture(capture) => &capture.hir,
198+
Frame::Repetition(rep) => &rep.sub,
199+
Frame::Capture(capture) => &capture.sub,
200200
Frame::Concat { head, .. } => head,
201201
Frame::Alternation { head, .. } => head,
202202
}

Diff for: src/compile.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ impl Compiler {
368368
self.c_empty_look(prog::EmptyLook::NotWordBoundary)
369369
}
370370
},
371-
Capture(hir::Capture { index, ref name, ref hir }) => {
371+
Capture(hir::Capture { index, ref name, ref sub }) => {
372372
if index as usize >= self.compiled.captures.len() {
373373
let name = match *name {
374374
None => None,
@@ -379,7 +379,7 @@ impl Compiler {
379379
self.capture_name_idx.insert(name, index as usize);
380380
}
381381
}
382-
self.c_capture(2 * index as usize, hir)
382+
self.c_capture(2 * index as usize, sub)
383383
}
384384
Concat(ref es) => {
385385
if self.compiled.is_reverse {
@@ -434,7 +434,7 @@ impl Compiler {
434434
min: 0,
435435
max: None,
436436
greedy: false,
437-
hir: Box::new(hir),
437+
sub: Box::new(hir),
438438
}))?
439439
.unwrap())
440440
}
@@ -644,14 +644,14 @@ impl Compiler {
644644

645645
fn c_repeat(&mut self, rep: &hir::Repetition) -> ResultOrEmpty {
646646
match (rep.min, rep.max) {
647-
(0, Some(1)) => self.c_repeat_zero_or_one(&rep.hir, rep.greedy),
648-
(0, None) => self.c_repeat_zero_or_more(&rep.hir, rep.greedy),
649-
(1, None) => self.c_repeat_one_or_more(&rep.hir, rep.greedy),
647+
(0, Some(1)) => self.c_repeat_zero_or_one(&rep.sub, rep.greedy),
648+
(0, None) => self.c_repeat_zero_or_more(&rep.sub, rep.greedy),
649+
(1, None) => self.c_repeat_one_or_more(&rep.sub, rep.greedy),
650650
(min, None) => {
651-
self.c_repeat_range_min_or_more(&rep.hir, rep.greedy, min)
651+
self.c_repeat_range_min_or_more(&rep.sub, rep.greedy, min)
652652
}
653653
(min, Some(max)) => {
654-
self.c_repeat_range(&rep.hir, rep.greedy, min, max)
654+
self.c_repeat_range(&rep.sub, rep.greedy, min, max)
655655
}
656656
}
657657
}

0 commit comments

Comments
 (0)