1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
pub mod actual_items;
pub mod actual_items_builder;
pub mod any;
pub mod any_builder;
pub mod expected_items;
pub mod expected_items_builder;
pub mod machine;
pub mod range_contains_max;
pub mod range_contains_max_builder;
pub mod repeat;
pub mod repeat_builder;
pub struct Machine {
actual_index: usize,
expected_index: usize,
is_final: bool,
matched_length_in_repeat: usize,
}
pub struct ActualItemsBuilder<T> {
items: Vec<T>,
}
pub struct ActualItems<T> {
items: Vec<T>,
}
pub struct ExpectedItemsBuilder<T> {
items: Vec<Controls<T>>,
}
pub struct ExpectedItems<T> {
items: Vec<Controls<T>>,
}
#[derive(Clone)]
pub enum Controls<T> {
Once(Quantity<T>),
Repeat(Repeat<T>),
}
#[derive(Clone)]
pub enum Quantity<T> {
One(Expected<T>),
Any(Any<T>),
}
#[derive(Clone)]
pub enum Expected<T> {
Exact(T),
RangeContainsMax(RangeContainsMax<T>),
}
pub struct RangeContainsMaxBuilder<T> {
min: Option<T>,
max: Option<T>,
}
#[derive(Clone)]
pub struct RangeContainsMax<T> {
min: Option<T>,
max: Option<T>,
}
pub struct AnyBuilder<T> {
items: Vec<Expected<T>>,
}
#[derive(Clone)]
pub struct Any<T> {
items: Vec<Expected<T>>,
}
pub struct RepeatBuilder<T> {
quantity: Option<Box<Quantity<T>>>,
min: usize,
max_not_included: usize,
}
#[derive(Clone)]
pub struct Repeat<T> {
quantity: Box<Quantity<T>>,
min: usize,
max_not_included: usize,
}
pub enum MatchingResult {
Ongoing,
Matched,
NotMatch,
}