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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e8f52b91ed0f66c7bdc49935483a81a5f329cec5ef5914555a57c6200b48ad7
4
- data.tar.gz: 3b52cc1430c0924cfc4a88f7facb2f022f51ef91ffdc94441b073d2dbde1866e
3
+ metadata.gz: 935f50c0ecadd127eddc6ddef78aa2cd2b4cc25c26ef33202260895719224527
4
+ data.tar.gz: ecebfbe0f95c5304d5a188eeaf8b6c22eff42357913064aa6f1ea380b4145f69
5
5
  SHA512:
6
- metadata.gz: 28dbc7918ed27110f6922286d36151ee00867a2a3d2afb8b20895fe12ddff5c3695b7dfa17058ce6a3638ddb43ca673661c85e586f31a6be4e94a7ea6364a1d7
7
- data.tar.gz: 74e0285aa3c6df1b0a41dd6ace23f60421202835f3d864089bcbc6fa6594dc6f0bc25b4db429cfff2880b633e63836e8b402195ce5db2e9d312cf5c622688fbf
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 condition, result' or 'base result'
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
- condition = parse_expression
282
-
283
- # Wrap simple trait references in cascade_and to match Ruby DSL behavior
284
- condition = wrap_condition_in_all(condition) if simple_trait_reference?(condition)
285
-
286
- expect_token(:comma)
287
- result = parse_expression
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)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kumi
4
4
  module Parser
5
- VERSION = '0.0.11'
5
+ VERSION = '0.0.12'
6
6
  end
7
7
  end
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.11
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-21 00:00:00.000000000 Z
11
+ date: 2025-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kumi