use state pattern for id4 parser