Apologies if this is answered elsewhere; couldn\'t find enough information to convince myself of the best way to do this. I also realize this is a lengthy explanation with no co
I would first consider the following points :
Are your state components (WAITING_FOR_COMMAND, COMMAND_RECEIVED etc )central to your application logic ? That is to say , does it really matter a lot what state the parser is in , and what state it transitions to , for the app to work correctly ? What are the values that each of the state is going to hold ? Do these values differ greatly from one state to another ? If your answers are yes , then probably you have a valid case for State pattern.But I have often seen state machines used in places where it was simply an overkill.
Your use-case seems more like in need of Command pattern and an Interpreter pattern ( as it seems you are writing a grammar ).