4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/praat_parser.rb', line 4
def parse input
output = Praat::Root.new
@current_node = output
@current_indent = 0
input.each do |item|
begin
case item.shift
when :indent
process_indent item
when :collection
@current_node.add_property "#{item.first}s", create_collection(item.first)
@current_node = @current_node.send("#{item.first}s")
when :object
@current_node << create_object(item.first)
@current_node.last.parent = @current_node
@current_node = @current_node.last
when :property
@current_node.add_property(*item)
end
rescue Exception => ex
puts
print "item: #{item}\n"
print "current node: #{@current_node}\n"
raise ex
end
end
output
end
|