feel 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 398083f80016bdecadf3f3ce58af72cabcf4fdecbba1490a20bf75fd11790a41
4
- data.tar.gz: c0aeb54440f57dfe9349fa8973b4f47028c04832bf6981f9ea8239f1372243a3
3
+ metadata.gz: 2d746d289c6f891920bc416f5616ffa1bfac0dc0d21c91b53b3ca0d9211a13c7
4
+ data.tar.gz: a81e5dd3027921066d4e10b435040b9f364d902a6fcdd0527a0889ed18b1baa2
5
5
  SHA512:
6
- metadata.gz: 8d8b027ebba02284ca76088b87d4ed4836966b6bd8640bddc7afe53b2fe1520bc89445bd965ce8f2af925477fa629f3b518f419ecc3f3b26e1448e23be3d413c
7
- data.tar.gz: f7a48972f26b28406100ed51c771863059d7ee16999ac41e836ca0a86e2b2b88e30dde29c2dbcec6fc697efda44f6b27a828c19c5ecd9e9f32b96209dee50d2f
6
+ metadata.gz: 7681b1c1596acdfec401b1f125998bdb96af557f85fc9a29ca0382a199a69b047888476b75b38284f57244210794b1d109f7668b5063720610134c7137173ed7
7
+ data.tar.gz: 594a28b3e3597981560173a97688feeeb63c2eb4e2274536cef4917ecda60d513b975ec6885306be2aaaa42b216f7d667dea0c6e9808c0955558b24134580c37
@@ -279,8 +279,20 @@ grammar FEEL
279
279
  # 27. name = name start , { name part | additional name symbols } ;
280
280
  #
281
281
  rule name
282
+ backtick_name / regular_name
283
+ end
284
+
285
+ rule regular_name
282
286
  head:name_start tail:(__ name_part)* <Name>
283
287
  end
288
+
289
+ rule backtick_name
290
+ "`" content:backtick_content "`" <BacktickName>
291
+ end
292
+
293
+ rule backtick_content
294
+ (!"`" .)*
295
+ end
284
296
 
285
297
  rule reserved_word
286
298
  keyword /
data/lib/feel/nodes.rb CHANGED
@@ -224,17 +224,37 @@ module FEEL
224
224
  #
225
225
  class QualifiedName < Node
226
226
  def eval(context = {})
227
+ head_name = head.eval(context)
228
+
227
229
  if tail.empty?
228
- raise_evaluation_error(head.text_value, context) if FEEL.config.strict && !context.key?(head.text_value.to_sym)
229
- context[head.text_value.to_sym]
230
+ context_get(context, head_name)
230
231
  else
231
- tail.elements.flat_map { |element| element.name.text_value.split(".") }.inject(context[head.text_value.to_sym]) do |hash, key|
232
- raise_evaluation_error("#{head.text_value}#{tail.text_value}", context) if FEEL.config.strict && (hash.blank? || !hash.key?(key.to_sym))
232
+ initial_value = context_get(context, head_name)
233
+
234
+ # Process each segment in the tail, evaluating names to handle backticks
235
+ tail.elements.inject(initial_value) do |hash, element|
233
236
  return nil unless hash
234
- hash[key.to_sym]
237
+
238
+ key = element.name.eval(context)
239
+ context_get(hash, key, root: context)
235
240
  end
236
241
  end
237
242
  end
243
+
244
+ # Get a key from the context, using symbol/string lookup, with errors if
245
+ # need be, and optionally overriding the root object for full path during
246
+ # errors.
247
+ def context_get(context, key, root: :nil)
248
+ root = context if root == :nil
249
+ if context.key?(key.to_sym)
250
+ context[key.to_sym]
251
+ elsif context.key?(key)
252
+ context[key]
253
+ else
254
+ raise_evaluation_error(head.text_value + tail.text_value, root) if FEEL.config.strict
255
+ nil
256
+ end
257
+ end
238
258
  end
239
259
 
240
260
  #
@@ -298,6 +318,13 @@ module FEEL
298
318
  text_value.strip
299
319
  end
300
320
  end
321
+
322
+ class BacktickName < Node
323
+ def eval(_context = {})
324
+ # Extract content between backticks
325
+ content.text_value
326
+ end
327
+ end
301
328
 
302
329
  #
303
330
  # 28. name start = name start char, { name part char } ;
data/lib/feel/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FEEL
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Connected Bits
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-06-27 00:00:00.000000000 Z
10
+ date: 2025-11-09 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activemodel