-
Notifications
You must be signed in to change notification settings - Fork 3
/
textsubjects-smart.scm
128 lines (111 loc) · 2.35 KB
/
textsubjects-smart.scm
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
;; extends
([
; FIXME: the do block should grab the INSIDE of the do block
(exp_do)
(stmt)
(exp_cond)
(exp_tuple)
(exp_list)
(patterns)
(guard)
(signature)
(function)
(data_constructor)
(record_fields)
(type_family)
(type_instance)
(newtype)
(instance)
(adt)
(class)
(top_splice)
] @_start @_end
(#make-range! "range" @_start @_end))
; guard equation rhs
; startOfThisWeek day | dayOfWeek day == Monday
; = day
((guard_equation
(guards)
"="
(_) @_start @_end)
(#make-range! "range" @_start @_end))
; FIXME: individual constraints
; FIXME: import-list entries
; FIXME
; ((exp_tuple
; (_) @_start @_end
; ((comma) . (_) @_start @_end))*
; (#make-range! "range" @_start @_end)
; )
; signature + function
(
((signature) @_start
.
(function) @_end)
(#make-range! "range" @_start @_end))
; function apply param
(
(exp_apply . (_) (_) @_start @_end)
(#make-range! "range" @_start @_end))
; function definition lhs
((function
pattern: (_) @_start @_end)
(#make-range! "range" @_start @_end))
; function definition rhs (this matters if it is not a do)
((function . (_)+
rhs: (_) @_start @_end)
(#make-range! "range" @_start @_end)
)
; let-in rhs
(
; test =
; let
; a = 1
; b = 2
; in a + b
(exp_let_in (exp_let) (exp_in "in" (_) @_start @_end))
(#make-range! "range" @_start @_end))
; FIXME: how should this work
; ; parts of a lambda definition
; (
; ; \a b c -> a
; ; both (a b c) and a
; (exp_lambda "\\" (_) @_start @_end (_) @_end . "->" (_) @_start @_end)
; (#make-range! "range" @_start @_end))
; one record field
((
; data A = A
; { fieldOne :: Int
; , fieldTwo :: Int
; }
(field (_)) @_start @_end . (comma)? @_end
)
(#make-range! "range" @_start @_end))
([
; lhs of a bind_pattern assignment
; MkTy {tyOne, tyTwo} <- undefined
(bind_pattern . (_) @_start @_end)
; rhs
(bind_pattern (_) @_start @_end .)
]
(#make-range! "range" @_start @_end))
(
; parts of a signature
; someFunc :: forall a. (a -> String)
[
; lhs
(signature
name: (_) @_start @_end
)
; rhs
(signature
type: "::"
type: (_) @_start @_end
)
]
(#make-range! "range" @_start @_end)
)
(((_) @head . (comment) @_start . (comment)+ @_end (_) @tail)
(#not-has-type? @tail "comment")
(#not-has-type? @head "comment")
(#make-range! "range" @_start @_end))