Implement a statemachine and parser