Syntax and semantics: spelling and meaning

Concepts explained

Syntax is the set of rules for how code is written. Semantics is what that code means. A board game also has both: the instructions must be readable, and the moves must have agreed effects.

Read one instruction

# language: en
let score = 2 + 3
say score

The syntax uses let, a name, =, and an expression. Its meaning is to calculate five and give that value the name score. The next instruction displays it.

Changing the source language changes words such as let and say. It does not change what addition does. Pliro keeps one meaning behind its localized syntax.

Three kinds of trouble

Situation What went wrong?
A closing quote is missing The source breaks a syntax rule.
A variable name was never declared The name cannot be resolved when checking the program.
The program adds one point when you wanted two The program can run, but its logic does not match your plan.

A parser reads the grammatical structure of code. Other checking stages work out what names refer to. The runtime carries out the checked operations and can still encounter errors such as division by zero.

Try changing 2 + 3 to 2 * 3. The structure is still valid, but the meaning and answer change.

Error messages · Expressions