What does a double colon followed by an equals sign (::=) mean in programming documentation?

Language AgnosticSymbols

Language Agnostic Problem Overview


What does ::= mean in programming documentation?
For example in the Lua documentation: or in Python documentation.

Language Agnostic Solutions


Solution 1 - Language Agnostic

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 (::=).

Solution 2 - Language Agnostic

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.

Solution 3 - Language Agnostic

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).

Solution 4 - Language Agnostic

The given element syntax. For example:

identifier ::=  (letter|"_") (letter | digit | "_")*

Means all identifiers must conform to the given syntax rule.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCharles HolbrowView Question on Stackoverflow
Solution 1 - Language AgnosticsoulcheckView Answer on Stackoverflow
Solution 2 - Language AgnosticmartinegView Answer on Stackoverflow
Solution 3 - Language AgnosticNPEView Answer on Stackoverflow
Solution 4 - Language Agnosticm0skit0View Answer on Stackoverflow