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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
use crate::{ast, ast::support, impl_ast_node, language::SyntaxNode, AstNode, SyntaxKind};
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ValBind {
syntax: SyntaxNode,
}
impl_ast_node!(ValBind, VAL_BIND);
impl ValBind {
pub fn pat(&self) -> Option<ast::Pat> {
support::child(self.syntax())
}
pub fn expr(&self) -> Option<ast::Expr> {
support::child(self.syntax())
}
pub fn rec(&self) -> bool {
support::token(self.syntax(), SyntaxKind::REC_KW).is_some()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct FvalBind {
syntax: SyntaxNode,
}
impl_ast_node!(FvalBind, FVAL_BIND);
impl FvalBind {
pub fn rows(&self) -> impl Iterator<Item = FvalBindRow> {
support::children(self.syntax())
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct FvalBindRow {
syntax: SyntaxNode,
}
impl_ast_node!(FvalBindRow, FVAL_BIND_ROW);
impl FvalBindRow {
pub fn op(&self) -> bool {
support::token(self.syntax(), SyntaxKind::OP_KW).is_some()
}
pub fn vid(&self) -> Option<ast::VId> {
support::tokens(self.syntax()).next()
}
pub fn atpats(&self) -> impl Iterator<Item = ast::AtomicPat> {
support::children(self.syntax())
}
pub fn ty(&self) -> Option<ast::Ty> {
support::child(self.syntax())
}
pub fn expr(&self) -> Option<ast::Expr> {
support::child(self.syntax())
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TyBind {
syntax: SyntaxNode,
}
impl_ast_node!(TyBind, TY_BIND);
impl TyBind {
pub fn tyvarseq(&self) -> impl Iterator<Item = ast::TyVar> {
support::tokens(self.syntax())
}
pub fn tycon(&self) -> Option<ast::TyCon> {
support::tokens(self.syntax()).next()
}
pub fn ty(&self) -> Option<ast::Ty> {
support::child(self.syntax())
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct DataBind {
syntax: SyntaxNode,
}
impl_ast_node!(DataBind, DATA_BIND);
impl DataBind {
pub fn tyvarseq(&self) -> impl Iterator<Item = ast::TyVar> {
support::tokens(self.syntax())
}
pub fn tycon(&self) -> Option<ast::TyCon> {
support::tokens(self.syntax()).next()
}
pub fn conbinds(&self) -> impl Iterator<Item = ast::ConBind> {
support::children(self.syntax())
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ConBind {
syntax: SyntaxNode,
}
impl_ast_node!(ConBind, CON_BIND);
impl ConBind {
pub fn op(&self) -> bool {
support::token(self.syntax(), SyntaxKind::OP_KW).is_some()
}
pub fn vid(&self) -> Option<ast::VId> {
support::tokens(self.syntax()).next()
}
pub fn ty(&self) -> Option<ast::Ty> {
support::child(self.syntax())
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ExBind {
syntax: SyntaxNode,
}
impl_ast_node!(ExBind, EX_BIND);
impl ExBind {
pub fn vid(&self) -> Option<ast::VId> {
support::tokens(self.syntax()).next()
}
pub fn ty(&self) -> Option<ast::Ty> {
support::child(self.syntax())
}
pub fn eq(&self) -> bool {
support::token(self.syntax(), SyntaxKind::EQ).is_some()
}
pub fn longvid(&self) -> Option<ast::LongVId> {
support::child(self.syntax())
}
}