@@ -20,6 +20,7 @@ mod visitor;
20
20
/// valid Unicode property name. That particular error is reported when
21
21
/// translating an AST to the high-level intermediate representation (`HIR`).
22
22
#[ derive( Clone , Debug , Eq , PartialEq ) ]
23
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
23
24
pub struct Error {
24
25
/// The kind of error.
25
26
kind : ErrorKind ,
@@ -70,6 +71,7 @@ impl Error {
70
71
/// new variant is not considered a breaking change.
71
72
#[ non_exhaustive]
72
73
#[ derive( Clone , Debug , Eq , PartialEq ) ]
74
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
73
75
pub enum ErrorKind {
74
76
/// The capturing group limit was exceeded.
75
77
///
@@ -278,6 +280,7 @@ impl core::fmt::Display for ErrorKind {
278
280
/// All span positions are absolute byte offsets that can be used on the
279
281
/// original regular expression that was parsed.
280
282
#[ derive( Clone , Copy , Eq , PartialEq ) ]
283
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
281
284
pub struct Span {
282
285
/// The start byte offset.
283
286
pub start : Position ,
@@ -308,6 +311,7 @@ impl PartialOrd for Span {
308
311
/// A position encodes one half of a span, and include the byte offset, line
309
312
/// number and column number.
310
313
#[ derive( Clone , Copy , Eq , PartialEq ) ]
314
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
311
315
pub struct Position {
312
316
/// The absolute offset of this position, starting at `0` from the
313
317
/// beginning of the regular expression pattern string.
@@ -396,6 +400,7 @@ impl Position {
396
400
/// comment contains a span of precisely where it occurred in the original
397
401
/// regular expression.
398
402
#[ derive( Clone , Debug , Eq , PartialEq ) ]
403
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
399
404
pub struct WithComments {
400
405
/// The actual ast.
401
406
pub ast : Ast ,
@@ -408,6 +413,7 @@ pub struct WithComments {
408
413
/// A regular expression can only contain comments when the `x` flag is
409
414
/// enabled.
410
415
#[ derive( Clone , Debug , Eq , PartialEq ) ]
416
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
411
417
pub struct Comment {
412
418
/// The span of this comment, including the beginning `#` and ending `\n`.
413
419
pub span : Span ,
@@ -424,6 +430,7 @@ pub struct Comment {
424
430
/// This type defines its own destructor that uses constant stack space and
425
431
/// heap space proportional to the size of the `Ast`.
426
432
#[ derive( Clone , Debug , Eq , PartialEq ) ]
433
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
427
434
pub enum Ast {
428
435
/// An empty regex that matches everything.
429
436
Empty ( Span ) ,
@@ -508,6 +515,7 @@ impl core::fmt::Display for Ast {
508
515
509
516
/// An alternation of regular expressions.
510
517
#[ derive( Clone , Debug , Eq , PartialEq ) ]
518
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
511
519
pub struct Alternation {
512
520
/// The span of this alternation.
513
521
pub span : Span ,
@@ -532,6 +540,7 @@ impl Alternation {
532
540
533
541
/// A concatenation of regular expressions.
534
542
#[ derive( Clone , Debug , Eq , PartialEq ) ]
543
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
535
544
pub struct Concat {
536
545
/// The span of this concatenation.
537
546
pub span : Span ,
@@ -560,6 +569,7 @@ impl Concat {
560
569
/// represented in their literal form, e.g., `a` or in their escaped form,
561
570
/// e.g., `\x61`.
562
571
#[ derive( Clone , Debug , Eq , PartialEq ) ]
572
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
563
573
pub struct Literal {
564
574
/// The span of this literal.
565
575
pub span : Span ,
@@ -584,6 +594,7 @@ impl Literal {
584
594
585
595
/// The kind of a single literal expression.
586
596
#[ derive( Clone , Debug , Eq , PartialEq ) ]
597
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
587
598
pub enum LiteralKind {
588
599
/// The literal is written verbatim, e.g., `a` or `☃`.
589
600
Verbatim ,
@@ -613,6 +624,7 @@ pub enum LiteralKind {
613
624
/// A special literal is a special escape sequence recognized by the regex
614
625
/// parser, e.g., `\f` or `\n`.
615
626
#[ derive( Clone , Debug , Eq , PartialEq ) ]
627
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
616
628
pub enum SpecialLiteralKind {
617
629
/// Bell, spelled `\a` (`\x07`).
618
630
Bell ,
@@ -637,6 +649,7 @@ pub enum SpecialLiteralKind {
637
649
/// differ when used without brackets in the number of hex digits that must
638
650
/// follow.
639
651
#[ derive( Clone , Debug , Eq , PartialEq ) ]
652
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
640
653
pub enum HexLiteralKind {
641
654
/// A `\x` prefix. When used without brackets, this form is limited to
642
655
/// two digits.
@@ -664,6 +677,7 @@ impl HexLiteralKind {
664
677
665
678
/// A single character class expression.
666
679
#[ derive( Clone , Debug , Eq , PartialEq ) ]
680
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
667
681
pub enum Class {
668
682
/// A Unicode character class, e.g., `\pL` or `\p{Greek}`.
669
683
Unicode ( ClassUnicode ) ,
@@ -688,6 +702,7 @@ impl Class {
688
702
689
703
/// A Perl character class.
690
704
#[ derive( Clone , Debug , Eq , PartialEq ) ]
705
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
691
706
pub struct ClassPerl {
692
707
/// The span of this class.
693
708
pub span : Span ,
@@ -700,6 +715,7 @@ pub struct ClassPerl {
700
715
701
716
/// The available Perl character classes.
702
717
#[ derive( Clone , Debug , Eq , PartialEq ) ]
718
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
703
719
pub enum ClassPerlKind {
704
720
/// Decimal numbers.
705
721
Digit ,
@@ -711,6 +727,7 @@ pub enum ClassPerlKind {
711
727
712
728
/// An ASCII character class.
713
729
#[ derive( Clone , Debug , Eq , PartialEq ) ]
730
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
714
731
pub struct ClassAscii {
715
732
/// The span of this class.
716
733
pub span : Span ,
@@ -723,6 +740,7 @@ pub struct ClassAscii {
723
740
724
741
/// The available ASCII character classes.
725
742
#[ derive( Clone , Debug , Eq , PartialEq ) ]
743
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
726
744
pub enum ClassAsciiKind {
727
745
/// `[0-9A-Za-z]`
728
746
Alnum ,
@@ -786,6 +804,7 @@ impl ClassAsciiKind {
786
804
787
805
/// A Unicode character class.
788
806
#[ derive( Clone , Debug , Eq , PartialEq ) ]
807
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
789
808
pub struct ClassUnicode {
790
809
/// The span of this class.
791
810
pub span : Span ,
@@ -821,6 +840,7 @@ impl ClassUnicode {
821
840
822
841
/// The available forms of Unicode character classes.
823
842
#[ derive( Clone , Debug , Eq , PartialEq ) ]
843
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
824
844
pub enum ClassUnicodeKind {
825
845
/// A one letter abbreviated class, e.g., `\pN`.
826
846
OneLetter ( char ) ,
@@ -840,6 +860,7 @@ pub enum ClassUnicodeKind {
840
860
841
861
/// The type of op used in a Unicode character class.
842
862
#[ derive( Clone , Debug , Eq , PartialEq ) ]
863
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
843
864
pub enum ClassUnicodeOpKind {
844
865
/// A property set to a specific value, e.g., `\p{scx=Katakana}`.
845
866
Equal ,
@@ -862,6 +883,7 @@ impl ClassUnicodeOpKind {
862
883
863
884
/// A bracketed character class, e.g., `[a-z0-9]`.
864
885
#[ derive( Clone , Debug , Eq , PartialEq ) ]
886
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
865
887
pub struct ClassBracketed {
866
888
/// The span of this class.
867
889
pub span : Span ,
@@ -880,6 +902,7 @@ pub struct ClassBracketed {
880
902
/// items (literals, ranges, other bracketed classes) or a tree of binary set
881
903
/// operations.
882
904
#[ derive( Clone , Debug , Eq , PartialEq ) ]
905
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
883
906
pub enum ClassSet {
884
907
/// An item, which can be a single literal, range, nested character class
885
908
/// or a union of items.
@@ -913,6 +936,7 @@ impl ClassSet {
913
936
914
937
/// A single component of a character class set.
915
938
#[ derive( Clone , Debug , Eq , PartialEq ) ]
939
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
916
940
pub enum ClassSetItem {
917
941
/// An empty item.
918
942
///
@@ -956,6 +980,7 @@ impl ClassSetItem {
956
980
957
981
/// A single character class range in a set.
958
982
#[ derive( Clone , Debug , Eq , PartialEq ) ]
983
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
959
984
pub struct ClassSetRange {
960
985
/// The span of this range.
961
986
pub span : Span ,
@@ -977,6 +1002,7 @@ impl ClassSetRange {
977
1002
978
1003
/// A union of items inside a character class set.
979
1004
#[ derive( Clone , Debug , Eq , PartialEq ) ]
1005
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
980
1006
pub struct ClassSetUnion {
981
1007
/// The span of the items in this operation. e.g., the `a-z0-9` in
982
1008
/// `[^a-z0-9]`
@@ -1021,6 +1047,7 @@ impl ClassSetUnion {
1021
1047
1022
1048
/// A Unicode character class set operation.
1023
1049
#[ derive( Clone , Debug , Eq , PartialEq ) ]
1050
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
1024
1051
pub struct ClassSetBinaryOp {
1025
1052
/// The span of this operation. e.g., the `a-z--[h-p]` in `[a-z--h-p]`.
1026
1053
pub span : Span ,
@@ -1038,6 +1065,7 @@ pub struct ClassSetBinaryOp {
1038
1065
/// explicit union operator. Concatenation inside a character class corresponds
1039
1066
/// to the union operation.
1040
1067
#[ derive( Clone , Copy , Debug , Eq , PartialEq ) ]
1068
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
1041
1069
pub enum ClassSetBinaryOpKind {
1042
1070
/// The intersection of two sets, e.g., `\pN&&[a-z]`.
1043
1071
Intersection ,
@@ -1051,6 +1079,7 @@ pub enum ClassSetBinaryOpKind {
1051
1079
1052
1080
/// A single zero-width assertion.
1053
1081
#[ derive( Clone , Debug , Eq , PartialEq ) ]
1082
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
1054
1083
pub struct Assertion {
1055
1084
/// The span of this assertion.
1056
1085
pub span : Span ,
@@ -1060,6 +1089,7 @@ pub struct Assertion {
1060
1089
1061
1090
/// An assertion kind.
1062
1091
#[ derive( Clone , Debug , Eq , PartialEq ) ]
1092
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
1063
1093
pub enum AssertionKind {
1064
1094
/// `^`
1065
1095
StartLine ,
@@ -1077,6 +1107,7 @@ pub enum AssertionKind {
1077
1107
1078
1108
/// A repetition operation applied to a regular expression.
1079
1109
#[ derive( Clone , Debug , Eq , PartialEq ) ]
1110
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
1080
1111
pub struct Repetition {
1081
1112
/// The span of this operation.
1082
1113
pub span : Span ,
@@ -1090,6 +1121,7 @@ pub struct Repetition {
1090
1121
1091
1122
/// The repetition operator itself.
1092
1123
#[ derive( Clone , Debug , Eq , PartialEq ) ]
1124
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
1093
1125
pub struct RepetitionOp {
1094
1126
/// The span of this operator. This includes things like `+`, `*?` and
1095
1127
/// `{m,n}`.
@@ -1100,6 +1132,7 @@ pub struct RepetitionOp {
1100
1132
1101
1133
/// The kind of a repetition operator.
1102
1134
#[ derive( Clone , Debug , Eq , PartialEq ) ]
1135
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
1103
1136
pub enum RepetitionKind {
1104
1137
/// `?`
1105
1138
ZeroOrOne ,
@@ -1113,6 +1146,7 @@ pub enum RepetitionKind {
1113
1146
1114
1147
/// A range repetition operator.
1115
1148
#[ derive( Clone , Debug , Eq , PartialEq ) ]
1149
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
1116
1150
pub enum RepetitionRange {
1117
1151
/// `{m}`
1118
1152
Exactly ( u32 ) ,
@@ -1142,6 +1176,7 @@ impl RepetitionRange {
1142
1176
/// contains a sub-expression, e.g., `(a)`, `(?P<name>a)`, `(?:a)` and
1143
1177
/// `(?is:a)`.
1144
1178
#[ derive( Clone , Debug , Eq , PartialEq ) ]
1179
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
1145
1180
pub struct Group {
1146
1181
/// The span of this group.
1147
1182
pub span : Span ,
@@ -1183,6 +1218,7 @@ impl Group {
1183
1218
1184
1219
/// The kind of a group.
1185
1220
#[ derive( Clone , Debug , Eq , PartialEq ) ]
1221
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
1186
1222
pub enum GroupKind {
1187
1223
/// `(a)`
1188
1224
CaptureIndex ( u32 ) ,
@@ -1202,6 +1238,7 @@ pub enum GroupKind {
1202
1238
/// This corresponds to the name itself between the angle brackets in, e.g.,
1203
1239
/// `(?P<foo>expr)`.
1204
1240
#[ derive( Clone , Debug , Eq , PartialEq ) ]
1241
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
1205
1242
pub struct CaptureName {
1206
1243
/// The span of this capture name.
1207
1244
pub span : Span ,
@@ -1213,6 +1250,7 @@ pub struct CaptureName {
1213
1250
1214
1251
/// A group of flags that is not applied to a particular regular expression.
1215
1252
#[ derive( Clone , Debug , Eq , PartialEq ) ]
1253
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
1216
1254
pub struct SetFlags {
1217
1255
/// The span of these flags, including the grouping parentheses.
1218
1256
pub span : Span ,
@@ -1224,6 +1262,7 @@ pub struct SetFlags {
1224
1262
///
1225
1263
/// This corresponds only to the sequence of flags themselves, e.g., `is-u`.
1226
1264
#[ derive( Clone , Debug , Eq , PartialEq ) ]
1265
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
1227
1266
pub struct Flags {
1228
1267
/// The span of this group of flags.
1229
1268
pub span : Span ,
@@ -1276,6 +1315,7 @@ impl Flags {
1276
1315
1277
1316
/// A single item in a group of flags.
1278
1317
#[ derive( Clone , Debug , Eq , PartialEq ) ]
1318
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
1279
1319
pub struct FlagsItem {
1280
1320
/// The span of this item.
1281
1321
pub span : Span ,
@@ -1285,6 +1325,7 @@ pub struct FlagsItem {
1285
1325
1286
1326
/// The kind of an item in a group of flags.
1287
1327
#[ derive( Clone , Debug , Eq , PartialEq ) ]
1328
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
1288
1329
pub enum FlagsItemKind {
1289
1330
/// A negation operator applied to all subsequent flags in the enclosing
1290
1331
/// group.
@@ -1305,6 +1346,7 @@ impl FlagsItemKind {
1305
1346
1306
1347
/// A single flag.
1307
1348
#[ derive( Clone , Copy , Debug , Eq , PartialEq ) ]
1349
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
1308
1350
pub enum Flag {
1309
1351
/// `i`
1310
1352
CaseInsensitive ,
0 commit comments