Class: Gisele::Language::ElsifFlattener

Inherits:
Sexpr::Rewriter
  • Object
show all
Defined in:
lib/gisele/language/processors/elsif_flattener.rb

Instance Method Summary collapse

Instance Method Details

#on_else_clause(sexpr) ⇒ Object



28
29
30
# File 'lib/gisele/language/processors/elsif_flattener.rb', line 28

def on_else_clause(sexpr)
  [:else_clause, apply(sexpr.last)]
end

#on_elsif_clause(sexpr) ⇒ Object



21
22
23
24
25
26
# File 'lib/gisele/language/processors/elsif_flattener.rb', line 21

def on_elsif_clause(sexpr)
  base = \
    [:else_clause,
     [:if_st, sexpr[1], apply(sexpr[2])] ]
  base = sexpr(base, sexpr.tracking_markers)
end

#on_if_st(sexpr) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/gisele/language/processors/elsif_flattener.rb', line 6

def on_if_st(sexpr)
  condition, dost, *clauses = sexpr.sexpr_body

  base = [:if_st, condition, dost]
  base = sexpr(base, sexpr.tracking_markers)

  clauses.inject base do |cur_if, clause|
    rw_clause = apply(clause)
    cur_if << rw_clause
    rw_clause.last
  end

  base
end