Skip to content

SpecificationII · Lexical structure

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.

Markdown version

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.A semicolon at the end of every simple statement; none on the opening and closing lines of a block.

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.

ProgramWhere the semicolon goes

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

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.

In short

  • Simple statements end with ;.
  • Block openings and closings do not.
  • Several statements are allowed on one line.