Implementation of CSS4 subject selector, need guidance

Scratching my own itch here, but I have a partial implementation of CSS4's subject selectors. If you'll have my code, I would like some guidance on finishing it and cleaning it up.

Thanks.