2.10.1 How it works
Lexical analysis splits the text into pieces. If it finds something that cannot be any piece, it emits a lexical error pointing at exactly that fragment. There are three situations:
| Situation | Diagnostic |
|---|---|
A character that does not belong to the language, such as @ | unrecognizedCharacter |
| An unknown escape inside a text | invalidEscapeSequence |
| Quotes that are never closed | unterminatedString |
When it can delimit the guilty fragment, the engine keeps reading to find more errors in the same pass. What it never does is invent a value or run a program with lexical errors.
A Write statement with an at sign between two texts. The at sign is marked in red and an arrow joins it to the diagnostic unrecognizedCharacter. Another arrow shows that the engine keeps reading; a dashed box recalls that no semantic analysis is done.
ProgramA character that does not exist in the language
Algorithm Arroba
Write "correo" @ "dominio";
EndAlgorithmDiagnostics
unrecognizedCharacter· error · 2:18 · Unrecognized character: @
The program finishes with an error.
There is a single diagnostic: the engine discards the @ and does not report errors caused by the gap it leaves, such as a missing semicolon.
In short
- Three lexical errors: unknown character, invalid escape and unclosed text.
- The diagnostic points at the exact fragment.
- With lexical errors there is no semantic analysis or execution.