kumi-parser 0.0.11 → 0.0.12
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/kumi/parser/direct_parser.rb +26 -8
- data/lib/kumi/parser/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: 935f50c0ecadd127eddc6ddef78aa2cd2b4cc25c26ef33202260895719224527
|
4
|
+
data.tar.gz: ecebfbe0f95c5304d5a188eeaf8b6c22eff42357913064aa6f1ea380b4145f69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81fe15f8482f0a2e123c14136e10bf47d2b90f5957f8c90e6ca4a416e811deee838510d22d3eb266dc8ef64b13dc1f4d2769eeacb06e7f1cac2a82e79fe1aa3b
|
7
|
+
data.tar.gz: ad2e56299872ac29522b5d63eca7e2c67ad74c07b702bf8cb0aa3a4da870bc11781e8e7a9c1df0232a75712c9eec7d8b29ebfedf4b387094790d2dfa48e3ecbf
|
@@ -273,18 +273,35 @@ module Kumi
|
|
273
273
|
Kumi::Syntax::CascadeExpression.new(cases, loc: start_token.location)
|
274
274
|
end
|
275
275
|
|
276
|
-
# Case expression: 'on
|
276
|
+
# Case expression: 'on condition1, condition2, ..., result' or 'base result'
|
277
277
|
def parse_case_expression
|
278
278
|
case current_token.type
|
279
279
|
when :on
|
280
280
|
on_token = advance_and_return_token
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
281
|
+
|
282
|
+
# Parse all comma-separated expressions
|
283
|
+
expressions = []
|
284
|
+
expressions << parse_expression
|
285
|
+
|
286
|
+
# Continue parsing comma-separated expressions until end of case
|
287
|
+
while current_token.type == :comma
|
288
|
+
advance # consume comma
|
289
|
+
expressions << parse_expression
|
290
|
+
end
|
291
|
+
|
292
|
+
# Last expression is the result, all others are conditions
|
293
|
+
result = expressions.pop
|
294
|
+
conditions = expressions
|
295
|
+
|
296
|
+
# Combine conditions appropriately
|
297
|
+
if conditions.length == 1
|
298
|
+
condition = conditions[0]
|
299
|
+
# Wrap simple trait references in cascade_and to match Ruby DSL behavior
|
300
|
+
condition = wrap_condition_in_all(condition) if simple_trait_reference?(condition)
|
301
|
+
else
|
302
|
+
# Multiple conditions: combine with cascade_and
|
303
|
+
condition = Kumi::Syntax::CallExpression.new(:cascade_and, conditions, loc: on_token.location)
|
304
|
+
end
|
288
305
|
|
289
306
|
Kumi::Syntax::CaseExpression.new(condition, result, loc: on_token.location)
|
290
307
|
|
@@ -570,6 +587,7 @@ module Kumi
|
|
570
587
|
condition.is_a?(Kumi::Syntax::DeclarationReference)
|
571
588
|
end
|
572
589
|
|
590
|
+
|
573
591
|
# Helper method to wrap condition in cascade_and function call
|
574
592
|
def wrap_condition_in_all(condition)
|
575
593
|
Kumi::Syntax::CallExpression.new(:cascade_and, [condition], loc: condition.loc)
|
data/lib/kumi/parser/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kumi-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kumi Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-08-
|
11
|
+
date: 2025-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kumi
|