builds a state machine based off a simple grammar using a LR canonical parse