makehalt
Designates a halt state for the computational variant.
Syntax
makehalt(state);
Parameters
state: The name of the state to mark as a halt state
Rules
- Only valid for the
computationalvariant - Not valid for other variants (use
makeaccept/makerejectinstead) - The state must be declared in
makestatesfirst - Multiple halt states are allowed
- Unlike
makeinit, there is no limit on the number of halt states
Behavior
When the machine enters a halt state, it stops execution. The computational variant doesn't distinguish between accept and reject - it simply halts.
Examples
setvariant(computational);
makestates(q0, q1, qhalt);
makeinit(q0);
makehalt(qhalt);
Multiple halt states:
setvariant(computational);
makestates(q0, q1, q2, qhalt1, qhalt2);
makeinit(q0);
makehalt(qhalt1);
makehalt(qhalt2);
Errors
- Wrong variant:
'makehalt' is only valid for the 'computational' variant — use 'makeaccept' or 'makereject' - Undeclared state:
state 'qhalt' is not declared
See Also
- makestates - Declare machine states
- makeinit - Designate the initial state
- makeaccept - Designate an accept state (non-computational)
- makereject - Designate a reject state (non-computational)