Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The Stop Statement

Stop provides an early exit from a loop or conditional block.

Example:

While (I < 10)
{
    If (I == 5)
    {
        Stop;
    }

    I = I + 1;
}

The semantic analyzer currently enforces these rules:

  • Stop cannot be used inside Main
  • Stop must be inside a loop or If statement

In the compiler, Stop is represented as Statement::Stop in src/ast.rs.

The semantic checks are implemented in src/semantic.rs.

Code generation is handled by FunctionCompiler::compile_statement in src/codegen.rs.

Stop is not an exception mechanism. It represents a structured early exit.


← Previous Next →