kumi-parser 0.0.9 → 0.0.10

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: 5c06089581b6028ed2459e0e96d9398cd973f02d6000fc707898c920bd1b24e1
4
- data.tar.gz: efb8f1e76217b7b98cef5abe97e5189326e70f81b3fbf53c5324556dc38fbb79
3
+ metadata.gz: b2cb46dec6261ef8c66346abb17f188c36a21c97322415ac6315adc3347214c3
4
+ data.tar.gz: 4cad59a51d06aaca85b1343ac520cdf28e5a82255df891fbb0086d4b11e35d98
5
5
  SHA512:
6
- metadata.gz: 50b9b9d4bf2c6d250c83ee92022ed3d3d280a7329aefdb699fef1444e9611d91aacd69d0bf7693335bf81a3b81c88bff7ef7ebf991da5c97bc98b76bec2b901d
7
- data.tar.gz: 11f5f0949efbdc961e963890ecae8cb114424f20c305107f01c53b120deced6bf96b2f78a7e28d1e57c0af025ae6749bdab8e49e3bdf59899949dc0a6d27accc
6
+ metadata.gz: c0505e71430dd3593356318dc4262e3b79487d9eea3aceb7fd19fbd189d9c5c0593d937eebd9727206d6640d0d280eede4a8378058de11858e83f05467d46aaa
7
+ data.tar.gz: 904e451757c5beeaa13f0a27c53477dcd5729abd678e08713f150e7d03a9a7fb3e5b948f7a62d8deed1ef38905214bebfe99881758bb92a2d8faf68ece50364e
@@ -335,7 +335,7 @@ module Kumi
335
335
  token = current_token
336
336
 
337
337
  case token.type
338
- when :integer, :float, :string, :boolean
338
+ when :integer, :float, :string, :boolean, :constant
339
339
  # Direct AST construction using token metadata
340
340
  value = convert_literal_value(token)
341
341
  advance
@@ -529,6 +529,12 @@ module Kumi
529
529
  when :float then token.value.gsub('_', '').to_f
530
530
  when :string then token.value
531
531
  when :boolean then token.value == 'true'
532
+ when :constant
533
+ case token.value
534
+ when 'Float::INFINITY' then Float::INFINITY
535
+ else
536
+ raise_parse_error("Unknown constant: #{token.value}")
537
+ end
532
538
  end
533
539
  end
534
540
 
@@ -160,6 +160,18 @@ module Kumi
160
160
  start_column = @column
161
161
  identifier = consume_while { |c| c.match?(/[a-zA-Z0-9_]/) }
162
162
 
163
+ # Check if it's a constant (e.g., Float::INFINITY)
164
+ if identifier == 'Float' && current_char == ':' && peek_char == ':'
165
+ advance # consume first :
166
+ advance # consume second :
167
+ constant_name = consume_while { |c| c.match?(/[a-zA-Z0-9_]/) }
168
+ full_constant = "#{identifier}::#{constant_name}"
169
+
170
+ location = Kumi::Syntax::Location.new(file: @source_file, line: @line, column: start_column)
171
+ @tokens << Token.new(:constant, full_constant, location, Kumi::Parser::TOKEN_METADATA[:constant])
172
+ return
173
+ end
174
+
163
175
  # Check if it's a keyword
164
176
  if keyword_type = Kumi::Parser::KEYWORDS[identifier]
165
177
  metadata = Kumi::Parser::TOKEN_METADATA[keyword_type].dup
@@ -13,6 +13,7 @@ module Kumi
13
13
  # Identifiers and symbols
14
14
  IDENTIFIER = :identifier
15
15
  SYMBOL = :symbol # :name
16
+ CONSTANT = :constant # Float::INFINITY
16
17
 
17
18
  # Keywords
18
19
  SCHEMA = :schema
@@ -278,6 +279,11 @@ module Kumi
278
279
  starts_expression: true,
279
280
  is_declaration_name: true
280
281
  },
282
+ constant: {
283
+ category: :literal,
284
+ starts_expression: true,
285
+ ast_class: 'Kumi::Syntax::Literal'
286
+ },
281
287
 
282
288
  # Punctuation with parser hints
283
289
  dot: {
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kumi
4
4
  module Parser
5
- VERSION = '0.0.9'
5
+ VERSION = '0.0.10'
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.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kumi Team