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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23d5bf2430a932df4208453cc4847d06915a5140
4
- data.tar.gz: 6be0f56ed32a3bded3ef3b9241633faedfc83c3a
3
+ metadata.gz: 0bd9629e495b71aa9395ad56acba1b0a90438f8a
4
+ data.tar.gz: 988988c9c767178f711ea944a1955807675ad08a
5
5
  SHA512:
6
- metadata.gz: 68bfb69f1c7628a24f2738bf5be828ce7b31d181a82f550ad1ed54b451d7612fa2ff7f4e6a6b6bf229dbfe147c13ff2a0656436c6b2680cfc800bd70106a34c3
7
- data.tar.gz: 9794d372352bd5cff6704b93604ea6b94942a6e4eaf882602788b0660c579e80bfae6369843b5eb75cb55ae3d97848123e52517b4acbb825d1f961e731acacc0
6
+ metadata.gz: 14691228c8cc50ce2219558080b9ff0d814f1e2c98421c9d4967c1aeaf54a00261f8e883da6c00095545a4d92173fa4136004ed8768ca2e95ba7174bbdcc9dcc
7
+ data.tar.gz: 4cda473f15bc4fb71ea036b6914b6222766a3b6c088bd5c31ffb111aeaa6f5e57a75e30cfb8f640d917dc9f9313a7b77d5410cf8c991f3e68ad00deb8dd6001f
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## master
4
+
5
+ ## 0.2.1 (2016-11-24)
6
+
7
+ * Fix `self` pattern matching
8
+
3
9
  ## 0.2.0 (2016-11-24)
4
10
 
5
11
  * Remove `tagging` section from config
@@ -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 receiver.test_node(node.children[0])
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
@@ -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(/\(/)
@@ -1,3 +1,3 @@
1
1
  module Querly
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: querly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto