Lines Matching refs:hir
9 use crate::hir::{self, Error, ErrorKind, Hir};
149 ClassUnicode(hir::ClassUnicode),
157 ClassBytes(hir::ClassBytes),
197 fn unwrap_class_unicode(self) -> hir::ClassUnicode {
210 fn unwrap_class_bytes(self) -> hir::ClassBytes {
248 let cls = hir::ClassUnicode::empty();
251 let cls = hir::ClassBytes::empty();
305 let hcls = hir::Class::Unicode(cls);
309 let hcls = hir::Class::Bytes(cls);
314 let cls = hir::Class::Unicode(self.hir_unicode_class(x)?);
331 let expr = Hir::class(hir::Class::Unicode(cls));
347 let expr = Hir::class(hir::Class::Bytes(cls));
390 let cls = hir::ClassUnicode::empty();
393 let cls = hir::ClassBytes::empty();
413 cls.push(hir::ClassUnicodeRange::new(x.c, x.c));
418 cls.push(hir::ClassBytesRange::new(byte, byte));
425 cls.push(hir::ClassUnicodeRange::new(x.start.c, x.end.c));
431 cls.push(hir::ClassBytesRange::new(start, end));
503 let cls = hir::ClassUnicode::empty();
506 let cls = hir::ClassBytes::empty();
517 let cls = hir::ClassUnicode::empty();
520 let cls = hir::ClassBytes::empty();
632 byte @ hir::Literal::Byte(_) => return Ok(Hir::literal(byte)),
633 hir::Literal::Unicode(ch) => ch,
650 fn literal_to_char(&self, lit: &ast::Literal) -> Result<hir::Literal> {
652 return Ok(hir::Literal::Unicode(lit.c));
655 None => return Ok(hir::Literal::Unicode(lit.c)),
659 return Ok(hir::Literal::Unicode(byte as char));
664 Ok(hir::Literal::Byte(byte))
671 Ok(Hir::literal(hir::Literal::Unicode(c)))
689 hir::ClassUnicode::new(vec![hir::ClassUnicodeRange::new(
695 Ok(Hir::class(hir::Class::Unicode(cls)))
706 hir::ClassBytes::new(vec![hir::ClassBytesRange::new(
710 Ok(Hir::class(hir::Class::Bytes(cls)))
731 hir::Anchor::StartLine
733 hir::Anchor::StartText
736 hir::Anchor::EndLine
738 hir::Anchor::EndText
741 Hir::anchor(hir::Anchor::StartText)
743 ast::AssertionKind::EndText => Hir::anchor(hir::Anchor::EndText),
746 hir::WordBoundary::Unicode
748 hir::WordBoundary::Ascii
753 hir::WordBoundary::UnicodeNegate
763 hir::WordBoundary::AsciiNegate
772 hir::GroupKind::CaptureIndex(idx)
775 hir::GroupKind::CaptureName {
780 ast::GroupKind::NonCapturing(_) => hir::GroupKind::NonCapturing,
782 Hir::group(hir::Group { kind, hir: Box::new(expr) })
787 ast::RepetitionKind::ZeroOrOne => hir::RepetitionKind::ZeroOrOne,
788 ast::RepetitionKind::ZeroOrMore => hir::RepetitionKind::ZeroOrMore,
789 ast::RepetitionKind::OneOrMore => hir::RepetitionKind::OneOrMore,
791 hir::RepetitionKind::Range(hir::RepetitionRange::Exactly(m))
794 hir::RepetitionKind::Range(hir::RepetitionRange::AtLeast(m))
800 hir::RepetitionKind::Range(hir::RepetitionRange::Bounded(m, n))
805 Hir::repetition(hir::Repetition { kind, greedy, hir: Box::new(expr) })
811 ) -> Result<hir::ClassUnicode> {
849 ) -> Result<hir::ClassUnicode> {
850 let mut cls = hir::ClassUnicode::new(
853 .map(|&(s, e)| hir::ClassUnicodeRange::new(s, e)),
862 ) -> Result<hir::ClassBytes> {
863 let mut cls = hir::ClassBytes::new(
866 .map(|&(s, e)| hir::ClassBytesRange::new(s as u8, e as u8)),
875 ) -> Result<hir::ClassUnicode> {
897 ) -> hir::ClassBytes {
921 result: unicode::Result<hir::ClassUnicode>,
922 ) -> Result<hir::ClassUnicode> {
943 class: &mut hir::ClassUnicode,
964 class: &mut hir::ClassBytes,
986 hir::Literal::Byte(byte) => Ok(byte),
987 hir::Literal::Unicode(ch) => {
1086 fn hir_ascii_class_bytes(kind: &ast::ClassAsciiKind) -> hir::ClassBytes {
1090 .map(|(s, e)| hir::ClassBytesRange::new(s as u8, e as u8))
1092 hir::ClassBytes::new(ranges)
1126 use crate::hir::{self, Hir, HirKind};
1131 // We create these errors to compare with real hir::Errors in the tests.
1132 // We define equality between TestError and hir::Error to disregard the
1133 // pattern string in hir::Error, which is annoying to provide in tests.
1137 kind: hir::ErrorKind,
1140 impl PartialEq<hir::Error> for TestError {
1141 fn eq(&self, other: &hir::Error) -> bool {
1146 impl PartialEq<TestError> for hir::Error {
1164 fn t_err(pattern: &str) -> hir::Error {
1186 .map(hir::Literal::Unicode)
1197 1 => Hir::literal(hir::Literal::Byte(s[0])),
1202 .map(hir::Literal::Byte)
1211 Hir::group(hir::Group {
1212 kind: hir::GroupKind::CaptureIndex(i),
1213 hir: Box::new(expr),
1218 Hir::group(hir::Group {
1219 kind: hir::GroupKind::CaptureName {
1223 hir: Box::new(expr),
1228 Hir::group(hir::Group {
1229 kind: hir::GroupKind::NonCapturing,
1230 hir: Box::new(expr),
1235 Hir::repetition(hir::Repetition {
1236 kind: hir::RepetitionKind::ZeroOrOne,
1238 hir: Box::new(expr),
1243 Hir::repetition(hir::Repetition {
1244 kind: hir::RepetitionKind::ZeroOrMore,
1246 hir: Box::new(expr),
1251 Hir::repetition(hir::Repetition {
1252 kind: hir::RepetitionKind::OneOrMore,
1254 hir: Box::new(expr),
1258 fn hir_range(greedy: bool, range: hir::RepetitionRange, expr: Hir) -> Hir {
1259 Hir::repetition(hir::Repetition {
1260 kind: hir::RepetitionKind::Range(range),
1262 hir: Box::new(expr),
1276 Hir::class(hir::Class::Unicode(unicode::class(query).unwrap()))
1281 Hir::class(hir::Class::Unicode(unicode::perl_word().unwrap()))
1285 let ranges: Vec<hir::ClassUnicodeRange> = ranges
1287 .map(|&(s, e)| hir::ClassUnicodeRange::new(s, e))
1289 Hir::class(hir::Class::Unicode(hir::ClassUnicode::new(ranges)))
1293 let ranges: Vec<hir::ClassBytesRange> = ranges
1295 .map(|&(s, e)| hir::ClassBytesRange::new(s, e))
1297 Hir::class(hir::Class::Bytes(hir::ClassBytes::new(ranges)))
1301 let ranges: Vec<hir::ClassBytesRange> = ranges
1306 hir::ClassBytesRange::new(s as u8, e as u8)
1309 Hir::class(hir::Class::Bytes(hir::ClassBytes::new(ranges)))
1334 use crate::hir::Class::{Bytes, Unicode};
1339 Hir::class(hir::Class::Unicode(c1))
1343 Hir::class(hir::Class::Bytes(c1))
1351 use crate::hir::Class::{Bytes, Unicode};
1356 Hir::class(hir::Class::Unicode(c1))
1360 Hir::class(hir::Class::Bytes(c1))
1366 fn hir_anchor(anchor: hir::Anchor) -> Hir {
1370 fn hir_word(wb: hir::WordBoundary) -> Hir {
1428 kind: hir::ErrorKind::UnicodeNotAllowed,
1438 kind: hir::ErrorKind::InvalidUtf8,
1518 kind: hir::ErrorKind::UnicodeNotAllowed,
1544 kind: hir::ErrorKind::InvalidUtf8,
1554 kind: hir::ErrorKind::InvalidUtf8,
1565 assert_eq!(t("^"), hir_anchor(hir::Anchor::StartText));
1566 assert_eq!(t("$"), hir_anchor(hir::Anchor::EndText));
1567 assert_eq!(t(r"\A"), hir_anchor(hir::Anchor::StartText));
1568 assert_eq!(t(r"\z"), hir_anchor(hir::Anchor::EndText));
1569 assert_eq!(t("(?m)^"), hir_anchor(hir::Anchor::StartLine));
1570 assert_eq!(t("(?m)$"), hir_anchor(hir::Anchor::EndLine));
1571 assert_eq!(t(r"(?m)\A"), hir_anchor(hir::Anchor::StartText));
1572 assert_eq!(t(r"(?m)\z"), hir_anchor(hir::Anchor::EndText));
1574 assert_eq!(t(r"\b"), hir_word(hir::WordBoundary::Unicode));
1575 assert_eq!(t(r"\B"), hir_word(hir::WordBoundary::UnicodeNegate));
1576 assert_eq!(t(r"(?-u)\b"), hir_word(hir::WordBoundary::Ascii));
1579 hir_word(hir::WordBoundary::AsciiNegate)
1585 kind: hir::ErrorKind::InvalidUtf8,
1695 hir_anchor(hir::Anchor::StartLine),
1703 hir_anchor(hir::Anchor::StartLine),
1705 hir_anchor(hir::Anchor::StartText),
1760 hir_range(true, hir::RepetitionRange::Exactly(1), hir_lit("a"),)
1764 hir_range(true, hir::RepetitionRange::AtLeast(1), hir_lit("a"),)
1768 hir_range(true, hir::RepetitionRange::Bounded(1, 2), hir_lit("a"),)
1772 hir_range(false, hir::RepetitionRange::Exactly(1), hir_lit("a"),)
1776 hir_range(false, hir::RepetitionRange::AtLeast(1), hir_lit("a"),)
1782 hir::RepetitionRange::Bounded(1, 2),
1943 kind: hir::ErrorKind::InvalidUtf8,
1953 kind: hir::ErrorKind::InvalidUtf8,
2095 kind: hir::ErrorKind::UnicodePerlClassNotFound,
2110 kind: hir::ErrorKind::UnicodePerlClassNotFound,
2128 kind: hir::ErrorKind::UnicodePerlClassNotFound,
2202 kind: hir::ErrorKind::UnicodeNotAllowed,
2212 kind: hir::ErrorKind::UnicodeNotAllowed,
2222 kind: hir::ErrorKind::UnicodePropertyNotFound,
2232 kind: hir::ErrorKind::UnicodePropertyNotFound,
2242 kind: hir::ErrorKind::UnicodePropertyValueNotFound,
2257 kind: hir::ErrorKind::UnicodePropertyNotFound,
2268 kind: hir::ErrorKind::UnicodePropertyNotFound,
2300 kind: hir::ErrorKind::UnicodePropertyValueNotFound,
2310 kind: hir::ErrorKind::UnicodePropertyValueNotFound,
2325 kind: hir::ErrorKind::UnicodePropertyNotFound,
2336 kind: hir::ErrorKind::UnicodePropertyNotFound,
2351 kind: hir::ErrorKind::UnicodePropertyValueNotFound,
2366 kind: hir::ErrorKind::EmptyClassNotAllowed,
2381 kind: hir::ErrorKind::UnicodePropertyNotFound,
2516 kind: hir::ErrorKind::InvalidUtf8,
2527 kind: hir::ErrorKind::EmptyClassNotAllowed,
2538 kind: hir::ErrorKind::EmptyClassNotAllowed,
2695 kind: hir::ErrorKind::EmptyClassNotAllowed,
2706 kind: hir::ErrorKind::EmptyClassNotAllowed,
2929 hir::RepetitionRange::Bounded(5, 10),