Skip to main content
Version: Sprint 4

makestates

Declares the states of the Turing machine.

Syntax​

makestates(state1, state2, ...);

Parameters​

  • state1, state2, ...: One or more state names

Examples​

makestates(q0, q1, q2);
makestates(start, accept, reject);
makestates(q0, q1, q2, q3, q4, qaccept, qreject);

Rules​

  • Must declare at least one state
  • State names are case-sensitive (q0 ≠ Q0)
  • Cannot conflict with alphabet symbols
  • No duplicate state names
  • States must be declared before being used in markers or transitions

Naming Conventions​

While any identifier is valid, common conventions include:

  • q0, q1, q2, ... for numbered states
  • start, accept, reject for descriptive names
  • q_accept, q_reject with underscores
  • Prefix with q to distinguish from symbols

Examples​

Valid:

setalpha(0, 1);
makestates(q0, q1, q2);

Invalid - conflicts with alphabet:

setalpha(0, 1);
makestates(q0, 0); ### ERROR: state '0' conflicts with a declared alphabet symbol

Invalid - duplicate state:

makestates(q0, q1, q0); ### ERROR: state 'q0' is already declared

Errors​

  • Empty states: 'makestates' requires at least one state name
  • Alphabet conflict: state 'X' conflicts with a declared alphabet symbol
  • Duplicate state: state 'X' is already declared

See Also​