Parser: refactored code to make it shorter and cleaner.

* Added methods consume() and requireOpening().