Module: Dhall::Parser::Expression
- Defined in:
- lib/dhall/parser.rb
Instance Method Summary collapse
- #arrow ⇒ Object
- #assert ⇒ Object
- #forall ⇒ Object
- #if ⇒ Object
- #lambda ⇒ Object
- #let_binding ⇒ Object
- #list ⇒ Object
- #merge ⇒ Object
- #tomap ⇒ Object
- #value ⇒ Object
Instance Method Details
#arrow ⇒ Object
57 58 59 60 61 62 |
# File 'lib/dhall/parser.rb', line 57 def arrow Forall.of_arguments( capture(:operator_expression).value, body: capture(:expression).value ) end |
#assert ⇒ Object
91 92 93 |
# File 'lib/dhall/parser.rb', line 91 def assert Assertion.new(type: capture(:expression).value) end |
#forall ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/dhall/parser.rb', line 49 def forall Forall.new( var: capture(:nonreserved_label).value, type: captures(:expression)[0].value, body: captures(:expression)[1].value ) end |
#if ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/dhall/parser.rb', line 64 def if If.new( predicate: captures(:expression)[0].value, then: captures(:expression)[1].value, else: captures(:expression)[2].value ) end |
#lambda ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/dhall/parser.rb', line 41 def lambda Function.new( var: capture(:nonreserved_label).value, type: captures(:expression)[0].value, body: captures(:expression)[1].value ) end |
#let_binding ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/dhall/parser.rb', line 33 def let_binding captures(:let_binding).reverse.reduce( capture(:expression).value ) do |inside, let| LetIn.new(let: let.value, body: inside) end end |
#list ⇒ Object
80 81 82 |
# File 'lib/dhall/parser.rb', line 80 def list EmptyList.new(type: capture(:application_expression).value) end |
#merge ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/dhall/parser.rb', line 72 def merge Merge.new( record: captures(:import_expression)[0].value, input: captures(:import_expression)[1].value, type: capture(:application_expression)&.value ) end |
#tomap ⇒ Object
84 85 86 87 88 89 |
# File 'lib/dhall/parser.rb', line 84 def tomap ToMap.new( record: capture(:import_expression).value, type: capture(:application_expression).value ) end |
#value ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/dhall/parser.rb', line 23 def value return list if string =~ /\A\[\s*\]/ key = [:let_binding, :lambda, :forall, :arrow, :if, :merge, :tomap, :assert] .find { |k| captures.key?(k) } key ? public_send(key) : super end |