Skip to content

SpecificationII · Lexical structure

2.1

Source text and encoding

A program is UTF-8 text; the engine reads it character by character and remembers the line and column of each one to point at errors precisely.

Markdown version

2.1.1 How it works

The source text is what you write. PseudoLearn reads it as UTF-8 text, the encoding that lets you write ñ, accents and any other Unicode symbol inside texts and comments.

Every character has a position: its line and its column, counting from 1. When the engine finds a problem, it uses those positions to point at the exact place. Lines can be separated with any of the three usual operating-system conventions; the engine treats them the same.

Figure 2.1-1.Every character has a line and a column. A diagnostic points at a span that starts at one position and ends just before another.

A three-line program on a grid with line numbers on the left and column numbers above. On the second line the x of Write x is highlighted in red, and an arrow joins it to a note explaining that the span starts at line 2, column 12.

Texts keep exactly what you wrote, including characters outside the Latin alphabet:

ProgramUnicode inside a text

Algorithm Saludos
  Write "¡Hola! ¿Qué tal?";
  Write "Ñandú, pingüino, café";
EndAlgorithm

Output

¡Hola! ¿Qué tal?
Ñandú, pingüino, café

The program finishes normally.

2.1.2 Normalisation

In Unicode, some accented letters can be written in two ways: as a single character or as a letter followed by an accent. To compare names, the engine first converts them to the same form, called NFC. That way año is always the same name, however you type it. Quoted texts are not touched.

In short

  • Source text is UTF-8.
  • Every character has a line and a column from 1.
  • Names are compared after normalising to NFC; texts are not modified.