10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/introhive_expression_language/iel/parser.rb', line 10
def self.apply_transforms(node)
if node.kind == :list
raise EvaluationError.new("Node can't end with trailing quote", node) if node.value[-1].to_s == "'" node.value.each { |child| apply_transforms(child) }
loop do
match, index = node.value.each_with_index.find { |child, index| child.kind == :symbol && child.value == "'" }
break if match.nil?
if index + 1 < node.value.size after_match = node.value.delete_at(index + 1)
node.value[index] = SexpParser::Node.list([SexpParser::Node.symbol('quote', match.source), after_match], match.source)
end
end
end
end
|