Simplify code

is_nesting_open returns a boolean with a equation value a true or false.
valid_close was using similar if statements I replaced all by a simple switch-case statement.
This makes the condition arguably harder to read.  The -1 is a special case, gets lots when tagged on then end of an already far too long condition.