Module: Dhall::Parser::Expression
- Defined in:
- lib/dhall/parser.rb
Instance Method Summary collapse
- #arrow ⇒ Object
- #forall ⇒ Object
- #if ⇒ Object
- #lambda ⇒ Object
- #let_binding ⇒ Object
- #merge ⇒ Object
- #value ⇒ Object
Instance Method Details
#arrow ⇒ Object
59 60 61 62 63 64 |
# File 'lib/dhall/parser.rb', line 59 def arrow Forall.of_arguments( capture(:operator_expression).value, body: capture(:expression).value ) end |
#forall ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/dhall/parser.rb', line 51 def forall Forall.new( var: capture(:nonreserved_label).value, type: captures(:expression)[0].value, body: captures(:expression)[1].value ) end |
#if ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/dhall/parser.rb', line 66 def if If.new( predicate: captures(:expression)[0].value, then: captures(:expression)[1].value, else: captures(:expression)[2].value ) end |
#lambda ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/dhall/parser.rb', line 43 def lambda Function.new( var: capture(:nonreserved_label).value, type: captures(:expression)[0].value, body: captures(:expression)[1].value ) end |
#let_binding ⇒ Object
36 37 38 39 40 41 |
# File 'lib/dhall/parser.rb', line 36 def let_binding LetBlock.for( lets: captures(:let_binding).map(&:value), body: capture(:expression).value ) end |
#merge ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/dhall/parser.rb', line 74 def merge Merge.new( record: captures(:import_expression)[0].value, input: captures(:import_expression)[1].value, type: capture(:application_expression)&.value ) end |
#value ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/dhall/parser.rb', line 23 def value key = [:let_binding, :lambda, :forall, :arrow, :if, :merge] .find { |k| captures.key?(k) } return public_send(key) if key key = [:empty_collection, :non_empty_optional] .find { |k| captures.key?(k) } key ? capture(key).value : super end |