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
114
115
116
|
#[derive(Debug, Clone, PartialEq)]
pub enum SelectionValuedExpr {
// Nullary selection function application
NullaryApplicationS(SelectionFn),
NullaryApplicationT(TextFn),
// Monadic selection function application: α F
MonadicApplicationS {
arg: Box<SelectionValuedExpr>,
func: SelectionFn,
},
// Monadic selection function application: F τ
MonadicApplicationT {
arg: Box<TextValuedExpr>,
func: TextFn,
},
// Dyadic selection function application: α F β
DyadicApplicationS {
left: Box<SelectionValuedExpr>,
right: Box<SelectionValuedExpr>,
func: SelectionFn,
},
// Dyadic text function application: α F τ
DyadicApplicationT {
left: Box<SelectionValuedExpr>,
right: Box<SelectionValuedExpr>,
func: SelectionFn,
},
}
#[derive(Debug, Clone, PartialEq)]
pub enum TextValuedExpr {
// Selection coerced to text (implicit coercion)
FromSelection(Box<SelectionValuedExpr>),
}
#[derive(Debug, Clone, PartialEq)]
pub enum SelectionFn {
Function {
func: BuiltinSelectionFn,
search_mod: Option<SearchModifier>,
result_transform: Option<ResultTransform>,
},
Hook {
kind: HookKind,
left: Box<SelectionFn>,
right: Box<SelectionFn>,
},
Train(Vec<SelectionFn>),
}
#[derive(Debug, Clone, PartialEq)]
pub enum TextFn {
Function {
func: BuiltinTextFn,
swapped: bool,
},
Hook {
kind: HookKind,
left: Box<TextFn>,
right: Box<TextFn>,
},
Train(Vec<TextFn>),
}
#[derive(Debug, Clone, PartialEq)]
pub enum BuiltinSelectionFn {
Empty, // e
EndOfBuffer, // $
Span, // -
CharOffset(usize), // # (expects number arg)
Line(usize), // (expects number arg)
Regex(String), // /re/ (expects regex arg)
AllMatches(String), // x (expects /re/ arg)
RelativeLine(usize), // + (expects number arg)
BufferMatch(String), // B (expects /re/ arg)
}
#[derive(Debug, Clone, PartialEq)]
pub enum BuiltinTextFn {
Dot, // .
Change, // c
Insert, // i
Append, // a
Delete, // d
Write, // w
Pipe, // |
Literal(String), // "..."
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum SearchModifier {
Reverse, // '
Sequential, // ;
ReverseSequential, // ';
SequentialReverse, // ;'
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum ResultTransform {
Complement, // ~
Conditional, // ?
ComplementConditional, // ~?
ConditionalComplement, // ?~
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum HookKind {
Before, // F>G (left hook)
After, // F<G (right hook)
}
|