Module: Dhall::Parser::UnionTypeOrLiteralVariantType

Defined in:
lib/dhall/parser.rb

Instance Method Summary collapse

Instance Method Details

#value(label) ⇒ Object



358
359
360
361
362
363
364
365
366
367
368
# File 'lib/dhall/parser.rb', line 358

def value(label)
  rest = capture(:non_empty_union_type_or_literal)&.value
  type = UnionType.new(
    alternatives: { label => capture(:expression)&.value }
  )
  if rest.is_a?(Union)
    rest.with(alternatives: type.merge(rest.alternatives))
  else
    rest ? type.merge(rest) : type
  end
end