Solution and specs for problem of checking for matching parentheses and curly braces in a line of text