
intermediate
10 min read
String to Integer (atoi)
A reliable atoi parser is a small state machine: skip leading spaces, read one optional sign, consume one numeric prefix, and guard every accumulator…
View solutionTranslate a textual grammar or staged input contract into explicit phases, flags, or state transitions that determine which characters or tokens are legal next.
Tagged articles
2 articles in this tag.

A reliable atoi parser is a small state machine: skip leading spaces, read one optional sign, consume one numeric prefix, and guard every accumulator…
View solution
A decimal point and an exponent are easy to track. The hard part is proving that every numeric component actually contains the digits the grammar requires.
View solution