Skip to content

Instantly share code, notes, and snippets.

View nickrolfe's full-sized avatar

Nick Rolfe nickrolfe

  • GitHub Staff
  • Oxford, UK
  • X @nckrlf
View GitHub Profile
@pervognsen
pervognsen / shift_dfa.md
Last active April 21, 2025 19:59
Shift-based DFAs

A traditional table-based DFA implementation looks like this:

uint8_t table[NUM_STATES][256]

uint8_t run(const uint8_t *start, const uint8_t *end, uint8_t state) {
    for (const uint8_t *s = start; s != end; s++)
        state = table[state][*s];
    return state;
}