Skip to content

SpecificationII · Lexical structure

2.8

Operators and signs

Operators and signs are the pieces made of symbols, such as +, <= or <-; the engine always reads the longest possible piece.

Markdown version

2.8.1 How it works

Besides words, the language has pieces made of symbols:

FamilySigns
Assignment<-
Arithmetic+ - * / ^
Comparison= <> < <= > >=
Grouping and access( ) [ ] .
Separators, ; :

When two pieces could overlap, the engine chooses the longest one. That is why x<-1 reads as x, <- and 1 (an assignment), while x < -1 reads as x, <, - and 1 (a comparison with a negative number).

Figure 2.8-1.The same symbols, split differently, are different pieces. The space decides.

At the top, x stuck to the arrow and the 1 splits into x, the assignment arrow and 1: an assignment. Below, with spaces, it splits into x, less than, minus and 1: a comparison.

ProgramAssigning is not comparing

Algorithm Flecha
  Define x As Integer <- 5;
  x<-1;
  Write x;
  Write x < -1;
  Write x = 1;
EndAlgorithm

Output

1
false
true

The program finishes normally.

The assignment <- and the comparison = are different operators: <- stores a value, = asks whether two values are equal.

In short

  • Symbol pieces form operators and signs.
  • The engine always chooses the longest piece.
  • <- assigns; = compares.