minerbot/choose_parser.py

28 lines
658 B
Python

testString = 'say "Jasper Oxide" "Are you really that stupid?"'
def parse(text,debug=False):
lines = [text.rstrip()]
result = []
for line in lines:
linetable = []
words = line.split(" ")
i=0
while i < len(words):
if words[i].startswith('"'):
if words[i].endswith('"'):
linetable.append(words[i][1:-1])
i = i + 1
continue
part = words[i][1:]
i=i+1
while not words[i].endswith('"'):
part = part + " " + words[i]
i = i + 1
part = part + " " + words[i][:-1]
linetable.append(part)
else:
part = words[i]
linetable.append(part)
i = i + 1
result.append(linetable)
return result[0][1:]