String Parsing: Finite State Machine

Validate an identifier step by step using states, character classes, and explicit transitions.

Rule: the first character must be a letter or underscore.

Current State

Step Explanation

Input Scan

Transition Table

Current StateCharacter ClassNext State
STARTLETTERIN_ID
STARTUNDERSCOREIN_ID
STARTDIGITREJECT
STARTOTHERREJECT
IN_IDLETTERIN_ID
IN_IDDIGITIN_ID
IN_IDUNDERSCOREIN_ID
IN_IDOTHERREJECT