# File /home/ser/Work/Pyx/MyoPyx.rb, line 31
 def parse( reader )
		tags = []
		current_tag = nil
		listeners = nil
		all_list = @listeners[ ' ' ]
		text = ""
		attributes = nil

		reader.each do |line|
			line.chop!
			text = line[1..-1] if line.size > 1
			next if line.strip.size == 0
			if line[0] != ?A and attributes
				if current_tag != nil
					all_list.each{|list| list.start_element(current_tag, attributes)} if all_list
					listeners.each{|list| list.start_element(current_tag, attributes)} if listeners
				end
				attributes = nil
			end

			case line[0]
			when ?(
				attributes = {}
				tags << current_tag if current_tag != nil
				current_tag = text
				listeners = @listeners[current_tag]
			when ?)
				raise "Parse error at line #$.\n"+
					"Expected end tag '#{current_tag}' but "+
					"got end tag '#{text}'\n"+
					"Line: '#{line}'\n" if text != current_tag
				all_list.each{|list| list.end_element(current_tag)} if all_list
				listeners.each{|list| list.end_element(current_tag)} if listeners
				listeners = nil
				current_tag = nil
				if tags.size > 0
					current_tag = tags.pop
					listeners = @listeners[ current_tag ]
				end
			when ?A
				text[/(.*?) (.*)/]
				attributes[$1] = $2
			when ?-
				all_list.each{|list| list.text text} if all_list
				listeners.each{|list| list.text text} if listeners
			when ??
				@pi_listeners.each{|list| list.pi text}
			else
				raise "Parse exception at line #$.\n"+
					"Bad markup\n"+
					"Line: '#{line}'\n"
			end
		end
	end