Reputation: 4231
What does ::=
mean in programming documentation?
For example in the Lua documentation: or in Python documentation.
Upvotes: 71
Views: 39053
Reputation: 679
This is BNF notation that is used to describe the syntax or semantics of different language elements in programming language. To give you an example, in Transact-SQL this BNF notation is used to define what expression
is or how expression
is defined:
<expression> ::=
{
constant
| scalar_function
| column
| variable
| ( expression )
| { unary_operator } expression
| expression { binary_operator } expression
}
"|" symbol is used to indicate that we have to make single choice from available options. You can think of BNF system as meta-language that is used to describe some other language e.g. SQL, Python or C etc.
Upvotes: 0
Reputation: 1359
This is Backus-Naur Form (BNF) notation describing the language. ::=
in this context means is defined as.
For example, in the Python language documentation you refer to, an identifier is defined as a letter or an underscore, followed by a letter, a digit or an underscore. The notation then goes on to describe what a letter and a digit is defined as, and so on.
Upvotes: 22
Reputation: 36767
It symbolizes 'symbol derivation rule' in Backus–Naur Form
Meaning that in:
<symbol> ::= __expression__
nonterminal <symbol>
consists of (is defined as, is constructed from, derives from) __expression__
It's used to describe language grammars.
Notice that both examples are in Extended Backus–Naur Form, but using a traditional BNF symbol-expression separator (::=
).
Upvotes: 66
Reputation: 500257
As others have already said, it's part of the BNF notation. Wikipedia has an explanation and some examples, which I won't repeat here.
The history and evolution of the ::=
symbol itself is explained in The History of the ALGOL Effort (p29 onwards).
Upvotes: 7
Reputation: 25873
The given element syntax. For example:
identifier ::= (letter|"_") (letter | digit | "_")*
Means all identifiers must conform to the given syntax rule.
Upvotes: 5