# 2.9 Statement end

> Every simple statement ends with a semicolon; the words that open and close blocks, such as `If` or `EndWhile`, do not.

Web page: https://pseudolearn.app/en/spec/lexico/fin-de-sentencia

> **In one sentence**
>
> Every simple statement ends with a semicolon; the words that open and close blocks, such as `If` or `EndWhile`, do not.

## 2.9.1 How it works

A **simple statement** is an instruction that contains no others: defining, assigning, writing, reading, calling or returning. Each one ends with `;`, including the last one before a closing word.

**Compound statements** contain others inside: `If`, `Switch`, `While`, `Repeat`, `For`. Their opening and closing lines have no semicolon; the simple statements inside do.

**Figure 2.9-1: Where the semicolon goes**

A While block with two statements inside. The two simple statements have a semicolon marked in green; the opening and closing lines have none, marked with an empty-set symbol in red.

A semicolon at the end of every simple statement; none on the opening and closing lines of a block.

### Program: Where the semicolon goes

```pseudolearn
Algorithm Terminacion
  Define i As Integer <- 0;
  While i < 2 Do
    Write "vuelta ", i;
    i <- i + 1;
  EndWhile
  Define a As Integer <- 1; Define b As Integer <- 2;
  Write a + b;
EndAlgorithm
```

**Output**

```text
vuelta 0
vuelta 1
3
```

*The program finishes normally.*

Several statements can share a line if each has its semicolon. Empty lines produce no statement.

> **Common mistakes**
>
> A forgotten semicolon is detected before running and the message points to where it should be:
>
> ### Program: A forgotten semicolon
>
> ```pseudolearn
> Algorithm Olvido
>   Write "uno"
>   Write "dos";
> EndAlgorithm
> ```
>
> **Diagnostics**
> - `missingStatementTerminator` (error, 2:14): Expected a semicolon at the end of the statement
>
> *The program finishes with an error.*

**In short**
- Simple statements end with `;`.
- Block openings and closings do not.
- Several statements are allowed on one line.

**See also**
- [2.2 Spaces and line breaks](https://pseudolearn.app/en/spec/lexico/espacios.md)
- [10.3 Recovery and order](https://pseudolearn.app/en/spec/diagnosticos/recuperacion.md)
