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 +4 -4
- data/lib/feel/feel.treetop +12 -0
- data/lib/feel/nodes.rb +32 -5
- data/lib/feel/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2d746d289c6f891920bc416f5616ffa1bfac0dc0d21c91b53b3ca0d9211a13c7
|
|
4
|
+
data.tar.gz: a81e5dd3027921066d4e10b435040b9f364d902a6fcdd0527a0889ed18b1baa2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7681b1c1596acdfec401b1f125998bdb96af557f85fc9a29ca0382a199a69b047888476b75b38284f57244210794b1d109f7668b5063720610134c7137173ed7
|
|
7
|
+
data.tar.gz: 594a28b3e3597981560173a97688feeeb63c2eb4e2274536cef4917ecda60d513b975ec6885306be2aaaa42b216f7d667dea0c6e9808c0955558b24134580c37
|
data/lib/feel/feel.treetop
CHANGED
|
@@ -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
|
-
|
|
229
|
-
context[head.text_value.to_sym]
|
|
230
|
+
context_get(context, head_name)
|
|
230
231
|
else
|
|
231
|
-
|
|
232
|
-
|
|
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
|
-
|
|
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
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.
|
|
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-
|
|
10
|
+
date: 2025-11-09 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: activemodel
|