So separate the steps,
- read characters until you reach >
- push the resulting string onto a stack.

This should be a trivial problem compared to the rest of the task.