Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
“content”: “
International standard CAN/CSA-ISO/IEC 14977-02, an identical adoption of ISO/IEC 14977:1996, establishes a formal notation for defining the syntax of programming languages, document formats, and communication protocols. This notation, widely recognized as Extended Backus-Naur Form (EBNF), provides a compact and unambiguous syntactic metalanguage. For standardization committees, language designers, and compiler engineers, it serves as a precise tool for documenting and communicating grammatical structures without ambiguity.
The primary purpose is to define a standardized metalanguage for specifying the syntax of object languages. It replaces informal, ad-hoc grammar descriptions with a formal system that is both highly readable by humans and machine-processable by parser generators and analysis tools.
Standard BNF relies heavily on recursion and auxiliary non-terminals to express repetition and optionality. EBNF introduces distinct operators, making grammars significantly shorter and more intuitive.
| Feature | Basic BNF Approach | EBNF (CAN/CSA-ISO/IEC 14977-02) |
|---|---|---|
| Zero or More (Repetition) | Recursive rule | { ... } |
| Zero or One (Option) | Auxiliary production | [ ... ] |
| Grouping | New non-terminal | ( ... ) |
| Exclusion | Not formally available | - (Exception) |
| Rule Definition | ::= | = |
-) is a powerful but often misunderstood feature of this standard. For example, letter - 'Q' matches any letter except Q. Its semantics are strictly defined based on the longest-match principle for string ordering.A grammar compliant with CAN/CSA-ISO/IEC 14977 must use the exact symbols defined in the standard. The following table summarizes the complete set of primary constructs:
| Construct | Notation | Example | Semantics |
|---|---|---|---|
| Definition | = | digit = ... ; | Assigns a name to a syntactic category. |
| Termination | ; | ; | Marks the end of a syntax rule. |
| Concatenation | , | letter , digit | Specifies a sequence of symbols. |
| Alternation | | | '0' | '1' | Indicates a choice between alternatives. |
| Option | [ ... ] | [ '+' ] | Zero or one occurrence. |
| Repetition | { ... } | { digit } | Zero or more occurrences. |
| Grouping | ( ... ) | ( 'a' | 'b' ) | Controls the scope of operators. |
| Exception | - | letter - 'W' | Excludes a specific string from a set. |
| Comment | (* ... *) | (* comment *) | Provides annotation for the grammar writer. |
| Special Sequence | ? ... ? | ? platform check ? | Indicates context-dependent constructs. |
When implementing a grammar specification under this standard, careful attention must be paid to the lexical structure of the metalanguage itself. Non-terminal names must be sequences of letters, digits, and hyphens. Terminal strings are enclosed in single ('...') or double ("...") quotes. The standard explicitly defines the syntax of the metalanguage in its own formalism, allowing for rigorous self-validation.
(* Simple Integer Syntax *) This example demonstrates how EBNF uses operators to concisely define an integer. The [ '+' | '-' ] handles the optional sign, while { digit } specifies the repetition of digits.
;). This is a frequent compliance pitfall for writers migrating from non-standard EBNF dialects, which might omit explicit terminators or use a period (.).CAN/