Skip to content

SpecificationII · Lexical structure

2.4

Identifiers

An identifier is the name you choose for a variable, a subroutine or a type: it starts with a letter or an underscore and distinguishes upper case, lower case and accents.

Markdown version

2.4.1 How it works

An identifier starts with a letter (including ñ, accented vowels and ü) or an underscore. After that it may continue with letters, digits or underscores. A single-letter name is valid.

Figure 2.4-1.What may go at the start of a name and what may follow. Digits may follow, never start.

Two boxes joined by an arrow: the first character, which may be a letter, ñ, an accented vowel or an underscore, and the following ones, which also accept digits and may repeat. Below, four valid names in green and three invalid ones in red.

Names are compared exactly: edad and Edad are two different variables, just like ano and año. Reserved words, on the other hand, ignore case: writing them in lower or upper case makes no difference.

ProgramNames that look alike

Algorithm Nombres
  Define edad As Integer <- 1;
  Define Edad As Integer <- 2;
  Define año As Integer <- 2026;
  Define _total1 As Integer <- edad + Edad;
  Write edad, " ", Edad, " ", año, " ", _total1;
EndAlgorithm

Output

1 2 2026 3

The program finishes normally.

In short

  • Starts with a letter or underscore; continues with letters, digits or underscores.
  • ñ, accents and ü are allowed.
  • Names distinguish case and accents; reserved words ignore case.