First draft for parsing algorithm.
Changed test case to sixth question for better testability.