kumi-parser 0.0.8 → 0.0.9

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: e06f93fc75dd438aff2b30f8980fff20abedfa426e80c66e329fb9a735102601
4
- data.tar.gz: 7e4bcfc6f5f7e709bcd61721a3e996f2221e43b254895ff7f9b718675095a94f
3
+ metadata.gz: 5c06089581b6028ed2459e0e96d9398cd973f02d6000fc707898c920bd1b24e1
4
+ data.tar.gz: efb8f1e76217b7b98cef5abe97e5189326e70f81b3fbf53c5324556dc38fbb79
5
5
  SHA512:
6
- metadata.gz: 48eedfdcc441a14209d03cf9640f171ed924e09c0e8af48634626967b8fb2d65a5b4e93b8007c6411b2f098ecdbd40e1b5fe15bcb8d1343a1e8c449402713c7f
7
- data.tar.gz: 482817510f74d70f0a8e8d4547e9ff1aafac2ed29cc2d3629cf244fb7e3d1e8966005be25caaeca549951cd23271f5c28597430cb635b11dabbb952a66b63e75
6
+ metadata.gz: 50b9b9d4bf2c6d250c83ee92022ed3d3d280a7329aefdb699fef1444e9611d91aacd69d0bf7693335bf81a3b81c88bff7ef7ebf991da5c97bc98b76bec2b901d
7
+ data.tar.gz: 11f5f0949efbdc961e963890ecae8cb114424f20c305107f01c53b120deced6bf96b2f78a7e28d1e57c0af025ae6749bdab8e49e3bdf59899949dc0a6d27accc
@@ -373,6 +373,18 @@ module Kumi
373
373
  when :fn
374
374
  parse_function_call_from_fn_token
375
375
 
376
+ when :subtract
377
+ # Handle unary minus operator: -expression
378
+ advance # consume '-'
379
+ skip_comments_and_newlines
380
+ operand = parse_primary_expression
381
+ # Convert to subtraction from zero: (subtract 0 operand)
382
+ Kumi::Syntax::CallExpression.new(
383
+ :subtract,
384
+ [Kumi::Syntax::Literal.new(0, loc: token.location), operand],
385
+ loc: token.location
386
+ )
387
+
376
388
  when :newline, :comment
377
389
  # Skip newlines and comments in expressions
378
390
  skip_comments_and_newlines
@@ -28,6 +28,12 @@ module Kumi
28
28
  when '#' then consume_comment
29
29
  when '"' then consume_string
30
30
  when /\d/ then consume_number
31
+ when '-'
32
+ if peek_char && peek_char.match?(/\d/)
33
+ consume_number
34
+ else
35
+ consume_operator_or_punctuation
36
+ end
31
37
  when /[a-zA-Z_]/ then consume_identifier_or_keyword
32
38
  when ':' then consume_symbol_or_colon
33
39
  else
@@ -124,6 +130,12 @@ module Kumi
124
130
  number_str = ''
125
131
  has_dot = false
126
132
 
133
+ # Handle negative sign if present
134
+ if current_char == '-'
135
+ number_str += current_char
136
+ advance
137
+ end
138
+
127
139
  # Consume digits and underscores, and optionally a decimal point
128
140
  while current_char && (current_char.match?(/[0-9_]/) || (!has_dot && current_char == '.'))
129
141
  if current_char == '.'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kumi
4
4
  module Parser
5
- VERSION = '0.0.8'
5
+ VERSION = '0.0.9'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kumi-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kumi Team