def TXT.parse(input)
in_escaped = false
in_string = false
count = -1
strings = []
current_binary = ""
current_quote_char = '"'
unquoted = false
seen_strings = false
pos = 0
input.sub!(/^\s*\(\s*/, "")
input.sub!(/\s*\)\s*$/, "")
input.each_char {|c|
if (((c == "'") || (c == '"')) && (!in_escaped) && (!unquoted))
if (!in_string)
seen_strings = true
current_quote_char = c
in_string = true
count+=1
strings[count] = ""
else
if (c == current_quote_char)
in_string = false
else
strings[count]+=c
end
end
else
if (seen_strings && !in_string)
next
end
if (pos == 0)
unquoted = true
count+=1
strings[count] = ""
elsif (unquoted)
if (c == " ")
count+=1
strings[count] = ""
pos += 1
next
end
end
if (c == "\\")
if (in_escaped)
in_escaped = false
strings[count]+=(c)
else
in_escaped = true
end
else
if (in_escaped)
if (c == ";") || (c == '"')
strings[count]+=c
in_escaped = false
elsif (ESCAPE_CHARS[c])
in_escaped=false
strings[count]+=ESCAPE_CHARS[c].chr
elsif (c<"0" || c>"9")
in_escaped = false
strings[count]+=c
else
current_binary += c
if ((current_binary.length == 3) )
strings[count]+=current_binary.to_i.chr
in_escaped = false
current_binary = ""
end
end
else
strings[count]+=(c)
end
end
end
pos += 1
}
return strings
end