querly 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/querly/pattern/expr.rb +18 -3
- data/lib/querly/pattern/parser.y +3 -0
- data/lib/querly/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bd9629e495b71aa9395ad56acba1b0a90438f8a
|
4
|
+
data.tar.gz: 988988c9c767178f711ea944a1955807675ad08a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14691228c8cc50ce2219558080b9ff0d814f1e2c98421c9d4967c1aeaf54a00261f8e883da6c00095545a4d92173fa4136004ed8768ca2e95ba7174bbdcc9dcc
|
7
|
+
data.tar.gz: 4cda473f15bc4fb71ea036b6914b6222766a3b6c088bd5c31ffb111aeaa6f5e57a75e30cfb8f640d917dc9f9313a7b77d5410cf8c991f3e68ad00deb8dd6001f
|
data/CHANGELOG.md
CHANGED
data/lib/querly/pattern/expr.rb
CHANGED
@@ -170,12 +170,23 @@ module Querly
|
|
170
170
|
case node&.type
|
171
171
|
when :send
|
172
172
|
return false unless name == node.children[1]
|
173
|
-
return false unless
|
173
|
+
return false unless test_receiver(node.children[0])
|
174
174
|
return false unless test_args(node.children.drop(2), args)
|
175
175
|
true
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
179
|
+
def test_receiver(node)
|
180
|
+
case receiver
|
181
|
+
when Self
|
182
|
+
!node || receiver.test_node(node)
|
183
|
+
when nil
|
184
|
+
true
|
185
|
+
else
|
186
|
+
receiver.test_node(node)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
179
190
|
def test_args(nodes, args)
|
180
191
|
first_node = nodes.first
|
181
192
|
|
@@ -271,6 +282,12 @@ module Querly
|
|
271
282
|
end
|
272
283
|
end
|
273
284
|
|
285
|
+
class Self < Base
|
286
|
+
def test_node(node)
|
287
|
+
node&.type == :self
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
274
291
|
class Vcall < Base
|
275
292
|
attr_reader :name
|
276
293
|
|
@@ -299,8 +316,6 @@ module Querly
|
|
299
316
|
node.children[1] == name
|
300
317
|
when :lvar
|
301
318
|
node.children.first == name
|
302
|
-
when :self
|
303
|
-
name == :self
|
304
319
|
end
|
305
320
|
end
|
306
321
|
end
|
data/lib/querly/pattern/parser.y
CHANGED
@@ -15,6 +15,7 @@ kinded_expr: expr { result = Kind::Any.new(expr: val[0]) }
|
|
15
15
|
|
16
16
|
expr: constant { result = Expr::Constant.new(path: val[0]) }
|
17
17
|
| send
|
18
|
+
| SELF { result = Expr::Self.new }
|
18
19
|
| EXCLAMATION expr { result = Expr::Not.new(pattern: val[1]) }
|
19
20
|
| BOOL { result = Expr::Literal.new(type: :bool, value: val[0]) }
|
20
21
|
| STRING { result = Expr::Literal.new(type: :string, value: val[0]) }
|
@@ -154,6 +155,8 @@ def next_token
|
|
154
155
|
[:UNDERBAR, input.matched]
|
155
156
|
when input.scan(/[A-Z]\w*/)
|
156
157
|
[:UIDENT, input.matched.to_sym]
|
158
|
+
when input.scan(/self/)
|
159
|
+
[:SELF, nil]
|
157
160
|
when input.scan(/[a-z_](\w)*(\?|\!|=)?/)
|
158
161
|
[:LIDENT, input.matched.to_sym]
|
159
162
|
when input.scan(/\(/)
|
data/lib/querly/version.rb
CHANGED