Lines Matching defs:ast
10 use crate::ast::{self, Ast, Position, Span};
15 type Result<T> = result::Result<T, ast::Error>;
25 Literal(ast::Literal),
26 Assertion(ast::Assertion),
28 Perl(ast::ClassPerl),
29 Unicode(ast::ClassUnicode),
50 Primitive::Perl(cls) => Ast::Class(ast::Class::Perl(cls)),
51 Primitive::Unicode(cls) => Ast::Class(ast::Class::Unicode(cls)),
62 ) -> Result<ast::ClassSetItem> {
64 use crate::ast::ClassSetItem;
70 x => Err(p.error(*x.span(), ast::ErrorKind::ClassEscapeInvalid)),
83 ) -> Result<ast::Literal> {
88 x => Err(p.error(*x.span(), ast::ErrorKind::ClassRangeLiteral)),
245 comments: RefCell<Vec<ast::Comment>>,
253 capture_names: RefCell<Vec<ast::CaptureName>>,
284 concat: ast::Concat,
286 group: ast::Group,
294 Alternation(ast::Alternation),
308 union: ast::ClassSetUnion,
312 set: ast::ClassBracketed,
318 kind: ast::ClassSetBinaryOpKind,
320 lhs: ast::ClassSet,
346 ) -> Result<ast::WithComments> {
383 fn error(&self, span: Span, kind: ast::ErrorKind) -> ast::Error {
384 ast::Error { kind, pattern: self.pattern().to_string(), span }
419 self.error(span, ast::ErrorKind::CaptureLimitExceeded)
427 fn add_capture_name(&self, cap: &ast::CaptureName) -> Result<()> {
438 ast::ErrorKind::GroupNameDuplicate { original: names[i].span },
552 let comment = ast::Comment {
640 fn push_alternate(&self, mut concat: ast::Concat) -> Result<ast::Concat> {
645 Ok(ast::Concat { span: self.span(), asts: vec![] })
650 fn push_or_add_alternation(&self, concat: ast::Concat) {
658 stack.push(Alternation(ast::Alternation {
678 fn push_group(&self, mut concat: ast::Concat) -> Result<ast::Concat> {
682 let ignore = set.flags.flag_state(ast::Flag::IgnoreWhitespace);
694 .and_then(|f| f.flag_state(ast::Flag::IgnoreWhitespace))
704 Ok(ast::Concat { span: self.span(), asts: vec![] })
719 fn pop_group(&self, mut group_concat: ast::Concat) -> Result<ast::Concat> {
737 ast::ErrorKind::GroupUnopened,
743 .error(self.span_char(), ast::ErrorKind::GroupUnopened));
754 group.ast = Box::new(alt.into_ast());
757 group.ast = Box::new(group_concat.into_ast());
771 fn pop_group_end(&self, mut concat: ast::Concat) -> Result<Ast> {
774 let ast = match stack.pop() {
783 self.error(group.span, ast::ErrorKind::GroupUnclosed)
789 None => ast,
800 Err(self.error(group.span, ast::ErrorKind::GroupUnclosed))
816 parent_union: ast::ClassSetUnion,
817 ) -> Result<ast::ClassSetUnion> {
845 nested_union: ast::ClassSetUnion,
846 ) -> Result<Either<ast::ClassSetUnion, ast::Class>> {
849 let item = ast::ClassSet::Item(nested_union.into_item());
878 Ok(Either::Right(ast::Class::Bracketed(set)))
880 union.push(ast::ClassSetItem::Bracketed(Box::new(set)));
892 fn unclosed_class_error(&self) -> ast::Error {
895 return self.error(set.span, ast::ErrorKind::ClassUnclosed);
911 next_kind: ast::ClassSetBinaryOpKind,
912 next_union: ast::ClassSetUnion,
913 ) -> ast::ClassSetUnion {
914 let item = ast::ClassSet::Item(next_union.into_item());
920 ast::ClassSetUnion { span: self.span(), items: vec![] }
929 fn pop_class_op(&self, rhs: ast::ClassSet) -> ast::ClassSet {
940 ast::ClassSet::BinaryOp(ast::ClassSetBinaryOp {
952 self.parse_with_comments().map(|astc| astc.ast)
957 fn parse_with_comments(&self) -> Result<ast::WithComments> {
960 let mut concat = ast::Concat { span: self.span(), asts: vec![] };
977 ast::RepetitionKind::ZeroOrOne,
983 ast::RepetitionKind::ZeroOrMore,
989 ast::RepetitionKind::OneOrMore,
998 let ast = self.pop_group_end(concat)?;
999 NestLimiter::new(self).check(&ast)?;
1000 Ok(ast::WithComments {
1001 ast,
1025 mut concat: ast::Concat,
1026 kind: ast::RepetitionKind,
1027 ) -> Result<ast::Concat> {
1032 let ast = match concat.asts.pop() {
1033 Some(ast) => ast,
1036 self.error(self.span(), ast::ErrorKind::RepetitionMissing)
1040 match ast {
1043 self.error(self.span(), ast::ErrorKind::RepetitionMissing)
1053 concat.asts.push(Ast::Repetition(ast::Repetition {
1054 span: ast.span().with_end(self.pos()),
1055 op: ast::RepetitionOp {
1060 ast: Box::new(ast),
1080 mut concat: ast::Concat,
1081 ) -> Result<ast::Concat> {
1084 let ast = match concat.asts.pop() {
1085 Some(ast) => ast,
1088 self.error(self.span(), ast::ErrorKind::RepetitionMissing)
1092 match ast {
1095 self.error(self.span(), ast::ErrorKind::RepetitionMissing)
1103 ast::ErrorKind::RepetitionCountUnclosed,
1108 ast::ErrorKind::DecimalEmpty,
1109 ast::ErrorKind::RepetitionCountDecimalEmpty,
1111 let mut range = ast::RepetitionRange::Exactly(count_start);
1115 ast::ErrorKind::RepetitionCountUnclosed,
1122 ast::ErrorKind::RepetitionCountUnclosed,
1128 ast::ErrorKind::DecimalEmpty,
1129 ast::ErrorKind::RepetitionCountDecimalEmpty,
1131 range = ast::RepetitionRange::Bounded(count_start, count_end);
1133 range = ast::RepetitionRange::AtLeast(count_start);
1139 ast::ErrorKind::RepetitionCountUnclosed,
1152 self.error(op_span, ast::ErrorKind::RepetitionCountInvalid)
1155 concat.asts.push(Ast::Repetition(ast::Repetition {
1156 span: ast.span().with_end(self.pos()),
1157 op: ast::RepetitionOp {
1159 kind: ast::RepetitionKind::Range(range),
1162 ast: Box::new(ast),
1186 fn parse_group(&self) -> Result<Either<ast::SetFlags, ast::Group>> {
1194 ast::ErrorKind::UnsupportedLookAround,
1201 Ok(Either::Right(ast::Group {
1203 kind: ast::GroupKind::CaptureName(cap),
1204 ast: Box::new(Ast::Empty(self.span())),
1209 self.error(open_span, ast::ErrorKind::GroupUnclosed)
1221 ast::ErrorKind::RepetitionMissing,
1224 Ok(Either::Left(ast::SetFlags {
1230 Ok(Either::Right(ast::Group {
1232 kind: ast::GroupKind::NonCapturing(flags),
1233 ast: Box::new(Ast::Empty(self.span())),
1238 Ok(Either::Right(ast::Group {
1240 kind: ast::GroupKind::CaptureIndex(capture_index),
1241 ast: Box::new(Ast::Empty(self.span())),
1256 ) -> Result<ast::CaptureName> {
1259 .error(self.span(), ast::ErrorKind::GroupNameUnexpectedEof));
1269 ast::ErrorKind::GroupNameInvalid,
1279 .error(self.span(), ast::ErrorKind::GroupNameUnexpectedEof));
1287 ast::ErrorKind::GroupNameEmpty,
1290 let capname = ast::CaptureName {
1314 fn parse_flags(&self) -> Result<ast::Flags> {
1315 let mut flags = ast::Flags { span: self.span(), items: vec![] };
1320 let item = ast::FlagsItem {
1322 kind: ast::FlagsItemKind::Negation,
1327 ast::ErrorKind::FlagRepeatedNegation {
1334 let item = ast::FlagsItem {
1336 kind: ast::FlagsItemKind::Flag(self.parse_flag()?),
1341 ast::ErrorKind::FlagDuplicate {
1349 self.error(self.span(), ast::ErrorKind::FlagUnexpectedEof)
1354 return Err(self.error(span, ast::ErrorKind::FlagDanglingNegation));
1366 fn parse_flag(&self) -> Result<ast::Flag> {
1368 'i' => Ok(ast::Flag::CaseInsensitive),
1369 'm' => Ok(ast::Flag::MultiLine),
1370 's' => Ok(ast::Flag::DotMatchesNewLine),
1371 'U' => Ok(ast::Flag::SwapGreed),
1372 'u' => Ok(ast::Flag::Unicode),
1373 'x' => Ok(ast::Flag::IgnoreWhitespace),
1376 .error(self.span_char(), ast::ErrorKind::FlagUnrecognized))
1395 let ast = Primitive::Dot(self.span_char());
1397 Ok(ast)
1400 let ast = Primitive::Assertion(ast::Assertion {
1402 kind: ast::AssertionKind::StartLine,
1405 Ok(ast)
1408 let ast = Primitive::Assertion(ast::Assertion {
1410 kind: ast::AssertionKind::EndLine,
1413 Ok(ast)
1416 let ast = Primitive::Literal(ast::Literal {
1418 kind: ast::LiteralKind::Verbatim,
1422 Ok(ast)
1439 ast::ErrorKind::EscapeUnexpectedEof,
1449 ast::ErrorKind::UnsupportedBackreference,
1459 ast::ErrorKind::UnsupportedBackreference,
1484 return Ok(Primitive::Literal(ast::Literal {
1486 kind: ast::LiteralKind::Punctuation,
1491 Ok(Primitive::Literal(ast::Literal {
1493 kind: ast::LiteralKind::Special(kind),
1498 'a' => special(ast::SpecialLiteralKind::Bell, '\x07'),
1499 'f' => special(ast::SpecialLiteralKind::FormFeed, '\x0C'),
1500 't' => special(ast::SpecialLiteralKind::Tab, '\t'),
1501 'n' => special(ast::SpecialLiteralKind::LineFeed, '\n'),
1502 'r' => special(ast::SpecialLiteralKind::CarriageReturn, '\r'),
1503 'v' => special(ast::SpecialLiteralKind::VerticalTab, '\x0B'),
1505 special(ast::SpecialLiteralKind::Space, ' ')
1507 'A' => Ok(Primitive::Assertion(ast::Assertion {
1509 kind: ast::AssertionKind::StartText,
1511 'z' => Ok(Primitive::Assertion(ast::Assertion {
1513 kind: ast::AssertionKind::EndText,
1515 'b' => Ok(Primitive::Assertion(ast::Assertion {
1517 kind: ast::AssertionKind::WordBoundary,
1519 'B' => Ok(Primitive::Assertion(ast::Assertion {
1521 kind: ast::AssertionKind::NotWordBoundary,
1523 _ => Err(self.error(span, ast::ErrorKind::EscapeUnrecognized)),
1535 fn parse_octal(&self) -> ast::Literal {
1557 ast::Literal {
1559 kind: ast::LiteralKind::Octal,
1569 fn parse_hex(&self) -> Result<ast::Literal> {
1575 'x' => ast::HexLiteralKind::X,
1576 'u' => ast::HexLiteralKind::UnicodeShort,
1577 _ => ast::HexLiteralKind::UnicodeLong,
1581 self.error(self.span(), ast::ErrorKind::EscapeUnexpectedEof)
1601 kind: ast::HexLiteralKind,
1602 ) -> Result<ast::Literal> {
1613 .error(self.span(), ast::ErrorKind::EscapeUnexpectedEof));
1618 ast::ErrorKind::EscapeHexInvalidDigit,
1631 ast::ErrorKind::EscapeHexInvalid,
1633 Some(c) => Ok(ast::Literal {
1635 kind: ast::LiteralKind::HexFixed(kind),
1647 kind: ast::HexLiteralKind,
1648 ) -> Result<ast::Literal> {
1661 ast::ErrorKind::EscapeHexInvalidDigit,
1669 ast::ErrorKind::EscapeUnexpectedEof,
1680 ast::ErrorKind::EscapeHexEmpty,
1686 ast::ErrorKind::EscapeHexInvalid,
1688 Some(c) => Ok(ast::Literal {
1690 kind: ast::LiteralKind::HexBrace(kind),
1723 return Err(self.error(span, ast::ErrorKind::DecimalEmpty));
1727 None => Err(self.error(span, ast::ErrorKind::DecimalInvalid)),
1739 fn parse_set_class(&self) -> Result<ast::Class> {
1743 ast::ClassSetUnion { span: self.span(), items: vec![] };
1757 union.push(ast::ClassSetItem::Ascii(cls));
1772 ast::ClassSetBinaryOpKind::Intersection,
1779 ast::ClassSetBinaryOpKind::Difference,
1786 ast::ClassSetBinaryOpKind::SymmetricDifference,
1806 fn parse_set_class_range(&self) -> Result<ast::ClassSetItem> {
1829 let range = ast::ClassSetRange {
1836 self.error(range.span, ast::ErrorKind::ClassRangeInvalid)
1839 Ok(ast::ClassSetItem::Range(range))
1857 let x = Primitive::Literal(ast::Literal {
1859 kind: ast::LiteralKind::Verbatim,
1875 /// In all cases, the op inside the returned `ast::ClassBracketed` is an
1886 ) -> Result<(ast::ClassBracketed, ast::ClassSetUnion)> {
1892 ast::ErrorKind::ClassUnclosed,
1902 ast::ErrorKind::ClassUnclosed,
1909 ast::ClassSetUnion { span: self.span(), items: vec![] };
1911 union.push(ast::ClassSetItem::Literal(ast::Literal {
1913 kind: ast::LiteralKind::Verbatim,
1919 ast::ErrorKind::ClassUnclosed,
1926 union.push(ast::ClassSetItem::Literal(ast::Literal {
1928 kind: ast::LiteralKind::Verbatim,
1934 ast::ErrorKind::ClassUnclosed,
1938 let set = ast::ClassBracketed {
1941 kind: ast::ClassSet::union(ast::ClassSetUnion {
1958 fn maybe_parse_ascii_class(&self) -> Option<ast::ClassAscii> {
2008 let kind = match ast::ClassAsciiKind::from_name(name) {
2015 Some(ast::ClassAscii {
2029 fn parse_unicode_class(&self) -> Result<ast::ClassUnicode> {
2038 self.error(self.span(), ast::ErrorKind::EscapeUnexpectedEof)
2048 .error(self.span(), ast::ErrorKind::EscapeUnexpectedEof));
2057 ast::ClassUnicodeKind::NamedValue {
2058 op: ast::ClassUnicodeOpKind::NotEqual,
2066 ast::ClassUnicodeKind::NamedValue {
2067 op: ast::ClassUnicodeOpKind::Colon,
2075 ast::ClassUnicodeKind::NamedValue {
2076 op: ast::ClassUnicodeOpKind::Equal,
2082 (start, ast::ClassUnicodeKind::Named(name.to_string()))
2090 ast::ErrorKind::UnicodeClassInvalid,
2094 let kind = ast::ClassUnicodeKind::OneLetter(c);
2097 Ok(ast::ClassUnicode {
2108 fn parse_perl_class(&self) -> ast::ClassPerl {
2113 'd' => (false, ast::ClassPerlKind::Digit),
2114 'D' => (true, ast::ClassPerlKind::Digit),
2115 's' => (false, ast::ClassPerlKind::Space),
2116 'S' => (true, ast::ClassPerlKind::Space),
2117 'w' => (false, ast::ClassPerlKind::Word),
2118 'W' => (true, ast::ClassPerlKind::Word),
2121 ast::ClassPerl { span, kind, negated }
2141 fn check(self, ast: &Ast) -> Result<()> {
2142 ast::visit(ast, self)
2149 ast::ErrorKind::NestLimitExceeded(::std::u32::MAX),
2156 ast::ErrorKind::NestLimitExceeded(limit),
2170 impl<'p, 's, P: Borrow<Parser>> ast::Visitor for NestLimiter<'p, 's, P> {
2172 type Err = ast::Error;
2178 fn visit_pre(&mut self, ast: &Ast) -> Result<()> {
2179 let span = match *ast {
2185 | Ast::Class(ast::Class::Unicode(_))
2186 | Ast::Class(ast::Class::Perl(_)) => {
2190 Ast::Class(ast::Class::Bracketed(ref x)) => &x.span,
2199 fn visit_post(&mut self, ast: &Ast) -> Result<()> {
2200 match *ast {
2206 | Ast::Class(ast::Class::Unicode(_))
2207 | Ast::Class(ast::Class::Perl(_)) => {
2211 Ast::Class(ast::Class::Bracketed(_))
2224 ast: &ast::ClassSetItem,
2226 let span = match *ast {
2227 ast::ClassSetItem::Empty(_)
2228 | ast::ClassSetItem::Literal(_)
2229 | ast::ClassSetItem::Range(_)
2230 | ast::ClassSetItem::Ascii(_)
2231 | ast::ClassSetItem::Unicode(_)
2232 | ast::ClassSetItem::Perl(_) => {
2236 ast::ClassSetItem::Bracketed(ref x) => &x.span,
2237 ast::ClassSetItem::Union(ref x) => &x.span,
2244 ast: &ast::ClassSetItem,
2246 match *ast {
2247 ast::ClassSetItem::Empty(_)
2248 | ast::ClassSetItem::Literal(_)
2249 | ast::ClassSetItem::Range(_)
2250 | ast::ClassSetItem::Ascii(_)
2251 | ast::ClassSetItem::Unicode(_)
2252 | ast::ClassSetItem::Perl(_) => {
2256 ast::ClassSetItem::Bracketed(_) | ast::ClassSetItem::Union(_) => {
2265 ast: &ast::ClassSetBinaryOp,
2267 self.increment_depth(&ast.span)
2272 _ast: &ast::ClassSetBinaryOp,
2279 /// When the result is an error, transforms the ast::ErrorKind from the source
2284 from: ast::ErrorKind,
2285 to: ast::ErrorKind,
2289 Err(ast::Error { kind: to, pattern: e.pattern, span: e.span })
2303 use crate::ast::{self, Ast, Position, Span};
2323 // We create these errors to compare with real ast::Errors in the tests.
2324 // We define equality between TestError and ast::Error to disregard the
2325 // pattern string in ast::Error, which is annoying to provide in tests.
2329 kind: ast::ErrorKind,
2332 impl PartialEq<ast::Error> for TestError {
2333 fn eq(&self, other: &ast::Error) -> bool {
2338 impl PartialEq<TestError> for ast::Error {
2419 Ast::Literal(ast::Literal {
2421 kind: ast::LiteralKind::Punctuation,
2428 Ast::Literal(ast::Literal {
2430 kind: ast::LiteralKind::Verbatim,
2442 Ast::Concat(ast::Concat { span, asts })
2447 Ast::Alternation(ast::Alternation { span: span(range), asts })
2451 fn group(range: Range<usize>, index: u32, ast: Ast) -> Ast {
2452 Ast::Group(ast::Group {
2454 kind: ast::GroupKind::CaptureIndex(index),
2455 ast: Box::new(ast),
2459 /// Create an ast::SetFlags.
2469 flag: ast::Flag,
2472 let mut items = vec![ast::FlagsItem {
2474 kind: ast::FlagsItemKind::Flag(flag),
2479 ast::FlagsItem {
2481 kind: ast::FlagsItemKind::Negation,
2485 Ast::Flags(ast::SetFlags {
2487 flags: ast::Flags {
2508 kind: ast::ErrorKind::NestLimitExceeded(0),
2513 Ok(Ast::Repetition(ast::Repetition {
2515 op: ast::RepetitionOp {
2517 kind: ast::RepetitionKind::OneOrMore,
2520 ast: Box::new(lit('a', 0)),
2527 kind: ast::ErrorKind::NestLimitExceeded(1),
2534 kind: ast::ErrorKind::NestLimitExceeded(1),
2539 Ok(Ast::Repetition(ast::Repetition {
2541 op: ast::RepetitionOp {
2543 kind: ast::RepetitionKind::ZeroOrMore,
2546 ast: Box::new(Ast::Repetition(ast::Repetition {
2548 op: ast::RepetitionOp {
2550 kind: ast::RepetitionKind::OneOrMore,
2553 ast: Box::new(lit('a', 0)),
2563 kind: ast::ErrorKind::NestLimitExceeded(0),
2580 kind: ast::ErrorKind::NestLimitExceeded(0),
2598 kind: ast::ErrorKind::NestLimitExceeded(0),
2603 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
2606 kind: ast::ClassSet::Item(ast::ClassSetItem::Literal(
2607 ast::Literal {
2609 kind: ast::LiteralKind::Verbatim,
2619 kind: ast::ErrorKind::NestLimitExceeded(1),
2626 kind: ast::ErrorKind::NestLimitExceeded(2),
2633 kind: ast::ErrorKind::NestLimitExceeded(3),
2640 kind: ast::ErrorKind::NestLimitExceeded(1),
2647 kind: ast::ErrorKind::NestLimitExceeded(2),
2662 astc.ast,
2666 flag_set(pat, 0..4, ast::Flag::IgnoreWhitespace, false),
2679 ast::Comment {
2683 ast::Comment {
2687 ast::Comment {
2691 ast::Comment {
2739 flag_set(pat, 0..4, ast::Flag::IgnoreWhitespace, false),
2753 flag_set(pat, 0..4, ast::Flag::IgnoreWhitespace, false),
2756 flag_set(pat, 7..12, ast::Flag::IgnoreWhitespace, true),
2773 Ast::Group(ast::Group {
2775 kind: ast::GroupKind::NonCapturing(ast::Flags {
2777 items: vec![ast::FlagsItem {
2779 kind: ast::FlagsItemKind::Flag(
2780 ast::Flag::IgnoreWhitespace
2784 ast: Box::new(lit_with('a', span_range(pat, 6..7))),
2799 flag_set(pat, 0..4, ast::Flag::IgnoreWhitespace, false),
2800 Ast::Group(ast::Group {
2802 kind: ast::GroupKind::CaptureName(ast::CaptureName {
2807 ast: Box::new(lit_with('a', span_range(pat, 14..15))),
2818 flag_set(pat, 0..4, ast::Flag::IgnoreWhitespace, false),
2819 Ast::Group(ast::Group {
2821 kind: ast::GroupKind::CaptureIndex(1),
2822 ast: Box::new(lit_with('a', span_range(pat, 7..8))),
2833 flag_set(pat, 0..4, ast::Flag::IgnoreWhitespace, false),
2834 Ast::Group(ast::Group {
2836 kind: ast::GroupKind::NonCapturing(ast::Flags {
2840 ast: Box::new(lit_with('a', span_range(pat, 11..12))),
2851 flag_set(pat, 0..4, ast::Flag::IgnoreWhitespace, false),
2852 Ast::Literal(ast::Literal {
2854 kind: ast::LiteralKind::HexBrace(
2855 ast::HexLiteralKind::X
2870 flag_set(pat, 0..4, ast::Flag::IgnoreWhitespace, false),
2871 Ast::Literal(ast::Literal {
2873 kind: ast::LiteralKind::Special(
2874 ast::SpecialLiteralKind::Space
2887 kind: ast::ErrorKind::EscapeUnrecognized,
2938 Ok(Ast::Repetition(ast::Repetition {
2940 op: ast::RepetitionOp {
2942 kind: ast::RepetitionKind::ZeroOrMore,
2945 ast: Box::new(lit('a', 0)),
2950 Ok(Ast::Repetition(ast::Repetition {
2952 op: ast::RepetitionOp {
2954 kind: ast::RepetitionKind::OneOrMore,
2957 ast: Box::new(lit('a', 0)),
2963 Ok(Ast::Repetition(ast::Repetition {
2965 op: ast::RepetitionOp {
2967 kind: ast::RepetitionKind::ZeroOrOne,
2970 ast: Box::new(lit('a', 0)),
2975 Ok(Ast::Repetition(ast::Repetition {
2977 op: ast::RepetitionOp {
2979 kind: ast::RepetitionKind::ZeroOrOne,
2982 ast: Box::new(lit('a', 0)),
2987 Ok(Ast::Repetition(ast::Repetition {
2989 op: ast::RepetitionOp {
2991 kind: ast::RepetitionKind::ZeroOrOne,
2994 ast: Box::new(lit('a', 0)),
3002 Ast::Repetition(ast::Repetition {
3004 op: ast::RepetitionOp {
3006 kind: ast::RepetitionKind::ZeroOrOne,
3009 ast: Box::new(lit('a', 0)),
3020 Ast::Repetition(ast::Repetition {
3022 op: ast::RepetitionOp {
3024 kind: ast::RepetitionKind::ZeroOrOne,
3027 ast: Box::new(lit('a', 0)),
3039 Ast::Repetition(ast::Repetition {
3041 op: ast::RepetitionOp {
3043 kind: ast::RepetitionKind::ZeroOrOne,
3046 ast: Box::new(lit('b', 1)),
3053 Ok(Ast::Repetition(ast::Repetition {
3055 op: ast::RepetitionOp {
3057 kind: ast::RepetitionKind::ZeroOrOne,
3060 ast: Box::new(group(
3073 Ast::Repetition(ast::Repetition {
3075 op: ast::RepetitionOp {
3077 kind: ast::RepetitionKind::ZeroOrOne,
3080 ast: Box::new(lit('a', 1)),
3090 kind: ast::ErrorKind::RepetitionMissing,
3097 kind: ast::ErrorKind::RepetitionMissing,
3104 kind: ast::ErrorKind::RepetitionMissing,
3111 kind: ast::ErrorKind::RepetitionMissing,
3118 kind: ast::ErrorKind::RepetitionMissing,
3125 kind: ast::ErrorKind::RepetitionMissing,
3132 kind: ast::ErrorKind::RepetitionMissing,
3139 kind: ast::ErrorKind::RepetitionMissing,
3146 kind: ast::ErrorKind::RepetitionMissing,
3153 kind: ast::ErrorKind::RepetitionMissing,
3162 Ok(Ast::Repetition(ast::Repetition {
3164 op: ast::RepetitionOp {
3166 kind: ast::RepetitionKind::Range(
3167 ast::RepetitionRange::Exactly(5)
3171 ast: Box::new(lit('a', 0)),
3176 Ok(Ast::Repetition(ast::Repetition {
3178 op: ast::RepetitionOp {
3180 kind: ast::RepetitionKind::Range(
3181 ast::RepetitionRange::AtLeast(5)
3185 ast: Box::new(lit('a', 0)),
3190 Ok(Ast::Repetition(ast::Repetition {
3192 op: ast::RepetitionOp {
3194 kind: ast::RepetitionKind::Range(
3195 ast::RepetitionRange::Bounded(5, 9)
3199 ast: Box::new(lit('a', 0)),
3204 Ok(Ast::Repetition(ast::Repetition {
3206 op: ast::RepetitionOp {
3208 kind: ast::RepetitionKind::Range(
3209 ast::RepetitionRange::Exactly(5)
3213 ast: Box::new(lit('a', 0)),
3222 Ast::Repetition(ast::Repetition {
3224 op: ast::RepetitionOp {
3226 kind: ast::RepetitionKind::Range(
3227 ast::RepetitionRange::Exactly(5)
3231 ast: Box::new(lit('b', 1)),
3242 Ast::Repetition(ast::Repetition {
3244 op: ast::RepetitionOp {
3246 kind: ast::RepetitionKind::Range(
3247 ast::RepetitionRange::Exactly(5)
3251 ast: Box::new(lit('b', 1)),
3260 Ok(Ast::Repetition(ast::Repetition {
3262 op: ast::RepetitionOp {
3264 kind: ast::RepetitionKind::Range(
3265 ast::RepetitionRange::Exactly(5)
3269 ast: Box::new(lit('a', 0)),
3274 Ok(Ast::Repetition(ast::Repetition {
3276 op: ast::RepetitionOp {
3278 kind: ast::RepetitionKind::Range(
3279 ast::RepetitionRange::Bounded(5, 9)
3283 ast: Box::new(lit('a', 0)),
3288 Ok(Ast::Repetition(ast::Repetition {
3290 op: ast::RepetitionOp {
3292 kind: ast::RepetitionKind::Range(
3293 ast::RepetitionRange::Bounded(5, 9)
3297 ast: Box::new(lit('a', 0)),
3305 kind: ast::ErrorKind::RepetitionMissing,
3312 kind: ast::ErrorKind::RepetitionMissing,
3319 kind: ast::ErrorKind::RepetitionCountDecimalEmpty,
3326 kind: ast::ErrorKind::RepetitionCountDecimalEmpty,
3333 kind: ast::ErrorKind::RepetitionCountUnclosed,
3340 kind: ast::ErrorKind::RepetitionCountDecimalEmpty,
3347 kind: ast::ErrorKind::RepetitionCountDecimalEmpty,
3354 kind: ast::ErrorKind::DecimalInvalid,
3361 kind: ast::ErrorKind::RepetitionCountUnclosed,
3368 kind: ast::ErrorKind::RepetitionCountDecimalEmpty,
3375 kind: ast::ErrorKind::DecimalInvalid,
3382 kind: ast::ErrorKind::RepetitionCountUnclosed,
3389 kind: ast::ErrorKind::RepetitionCountUnclosed,
3396 kind: ast::ErrorKind::RepetitionCountInvalid,
3403 kind: ast::ErrorKind::RepetitionMissing,
3410 kind: ast::ErrorKind::RepetitionMissing,
3419 Ok(Ast::Alternation(ast::Alternation {
3429 Ast::Alternation(ast::Alternation {
3438 Ok(Ast::Alternation(ast::Alternation {
3445 Ok(Ast::Alternation(ast::Alternation {
3459 Ast::Alternation(ast::Alternation {
3563 kind: ast::ErrorKind::GroupUnopened,
3570 kind: ast::ErrorKind::GroupUnclosed,
3581 kind: ast::ErrorKind::UnsupportedLookAround,
3588 kind: ast::ErrorKind::UnsupportedLookAround,
3595 kind: ast::ErrorKind::UnsupportedLookAround,
3602 kind: ast::ErrorKind::UnsupportedLookAround,
3611 Ok(Ast::Flags(ast::SetFlags {
3613 flags: ast::Flags {
3615 items: vec![ast::FlagsItem {
3617 kind: ast::FlagsItemKind::Flag(
3618 ast::Flag::CaseInsensitive
3626 Ok(Ast::Flags(ast::SetFlags {
3628 flags: ast::Flags {
3631 ast::FlagsItem {
3633 kind: ast::FlagsItemKind::Flag(
3634 ast::Flag::CaseInsensitive
3637 ast::FlagsItem {
3639 kind: ast::FlagsItemKind::Flag(
3640 ast::Flag::SwapGreed
3649 Ok(Ast::Flags(ast::SetFlags {
3651 flags: ast::Flags {
3654 ast::FlagsItem {
3656 kind: ast::FlagsItemKind::Flag(
3657 ast::Flag::CaseInsensitive
3660 ast::FlagsItem {
3662 kind: ast::FlagsItemKind::Negation,
3664 ast::FlagsItem {
3666 kind: ast::FlagsItemKind::Flag(
3667 ast::Flag::SwapGreed
3677 Ok(Ast::Group(ast::Group {
3679 kind: ast::GroupKind::CaptureIndex(1),
3680 ast: Box::new(Ast::Empty(span(1..1))),
3685 Ok(Ast::Group(ast::Group {
3687 kind: ast::GroupKind::CaptureIndex(1),
3688 ast: Box::new(lit('a', 1)),
3693 Ok(Ast::Group(ast::Group {
3695 kind: ast::GroupKind::CaptureIndex(1),
3696 ast: Box::new(Ast::Group(ast::Group {
3698 kind: ast::GroupKind::CaptureIndex(2),
3699 ast: Box::new(Ast::Empty(span(2..2))),
3706 Ok(Ast::Group(ast::Group {
3708 kind: ast::GroupKind::NonCapturing(ast::Flags {
3712 ast: Box::new(lit('a', 3)),
3718 Ok(Ast::Group(ast::Group {
3720 kind: ast::GroupKind::NonCapturing(ast::Flags {
3722 items: vec![ast::FlagsItem {
3724 kind: ast::FlagsItemKind::Flag(
3725 ast::Flag::CaseInsensitive
3729 ast: Box::new(lit('a', 4)),
3734 Ok(Ast::Group(ast::Group {
3736 kind: ast::GroupKind::NonCapturing(ast::Flags {
3739 ast::FlagsItem {
3741 kind: ast::FlagsItemKind::Flag(
3742 ast::Flag::CaseInsensitive
3745 ast::FlagsItem {
3747 kind: ast::FlagsItemKind::Negation,
3749 ast::FlagsItem {
3751 kind: ast::FlagsItemKind::Flag(
3752 ast::Flag::SwapGreed
3757 ast: Box::new(lit('a', 6)),
3765 kind: ast::ErrorKind::GroupUnclosed,
3772 kind: ast::ErrorKind::GroupUnclosed,
3779 kind: ast::ErrorKind::FlagUnrecognized,
3786 kind: ast::ErrorKind::GroupNameUnexpectedEof,
3793 kind: ast::ErrorKind::GroupUnclosed,
3800 kind: ast::ErrorKind::GroupUnclosed,
3807 kind: ast::ErrorKind::GroupUnopened,
3814 kind: ast::ErrorKind::GroupUnopened,
3823 Ok(Ast::Group(ast::Group {
3825 kind: ast::GroupKind::CaptureName(ast::CaptureName {
3830 ast: Box::new(lit('z', 6)),
3835 Ok(Ast::Group(ast::Group {
3837 kind: ast::GroupKind::CaptureName(ast::CaptureName {
3842 ast: Box::new(lit('z', 8)),
3848 Ok(Ast::Group(ast::Group {
3850 kind: ast::GroupKind::CaptureName(ast::CaptureName {
3855 ast: Box::new(lit('z', 8)),
3861 Ok(Ast::Group(ast::Group {
3863 kind: ast::GroupKind::CaptureName(ast::CaptureName {
3868 ast: Box::new(lit('z', 8)),
3874 Ok(Ast::Group(ast::Group {
3876 kind: ast::GroupKind::CaptureName(ast::CaptureName {
3881 ast: Box::new(lit('z', 9)),
3889 kind: ast::ErrorKind::GroupNameUnexpectedEof,
3896 kind: ast::ErrorKind::GroupNameEmpty,
3903 kind: ast::ErrorKind::GroupNameUnexpectedEof,
3910 kind: ast::ErrorKind::GroupNameUnexpectedEof,
3917 kind: ast::ErrorKind::GroupNameInvalid,
3924 kind: ast::ErrorKind::GroupNameInvalid,
3931 kind: ast::ErrorKind::GroupNameInvalid,
3938 kind: ast::ErrorKind::GroupNameDuplicate {
3949 Ok(ast::Flags {
3951 items: vec![ast::FlagsItem {
3953 kind: ast::FlagsItemKind::Flag(ast::Flag::CaseInsensitive),
3959 Ok(ast::Flags {
3961 items: vec![ast::FlagsItem {
3963 kind: ast::FlagsItemKind::Flag(ast::Flag::CaseInsensitive),
3970 Ok(ast::Flags {
3973 ast::FlagsItem {
3975 kind: ast::FlagsItemKind::Flag(
3976 ast::Flag::CaseInsensitive
3979 ast::FlagsItem {
3981 kind: ast::FlagsItemKind::Flag(
3982 ast::Flag::DotMatchesNewLine
3985 ast::FlagsItem {
3987 kind: ast::FlagsItemKind::Flag(ast::Flag::SwapGreed),
3995 Ok(ast::Flags {
3998 ast::FlagsItem {
4000 kind: ast::FlagsItemKind::Negation,
4002 ast::FlagsItem {
4004 kind: ast::FlagsItemKind::Flag(
4005 ast::Flag::CaseInsensitive
4008 ast::FlagsItem {
4010 kind: ast::FlagsItemKind::Flag(
4011 ast::Flag::DotMatchesNewLine
4014 ast::FlagsItem {
4016 kind: ast::FlagsItemKind::Flag(ast::Flag::SwapGreed),
4023 Ok(ast::Flags {
4026 ast::FlagsItem {
4028 kind: ast::FlagsItemKind::Flag(
4029 ast::Flag::CaseInsensitive
4032 ast::FlagsItem {
4034 kind: ast::FlagsItemKind::Negation,
4036 ast::FlagsItem {
4038 kind: ast::FlagsItemKind::Flag(
4039 ast::Flag::DotMatchesNewLine
4042 ast::FlagsItem {
4044 kind: ast::FlagsItemKind::Flag(ast::Flag::SwapGreed),
4054 kind: ast::ErrorKind::FlagUnexpectedEof,
4061 kind: ast::ErrorKind::FlagUnrecognized,
4068 kind: ast::ErrorKind::FlagDuplicate { original: span(0..1) },
4075 kind: ast::ErrorKind::FlagRepeatedNegation {
4084 kind: ast::ErrorKind::FlagDanglingNegation,
4091 kind: ast::ErrorKind::FlagDanglingNegation,
4098 kind: ast::ErrorKind::FlagDanglingNegation,
4105 assert_eq!(parser("i").parse_flag(), Ok(ast::Flag::CaseInsensitive));
4106 assert_eq!(parser("m").parse_flag(), Ok(ast::Flag::MultiLine));
4107 assert_eq!(parser("s").parse_flag(), Ok(ast::Flag::DotMatchesNewLine));
4108 assert_eq!(parser("U").parse_flag(), Ok(ast::Flag::SwapGreed));
4109 assert_eq!(parser("u").parse_flag(), Ok(ast::Flag::Unicode));
4110 assert_eq!(parser("x").parse_flag(), Ok(ast::Flag::IgnoreWhitespace));
4116 kind: ast::ErrorKind::FlagUnrecognized,
4123 kind: ast::ErrorKind::FlagUnrecognized,
4136 Ok(Primitive::Assertion(ast::Assertion {
4138 kind: ast::AssertionKind::StartLine,
4143 Ok(Primitive::Assertion(ast::Assertion {
4145 kind: ast::AssertionKind::EndLine,
4151 Ok(Primitive::Literal(ast::Literal {
4153 kind: ast::LiteralKind::Verbatim,
4159 Ok(Primitive::Literal(ast::Literal {
4161 kind: ast::LiteralKind::Verbatim,
4167 Ok(Primitive::Literal(ast::Literal {
4169 kind: ast::LiteralKind::Verbatim,
4179 Ok(Primitive::Literal(ast::Literal {
4181 kind: ast::LiteralKind::Punctuation,
4186 (r"\a", '\x07', ast::SpecialLiteralKind::Bell),
4187 (r"\f", '\x0C', ast::SpecialLiteralKind::FormFeed),
4188 (r"\t", '\t', ast::SpecialLiteralKind::Tab),
4189 (r"\n", '\n', ast::SpecialLiteralKind::LineFeed),
4190 (r"\r", '\r', ast::SpecialLiteralKind::CarriageReturn),
4191 (r"\v", '\x0B', ast::SpecialLiteralKind::VerticalTab),
4196 Ok(Primitive::Literal(ast::Literal {
4198 kind: ast::LiteralKind::Special(kind.clone()),
4205 Ok(Primitive::Assertion(ast::Assertion {
4207 kind: ast::AssertionKind::StartText,
4212 Ok(Primitive::Assertion(ast::Assertion {
4214 kind: ast::AssertionKind::EndText,
4219 Ok(Primitive::Assertion(ast::Assertion {
4221 kind: ast::AssertionKind::WordBoundary,
4226 Ok(Primitive::Assertion(ast::Assertion {
4228 kind: ast::AssertionKind::NotWordBoundary,
4236 kind: ast::ErrorKind::EscapeUnexpectedEof,
4243 kind: ast::ErrorKind::EscapeUnrecognized,
4254 kind: ast::ErrorKind::UnsupportedBackreference,
4261 kind: ast::ErrorKind::UnsupportedBackreference,
4272 Ok(Primitive::Literal(ast::Literal {
4274 kind: ast::LiteralKind::Octal,
4281 Ok(Primitive::Literal(ast::Literal {
4283 kind: ast::LiteralKind::Octal,
4289 Ok(Primitive::Literal(ast::Literal {
4291 kind: ast::LiteralKind::Octal,
4297 Ok(Ast::Concat(ast::Concat {
4300 Ast::Literal(ast::Literal {
4302 kind: ast::LiteralKind::Octal,
4305 Ast::Literal(ast::Literal {
4307 kind: ast::LiteralKind::Verbatim,
4315 Ok(Ast::Concat(ast::Concat {
4318 Ast::Literal(ast::Literal {
4320 kind: ast::LiteralKind::Octal,
4323 Ast::Literal(ast::Literal {
4325 kind: ast::LiteralKind::Verbatim,
4336 kind: ast::ErrorKind::EscapeUnrecognized,
4347 Ok(Primitive::Literal(ast::Literal {
4349 kind: ast::LiteralKind::HexFixed(ast::HexLiteralKind::X),
4359 kind: ast::ErrorKind::EscapeUnexpectedEof,
4366 kind: ast::ErrorKind::EscapeHexInvalidDigit,
4373 kind: ast::ErrorKind::EscapeHexInvalidDigit,
4388 Ok(Primitive::Literal(ast::Literal {
4390 kind: ast::LiteralKind::HexFixed(
4391 ast::HexLiteralKind::UnicodeShort
4402 kind: ast::ErrorKind::EscapeUnexpectedEof,
4409 kind: ast::ErrorKind::EscapeHexInvalidDigit,
4416 kind: ast::ErrorKind::EscapeHexInvalidDigit,
4423 kind: ast::ErrorKind::EscapeHexInvalidDigit,
4430 kind: ast::ErrorKind::EscapeHexInvalidDigit,
4437 kind: ast::ErrorKind::EscapeHexInvalid,
4452 Ok(Primitive::Literal(ast::Literal {
4454 kind: ast::LiteralKind::HexFixed(
4455 ast::HexLiteralKind::UnicodeLong
4466 kind: ast::ErrorKind::EscapeUnexpectedEof,
4473 kind: ast::ErrorKind::EscapeHexInvalidDigit,
4480 kind: ast::ErrorKind::EscapeHexInvalidDigit,
4487 kind: ast::ErrorKind::EscapeHexInvalidDigit,
4494 kind: ast::ErrorKind::EscapeHexInvalidDigit,
4501 kind: ast::ErrorKind::EscapeHexInvalidDigit,
4508 kind: ast::ErrorKind::EscapeHexInvalidDigit,
4515 kind: ast::ErrorKind::EscapeHexInvalidDigit,
4522 kind: ast::ErrorKind::EscapeHexInvalidDigit,
4531 Ok(Primitive::Literal(ast::Literal {
4533 kind: ast::LiteralKind::HexBrace(
4534 ast::HexLiteralKind::UnicodeShort
4541 Ok(Primitive::Literal(ast::Literal {
4543 kind: ast::LiteralKind::HexBrace(
4544 ast::HexLiteralKind::UnicodeLong
4551 Ok(Primitive::Literal(ast::Literal {
4553 kind: ast::LiteralKind::HexBrace(ast::HexLiteralKind::X),
4559 Ok(Primitive::Literal(ast::Literal {
4561 kind: ast::LiteralKind::HexBrace(ast::HexLiteralKind::X),
4567 Ok(Primitive::Literal(ast::Literal {
4569 kind: ast::LiteralKind::HexBrace(ast::HexLiteralKind::X),
4578 kind: ast::ErrorKind::EscapeUnexpectedEof,
4585 kind: ast::ErrorKind::EscapeUnexpectedEof,
4592 kind: ast::ErrorKind::EscapeUnexpectedEof,
4599 kind: ast::ErrorKind::EscapeHexEmpty,
4606 kind: ast::ErrorKind::EscapeHexInvalidDigit,
4613 kind: ast::ErrorKind::EscapeHexInvalid,
4620 kind: ast::ErrorKind::EscapeHexInvalid,
4627 kind: ast::ErrorKind::EscapeHexInvalid,
4640 TestError { span: span(0..0), kind: ast::ErrorKind::DecimalEmpty }
4644 TestError { span: span(0..0), kind: ast::ErrorKind::DecimalEmpty }
4650 kind: ast::ErrorKind::DecimalInvalid,
4657 fn union(span: Span, items: Vec<ast::ClassSetItem>) -> ast::ClassSet {
4658 ast::ClassSet::union(ast::ClassSetUnion { span, items })
4663 lhs: ast::ClassSet,
4664 rhs: ast::ClassSet,
4665 ) -> ast::ClassSet {
4666 ast::ClassSet::BinaryOp(ast::ClassSetBinaryOp {
4668 kind: ast::ClassSetBinaryOpKind::Intersection,
4676 lhs: ast::ClassSet,
4677 rhs: ast::ClassSet,
4678 ) -> ast::ClassSet {
4679 ast::ClassSet::BinaryOp(ast::ClassSetBinaryOp {
4681 kind: ast::ClassSetBinaryOpKind::Difference,
4689 lhs: ast::ClassSet,
4690 rhs: ast::ClassSet,
4691 ) -> ast::ClassSet {
4692 ast::ClassSet::BinaryOp(ast::ClassSetBinaryOp {
4694 kind: ast::ClassSetBinaryOpKind::SymmetricDifference,
4700 fn itemset(item: ast::ClassSetItem) -> ast::ClassSet {
4701 ast::ClassSet::Item(item)
4704 fn item_ascii(cls: ast::ClassAscii) -> ast::ClassSetItem {
4705 ast::ClassSetItem::Ascii(cls)
4708 fn item_unicode(cls: ast::ClassUnicode) -> ast::ClassSetItem {
4709 ast::ClassSetItem::Unicode(cls)
4712 fn item_perl(cls: ast::ClassPerl) -> ast::ClassSetItem {
4713 ast::ClassSetItem::Perl(cls)
4716 fn item_bracket(cls: ast::ClassBracketed) -> ast::ClassSetItem {
4717 ast::ClassSetItem::Bracketed(Box::new(cls))
4720 fn lit(span: Span, c: char) -> ast::ClassSetItem {
4721 ast::ClassSetItem::Literal(ast::Literal {
4723 kind: ast::LiteralKind::Verbatim,
4728 fn empty(span: Span) -> ast::ClassSetItem {
4729 ast::ClassSetItem::Empty(span)
4732 fn range(span: Span, start: char, end: char) -> ast::ClassSetItem {
4743 ast::ClassSetItem::Range(ast::ClassSetRange {
4745 start: ast::Literal {
4747 kind: ast::LiteralKind::Verbatim,
4750 end: ast::Literal {
4752 kind: ast::LiteralKind::Verbatim,
4758 fn alnum(span: Span, negated: bool) -> ast::ClassAscii {
4759 ast::ClassAscii { span, kind: ast::ClassAsciiKind::Alnum, negated }
4762 fn lower(span: Span, negated: bool) -> ast::ClassAscii {
4763 ast::ClassAscii { span, kind: ast::ClassAsciiKind::Lower, negated }
4768 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
4776 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
4779 kind: itemset(item_bracket(ast::ClassBracketed {
4788 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
4800 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
4812 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
4825 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
4833 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
4840 ast::ClassSetItem::Literal(ast::Literal {
4842 kind: ast::LiteralKind::Punctuation,
4851 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
4858 ast::ClassSetItem::Literal(ast::Literal {
4860 kind: ast::LiteralKind::Punctuation,
4870 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
4881 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
4892 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
4903 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
4906 kind: itemset(item_unicode(ast::ClassUnicode {
4909 kind: ast::ClassUnicodeKind::OneLetter('L'),
4915 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
4918 kind: itemset(item_perl(ast::ClassPerl {
4920 kind: ast::ClassPerlKind::Word,
4927 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
4934 item_perl(ast::ClassPerl {
4936 kind: ast::ClassPerlKind::Word,
4947 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
4955 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
4969 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
4974 itemset(item_perl(ast::ClassPerl {
4976 kind: ast::ClassPerlKind::Word,
4991 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
5003 itemset(item_perl(ast::ClassPerl {
5005 kind: ast::ClassPerlKind::Word,
5013 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
5029 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
5045 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
5050 itemset(ast::ClassSetItem::Literal(ast::Literal {
5052 kind: ast::LiteralKind::Punctuation,
5061 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
5066 itemset(ast::ClassSetItem::Literal(ast::Literal {
5068 kind: ast::LiteralKind::Punctuation,
5077 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
5095 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
5098 kind: itemset(ast::ClassSetItem::Range(ast::ClassSetRange {
5100 start: ast::Literal {
5102 kind: ast::LiteralKind::Verbatim,
5105 end: ast::Literal {
5107 kind: ast::LiteralKind::Verbatim,
5116 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
5124 Ok(Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
5131 ast::ClassSetItem::Literal(ast::Literal {
5133 kind: ast::LiteralKind::Punctuation,
5145 Ast::Class(ast::Class::Bracketed(ast::ClassBracketed {
5148 kind: itemset(ast::ClassSetItem::Literal(
5149 ast::Literal {
5151 kind: ast::LiteralKind::Punctuation,
5156 Ast::Literal(ast::Literal {
5158 kind: ast::LiteralKind::Verbatim,
5169 kind: ast::ErrorKind::ClassUnclosed,
5176 kind: ast::ErrorKind::ClassUnclosed,
5183 kind: ast::ErrorKind::ClassUnclosed,
5190 kind: ast::ErrorKind::ClassUnclosed,
5197 kind: ast::ErrorKind::ClassEscapeInvalid,
5204 kind: ast::ErrorKind::ClassRangeLiteral,
5211 kind: ast::ErrorKind::ClassRangeLiteral,
5218 kind: ast::ErrorKind::ClassRangeInvalid,
5226 kind: ast::ErrorKind::ClassUnclosed,
5233 kind: ast::ErrorKind::ClassUnclosed,
5241 let set = ast::ClassBracketed {
5244 kind: ast::ClassSet::union(ast::ClassSetUnion {
5249 let union = ast::ClassSetUnion { span: span(1..1), items: vec![] };
5255 let set = ast::ClassBracketed {
5258 kind: ast::ClassSet::union(ast::ClassSetUnion {
5264 ast::ClassSetUnion { span: span(4..4), items: vec![] };
5269 let set = ast::ClassBracketed {
5272 kind: ast::ClassSet::union(ast::ClassSetUnion {
5277 let union = ast::ClassSetUnion { span: span(2..2), items: vec![] };
5283 let set = ast::ClassBracketed {
5286 kind: ast::ClassSet::union(ast::ClassSetUnion {
5292 ast::ClassSetUnion { span: span(4..4), items: vec![] };
5297 let set = ast::ClassBracketed {
5300 kind: ast::ClassSet::union(ast::ClassSetUnion {
5305 let union = ast::ClassSetUnion {
5307 items: vec![ast::ClassSetItem::Literal(ast::Literal {
5309 kind: ast::LiteralKind::Verbatim,
5318 let set = ast::ClassBracketed {
5321 kind: ast::ClassSet::union(ast::ClassSetUnion {
5326 let union = ast::ClassSetUnion {
5328 items: vec![ast::ClassSetItem::Literal(ast::Literal {
5330 kind: ast::LiteralKind::Verbatim,
5338 let set = ast::ClassBracketed {
5341 kind: ast::ClassSet::union(ast::ClassSetUnion {
5346 let union = ast::ClassSetUnion {
5348 items: vec![ast::ClassSetItem::Literal(ast::Literal {
5350 kind: ast::LiteralKind::Verbatim,
5357 let set = ast::ClassBracketed {
5360 kind: ast::ClassSet::union(ast::ClassSetUnion {
5365 let union = ast::ClassSetUnion {
5368 ast::ClassSetItem::Literal(ast::Literal {
5370 kind: ast::LiteralKind::Verbatim,
5373 ast::ClassSetItem::Literal(ast::Literal {
5375 kind: ast::LiteralKind::Verbatim,
5383 let set = ast::ClassBracketed {
5386 kind: ast::ClassSet::union(ast::ClassSetUnion {
5391 let union = ast::ClassSetUnion {
5393 items: vec![ast::ClassSetItem::Literal(ast::Literal {
5395 kind: ast::LiteralKind::Verbatim,
5404 let set = ast::ClassBracketed {
5407 kind: ast::ClassSet::union(ast::ClassSetUnion {
5412 let union = ast::ClassSetUnion {
5414 items: vec![ast::ClassSetItem::Literal(ast::Literal {
5416 kind: ast::LiteralKind::Verbatim,
5424 let set = ast::ClassBracketed {
5427 kind: ast::ClassSet::union(ast::ClassSetUnion {
5432 let union = ast::ClassSetUnion {
5434 items: vec![ast::ClassSetItem::Literal(ast::Literal {
5436 kind: ast::LiteralKind::Verbatim,
5443 let set = ast::ClassBracketed {
5446 kind: ast::ClassSet::union(ast::ClassSetUnion {
5451 let union = ast::ClassSetUnion {
5453 items: vec![ast::ClassSetItem::Literal(ast::Literal {
5455 kind: ast::LiteralKind::Verbatim,
5466 kind: ast::ErrorKind::ClassUnclosed,
5475 kind: ast::ErrorKind::ClassUnclosed,
5482 kind: ast::ErrorKind::ClassUnclosed,
5489 kind: ast::ErrorKind::ClassUnclosed,
5496 kind: ast::ErrorKind::ClassUnclosed,
5503 kind: ast::ErrorKind::ClassUnclosed,
5512 kind: ast::ErrorKind::ClassUnclosed,
5521 Some(ast::ClassAscii {
5523 kind: ast::ClassAsciiKind::Alnum,
5529 Some(ast::ClassAscii {
5531 kind: ast::ClassAsciiKind::Alnum,
5537 Some(ast::ClassAscii {
5539 kind: ast::ClassAsciiKind::Alnum,
5573 Ok(Primitive::Unicode(ast::ClassUnicode {
5576 kind: ast::ClassUnicodeKind::OneLetter('N'),
5581 Ok(Primitive::Unicode(ast::ClassUnicode {
5584 kind: ast::ClassUnicodeKind::OneLetter('N'),
5589 Ok(Primitive::Unicode(ast::ClassUnicode {
5592 kind: ast::ClassUnicodeKind::Named(s("N")),
5597 Ok(Primitive::Unicode(ast::ClassUnicode {
5600 kind: ast::ClassUnicodeKind::Named(s("N")),
5605 Ok(Primitive::Unicode(ast::ClassUnicode {
5608 kind: ast::ClassUnicodeKind::Named(s("Greek")),
5614 Ok(Primitive::Unicode(ast::ClassUnicode {
5617 kind: ast::ClassUnicodeKind::NamedValue {
5618 op: ast::ClassUnicodeOpKind::Colon,
5626 Ok(Primitive::Unicode(ast::ClassUnicode {
5629 kind: ast::ClassUnicodeKind::NamedValue {
5630 op: ast::ClassUnicodeOpKind::Equal,
5638 Ok(Primitive::Unicode(ast::ClassUnicode {
5641 kind: ast::ClassUnicodeKind::NamedValue {
5642 op: ast::ClassUnicodeOpKind::NotEqual,
5651 Ok(Primitive::Unicode(ast::ClassUnicode {
5654 kind: ast::ClassUnicodeKind::NamedValue {
5655 op: ast::ClassUnicodeOpKind::Colon,
5663 Ok(Primitive::Unicode(ast::ClassUnicode {
5666 kind: ast::ClassUnicodeKind::NamedValue {
5667 op: ast::ClassUnicodeOpKind::Equal,
5675 Ok(Primitive::Unicode(ast::ClassUnicode {
5678 kind: ast::ClassUnicodeKind::NamedValue {
5679 op: ast::ClassUnicodeOpKind::NotEqual,
5690 kind: ast::ErrorKind::EscapeUnexpectedEof,
5697 kind: ast::ErrorKind::EscapeUnexpectedEof,
5704 kind: ast::ErrorKind::EscapeUnexpectedEof,
5711 kind: ast::ErrorKind::EscapeUnexpectedEof,
5717 Ok(Ast::Concat(ast::Concat {
5720 Ast::Class(ast::Class::Unicode(ast::ClassUnicode {
5723 kind: ast::ClassUnicodeKind::OneLetter('N'),
5725 Ast::Literal(ast::Literal {
5727 kind: ast::LiteralKind::Verbatim,
5735 Ok(Ast::Concat(ast::Concat {
5738 Ast::Class(ast::Class::Unicode(ast::ClassUnicode {
5741 kind: ast::ClassUnicodeKind::Named(s("Greek")),
5743 Ast::Literal(ast::Literal {
5745 kind: ast::LiteralKind::Verbatim,
5755 kind: ast::ErrorKind::UnicodeClassInvalid,
5762 kind: ast::ErrorKind::UnicodeClassInvalid,
5771 Ok(Primitive::Perl(ast::ClassPerl {
5773 kind: ast::ClassPerlKind::Digit,
5779 Ok(Primitive::Perl(ast::ClassPerl {
5781 kind: ast::ClassPerlKind::Digit,
5787 Ok(Primitive::Perl(ast::ClassPerl {
5789 kind: ast::ClassPerlKind::Space,
5795 Ok(Primitive::Perl(ast::ClassPerl {
5797 kind: ast::ClassPerlKind::Space,
5803 Ok(Primitive::Perl(ast::ClassPerl {
5805 kind: ast::ClassPerlKind::Word,
5811 Ok(Primitive::Perl(ast::ClassPerl {
5813 kind: ast::ClassPerlKind::Word,
5820 Ok(Ast::Class(ast::Class::Perl(ast::ClassPerl {
5822 kind: ast::ClassPerlKind::Digit,
5828 Ok(Ast::Concat(ast::Concat {
5831 Ast::Class(ast::Class::Perl(ast::ClassPerl {
5833 kind: ast::ClassPerlKind::Digit,
5836 Ast::Literal(ast::Literal {
5838 kind: ast::LiteralKind::Verbatim,