Augmented Backus–Naur formIn computer science, augmented Backus–Naur form (ABNF) is a metalanguage based on Backus–Naur form (BNF) but consisting of its own syntax and derivation rules. The motive principle for ABNF is to describe a formal system of a language to be used as a bidirectional communications protocol. It is defined by Internet Standard 68 ("STD 68", type case sic), which as of December 2010[update] was RFC 5234, and it often serves as the definition language for IETF communication protocols.[1][2] RFC 5234 supersedes RFC 4234, 2234 and 733.[3] RFC 7405 updates it, adding a syntax for specifying case-sensitive string literals. Overview![]() An ABNF specification is a set of derivation rules, written as rule = definition; comment CR LF
where rule is a case-insensitive nonterminal, the definition consists of sequences of symbols that define the rule, a comment for documentation, and ending with a carriage return and line feed. Rule names are case-insensitive: Angle brackets ( Terminal valuesTerminals are specified by one or more numeric characters. Numeric characters may be specified as the percent sign Literal text is specified through the use of a string enclosed in quotation marks ( OperatorsWhite spaceWhite space is used to separate elements of a definition; for space to be recognized as a delimiter, it must be explicitly included. The explicit reference for a single whitespace character is Definitions are left-aligned. When multiple lines are required (for readability), continuation lines are indented by whitespace. Comment
A semicolon ( Concatenation
A rule may be defined by listing a sequence of rule names. To match the string “aba”, the following rules could be used:
Alternative
A rule may be defined by a list of alternative rules separated by a solidus ( To accept the rule fu or the rule bar, the following rule could be constructed:
Incremental alternatives
Additional alternatives may be added to a rule through the use of The rule
is therefore equivalent to
Value range
A range of numeric values may be specified through the use of a hyphen ( The rule
is equivalent to
Sequence group
Elements may be placed in parentheses to group rules in a definition. To match "a b d" or "a c d", the following rule could be constructed:
To match “a b” or “c d”, the following rules could be constructed:
Variable repetition
To indicate repetition of an element, the form Use Specific repetition
To indicate an explicit number of elements, the form Use Optional sequence
To indicate an optional element, the following constructions are equivalent:
Operator precedenceThe following operators have the given precedence from tightest binding to loosest binding:
Use of the alternative operator with concatenation may be confusing, and it is recommended that grouping be used to make explicit concatenation groups. Core rules![]() The core rules are defined in the ABNF standard.
Note that in the core rules diagram the CHAR2 charset is inlined in char-val and CHAR3 is inlined in prose-val in the RFC spec. They are named here for clarity in the main syntax diagram. ExampleThe (U.S.) postal address example given in the augmented Backus–Naur form (ABNF) page may be specified as follows: postal-address = name-part street zip-part
name-part = *(personal-part SP) last-name [SP suffix] CRLF
name-part =/ personal-part CRLF
personal-part = first-name / (initial ".")
first-name = *ALPHA
initial = ALPHA
last-name = *ALPHA
suffix = ("Jr." / "Sr." / 1*("I" / "V" / "X"))
street = [apt SP] house-num SP street-name CRLF
apt = 1*4DIGIT
house-num = 1*8(DIGIT / ALPHA)
street-name = 1*VCHAR
zip-part = town-name "," SP state 1*2SP zip-code CRLF
town-name = 1*(ALPHA / SP)
state = 2ALPHA
zip-code = 5DIGIT ["-" 4DIGIT]
PitfallsRFC 5234 adds a warning in conjunction to the definition of LWSP as follows:
References
|
Portal di Ensiklopedia Dunia