Given a string representing a code snippet, implement a tag validator to parse the code and return whether it is valid. A code snippet is valid if all the following rules hold:
- The code must be wrapped in a valid closed tag. Otherwise, the code is invalid.
- A closed tag (not necessarily valid) has exactly the following format : TAGCONTENT. Among them, is the start tag, and is the end tag. The TAG\NAME in start and end tags should be the same. A closed tag is valid if and only if the TAG\NAME and TAG\CONTENT are valid.
- A valid TAGNAME only contain upper-case letters, and has length in range 1,9. Otherwise, the TAGNAME is invalid.
- A valid TAGCONTENT may contain other valid closed tags, cdata and any characters (see note1) EXCEPT unmatched .