implemented whiles to output syntax tree