Statement (computer science)

Many programming languages (e.g. Ada, Algol 60, C, Java, Pascal) make a distinction between statements and definitions/declarations.

Apart from assignments and subroutine calls, most languages start each statement with a special word (e.g. goto, if, while, etc.)

Various methods have been used to describe the form of statements in different languages; the more formal methods tend to be more precise: BNF uses recursion to express repetition, so various extensions have been proposed to allow direct indication of repetition.

Some programming language grammars reserve keywords or mark them specially, and do not allow them to be used as identifiers.

Fortran and PL/1 do not have reserved keywords, allowing statements like: In Algol 60 and Algol 68, special tokens were distinguished explicitly: for publication, in boldface e.g. begin; for programming, with some special marking, e.g., a flag ('begin), quotation marks ('begin'), or underlined (begin on the Elliott 503).

Tokens that are part of the language syntax thus do not conflict with programmer-defined names.

The standards documents for many programming languages use BNF or some equivalent to express the syntax/grammar in a fairly formal and precise way, but the semantics/meaning of the program is generally described using examples and English prose.

Some approaches effectively define an interpreter for the language, some use formal logic to reason about a program, some attach affixes to syntactic entities to ensure consistency, etc.

A notable example of this is Python, where = is not an operator, but rather just a separator in the assignment statement.