Module: SFRP::Poly::DSL

Defined in:
lib/sfrp/poly/dsl.rb

Defined Under Namespace

Classes: CaseProxy, FuncProxy, NodeProxy, TConstProxy

Instance Method Summary collapse

Instance Method Details

#call_e(func_str, *arg_exps) ⇒ Object



39
40
41
# File 'lib/sfrp/poly/dsl.rb', line 39

def call_e(func_str, *arg_exps)
  FuncCallExp.new(func_str, arg_exps)
end

#func(func_str, ret_type_annot = nil, &block) ⇒ Object



13
14
15
16
17
# File 'lib/sfrp/poly/dsl.rb', line 13

def func(func_str, ret_type_annot = nil, &block)
  fp = FuncProxy.new(func_str, ret_type_annot)
  block.call(fp) if block
  fp.to_func
end

#match_e(left_exp, &block) ⇒ Object



33
34
35
36
37
# File 'lib/sfrp/poly/dsl.rb', line 33

def match_e(left_exp, &block)
  cp = CaseProxy.new
  block.call(cp) if block
  MatchExp.new(left_exp, cp.to_a)
end

#node(node_str, type_annot = nil, &block) ⇒ Object



19
20
21
22
23
# File 'lib/sfrp/poly/dsl.rb', line 19

def node(node_str, type_annot = nil, &block)
  np = NodeProxy.new(node_str, type_annot)
  block.call(np) if block
  np.to_node
end

#pany(ref_var_str = nil) ⇒ Object



59
60
61
# File 'lib/sfrp/poly/dsl.rb', line 59

def pany(ref_var_str = nil)
  Pattern.new(nil, ref_var_str, [])
end

#pat(vconst_str, *arg_patterns) ⇒ Object



51
52
53
# File 'lib/sfrp/poly/dsl.rb', line 51

def pat(vconst_str, *arg_patterns)
  Pattern.new(vconst_str, nil, arg_patterns)
end

#pref(vconst_str, ref_var_str, *arg_patterns) ⇒ Object



55
56
57
# File 'lib/sfrp/poly/dsl.rb', line 55

def pref(vconst_str, ref_var_str, *arg_patterns)
  Pattern.new(vconst_str, ref_var_str, arg_patterns)
end

#t(tconst_str, *args) ⇒ Object



25
26
27
# File 'lib/sfrp/poly/dsl.rb', line 25

def t(tconst_str, *args)
  TypeAnnotationType.new(tconst_str, args)
end

#tconst(tconst_str, var_strs, static, native_str, infinite, &block) ⇒ Object



6
7
8
9
10
11
# File 'lib/sfrp/poly/dsl.rb', line 6

def tconst(tconst_str, var_strs, static, native_str, infinite, &block)
  tp = TConstProxy.new(tconst_str, var_strs, infinite)
  block.call(tp) if block
  argc = var_strs.size
  TConst.new(tconst_str, argc, tp.vconst_strs, static, native_str)
end

#tv(var_str) ⇒ Object



29
30
31
# File 'lib/sfrp/poly/dsl.rb', line 29

def tv(var_str)
  TypeAnnotationVar.new(var_str)
end

#v_e(var_str) ⇒ Object



47
48
49
# File 'lib/sfrp/poly/dsl.rb', line 47

def v_e(var_str)
  VarRefExp.new(var_str)
end

#vc_call_e(vconst_str, *arg_exps) ⇒ Object



43
44
45
# File 'lib/sfrp/poly/dsl.rb', line 43

def vc_call_e(vconst_str, *arg_exps)
  VConstCallExp.new(vconst_str, arg_exps)
end