kumi-parser 0.0.21 → 0.0.22

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: 219a0ee4cbe1b140e1adb5f885b95764258bad4ac416ad361167dcdf5464e64b
4
- data.tar.gz: db323360955a244c7f6ddbf6cdcd1ae333fc21aa039ce0364ac143789d17f5c5
3
+ metadata.gz: b23bd39864b3107f7f6e3c7fecf3e3791152e015a23ebe673a3e1aea2cb7553e
4
+ data.tar.gz: b60284dcb13154d1773f35d3dc4af954f794e31b546f3cd94e37f25bc84a4e1d
5
5
  SHA512:
6
- metadata.gz: c937eee31a97be97fa71e4830db4f40122acb1aae720fb1dba78a67b1039cc21cd9042d3ae0884d67cda3dbddcf47e6e193a805218d2f68f93946f90649060a2
7
- data.tar.gz: 21b2ae87d652bc2ffb66489ea0a504033baaa65c6d74ee9168a7a8420d38de3d04c005b1ae21acc10c49656a3c8dee242a2e47425e007cdb3058b389c40de5f1
6
+ metadata.gz: 2fdb2049c0b269d1b89a20aa6481df8d199916c55f56fb0ba3fa223abf0f9e531bfa2b0a2c4619b6e676497d1acaaf37565c42114886266b3625ac224cb7121b
7
+ data.tar.gz: 8e5348e745c4b633ffc1b1b5b853281e83aa09a737593be1bfe70a1149550b5d3bffc85d8b6aae6020320b717a08b8d3cc3940d93d67caec2072676aaec205df
@@ -253,11 +253,11 @@ module Kumi
253
253
  # Value declaration: 'value :name, expression' or 'value :name do ... end'
254
254
  def parse_value_declaration
255
255
  begin
256
- value_token = expect_token(:value)
257
- name_token = expect_token(:symbol)
258
- rescue => e
259
- binding.pry
260
- end
256
+ value_token = expect_token(:value)
257
+ name_token = expect_token(:symbol)
258
+ rescue StandardError => e
259
+ binding.pry
260
+ end
261
261
 
262
262
  if current_token.type == :do
263
263
  expression = parse_cascade_expression
@@ -604,28 +604,30 @@ module Kumi
604
604
  end
605
605
 
606
606
  def parse_hash_pair
607
- key_token_type = current_token.type
608
- key = case key_token_type
609
- when :label, :string
610
- value = current_token.value.to_sym if key_token_type == :label
611
- advance
612
- Kumi::Syntax::Literal.new(value, loc: current_token.location)
613
- else
614
- raise_parse_error("Hash keys must be symbols (:key) or strings (\"key\"), got #{current_token.type}")
615
- end
607
+ key_token = current_token
616
608
 
617
- skip_comments_and_newlines
609
+ key_value =
610
+ case key_token.type
611
+ when :label then key_token.value.to_sym # render:
612
+ when :string then key_token.value # "0" => ...
613
+ when :symbol then key_token.value.to_sym # optional support for :foo => ...
614
+ else
615
+ raise_parse_error('Hash keys must be symbols (:key) or strings ("key")')
616
+ end
618
617
 
619
- case current_token.type
620
- when :arrow
618
+ advance
619
+ key = Kumi::Syntax::Literal.new(key_value, loc: key_token.location)
620
+
621
+ skip_comments_and_newlines
622
+ if current_token.type == :arrow
621
623
  advance
622
624
  else
623
- raise_parse_error("Expected '=>' in hash pair") unless key_token_type == :label
625
+ # Only labels may omit => (Ruby-style `key:`)
626
+ raise_parse_error("Expected '=>' in hash pair") unless key_token.type == :label
624
627
  end
625
628
 
626
629
  skip_comments_and_newlines
627
630
  value = parse_expression
628
-
629
631
  [key, value]
630
632
  end
631
633
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kumi
4
4
  module Parser
5
- VERSION = '0.0.21'
5
+ VERSION = '0.0.22'
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.21
4
+ version: 0.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kumi Team