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 +4 -4
- data/lib/kumi/parser/direct_parser.rb +12 -0
- data/lib/kumi/parser/smart_tokenizer.rb +12 -0
- data/lib/kumi/parser/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c06089581b6028ed2459e0e96d9398cd973f02d6000fc707898c920bd1b24e1
|
4
|
+
data.tar.gz: efb8f1e76217b7b98cef5abe97e5189326e70f81b3fbf53c5324556dc38fbb79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 == '.'
|
data/lib/kumi/parser/version.rb
CHANGED