Tactable interview question

Simple algorithm implementation that could evolve into building Abstract Syntax Tree.