regular-state::process (config) { if (self->accepts) { # memo config->remember-accept-position config->remember-accept-type (self->type) } config->advance-input # advance } error-state::process (config) { push (output-queue, token { # token type = config->accepted-type value = config->accepted-string }) config->rewind-input # rewind } error-state::transition-for (char) { return (start) # restart-1 } start-state::process (config) { config->remember-starting-position # restart-2 } state = start while (config->has-more-input) { state->process (config) state = state->transition-for (config->current-input-char) || error-state # move }