blob: 47356b1fd3878864a2fe658d0623261ff29c5bf6 (
plain)
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
|
use ast::source_slice_list::SourceSliceIndex;
#[derive(Debug)]
pub struct RegExpItem {
pub pattern: SourceSliceIndex,
pub global: bool,
pub ignore_case: bool,
pub multi_line: bool,
pub dot_all: bool,
pub sticky: bool,
pub unicode: bool,
}
/// Index into RegExpList.atoms.
#[derive(Debug, Clone, Copy)]
pub struct RegExpIndex {
index: usize,
}
impl RegExpIndex {
fn new(index: usize) -> Self {
Self { index }
}
}
impl From<RegExpIndex> for usize {
fn from(index: RegExpIndex) -> usize {
index.index
}
}
/// List of RegExp.
#[derive(Debug)]
pub struct RegExpList {
items: Vec<RegExpItem>,
}
impl RegExpList {
pub fn new() -> Self {
Self { items: Vec::new() }
}
pub fn push(&mut self, item: RegExpItem) -> RegExpIndex {
let index = self.items.len();
self.items.push(item);
RegExpIndex::new(index)
}
}
impl From<RegExpList> for Vec<RegExpItem> {
fn from(list: RegExpList) -> Vec<RegExpItem> {
list.items
}
}
|