Sounds promising. Has it been done in practice?
What is you function doing on the else?
What is the while loop doing?
Where is parse() defined?