state->start
input->remember-starting-position
while (input->has-more) {
if (state->attempt-transition-for (input->current-char)) { # move
if (state->accepts) { # memo
last-accept-state = state
input->remember-accept-position
}
input->advance # advance
} else {
push (output-queue, token { # token
type = last-accept-state->type
value = input->last-accepted-string
})
input->rewind # rewind
state = start # restart
input->remember-starting-position
}
}
####
state->start
while (config->has_more_input) {
if (state->attempt_transition_for(config->current_input)) { # move
config->remember(state->type) if state->accepts # memo
config->input->advance # advance
} else {
config->rewind # rewind
push (output_queue, token { # token
type = config->type
value = config->string
})
state->start # restart
}
}
####
config->start
while (config->has_more_input) {
if (config->state->attempt_transition) { # move + advance
config->remember if config->state->accepts # memo
} else {
config->rewind # rewind + restart
push output_queue, config->token # token
}
}