Class: Sith::BaseMacro

Inherits:
Object
  • Object
show all
Defined in:
lib/sith/macro.rb

Direct Known Subclasses

Macro, MacroMapper

Instance Method Summary collapse

Instance Method Details

#expand_macro(nodes) ⇒ Object



21
22
23
24
25
# File 'lib/sith/macro.rb', line 21

def expand_macro(nodes)
  a = expand_to_source(nodes)

  Parser::CurrentRuby.parse a
end

#represent(node) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/sith/macro.rb', line 5

def represent(node)
  return node.to_s unless node.is_a?(Parser::AST::Node) || node.is_a?(Array)

  if node.is_a?(Array)
    "#{node.map(&method(:represent)).join(', ')}"
  elsif node.type == :int
    node.children[0].to_s
  elsif node.type == :string
    node.children[0]
  elsif :send
    node.children[1].to_s
  else
    '?'
  end
end