Augmented Backus–Naur Form

Augmented Backus–Naur Form

In 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), which as of May 2008 is RFC 5234, and it often serves as the definition language for IETF communication protocols.cite web
url= http://www.rfc-editor.org/rfcxx00.html
title= "Official Internet Protocol Standards"
accessdate= 2008-05-26
date= 2008-05-26
publisher= RFC Editor
] cite web
url= ftp://ftp.rfc-editor.org/in-notes/std/std68.txt
title= "Augmented BNF for Syntax Specifications: ABNF"
accessdate= 2008-05-26
last= Crocker
first= D.
coauthors= Overell, P.
year= 2008
month= January
format= plain text
work=
publisher= RFC Editor
pages= 16
]

RFC 5234 supersedes RFC 4234 (which superseded RFC 2234).cite web
url= http://www.rfc-editor.org/rfc-index2.html
title= "RFC Index"
accessdate= 2008-05-26
date= 2008-05-25
publisher= RFC Editor
]

Introduction

An ABNF specification is a set of derivation rules, written as

rule = definition ; comment CR LF

where rule is a case-sensitive 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: , , , and all refer to the same rule. Rule names consist of a letter followed by letters, numbers, and hyphens.

Angle brackets (“<”, “>”) are not required around rule names (as they are in BNF). However they may be used to delimit a rule name when used in prose to discern a rule name.

ABNF is encoded in ASCII (which is seven bits) in an eight-bit field with the high bit set to zero.

Terminal values

Terminals are specified by one or more numeric characters.

Numeric characters may be specified as the percent sign “%”, followed by the base (b = binary, d = decimal, and x = hexadecimal), followed by the value, or concatenation of values (indicated by “.”). For example a carriage return is specified by %d13 in decimal or %x0D in hexadecimal. A carriage return followed by a line feed may be specified with concatenation as %d13.10.

Literal text is specified through the use of a string enclosed in quotation marks ("). These strings are case-insensitive and the character set used is (US-)ASCII. Therefore the string “abc” will match “abc”, “Abc”, “aBc”, “abC”, “ABc”, “AbC”, “aBC”, and “ABC”. For a case-sensitive match the explicit characters must be defined: to match “aBc” the definition will be %d97 %d66 %d99.

Operators

White space

White space is used to separate elements of a definition; for space to be recognized as a delimiter it must be explicitly included.

Concatenation

Rule1 Rule2

A rule may be defined by listing a sequence of rule names.

To match the string “aba” the following rules could be used:
#fu = %x61 ; a
#bar = %x62 ; b
#mumble = fu bar fu

Alternation

Rule1 / Rule2

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:
#fubar = fu / bar

Incremental alternatives

Rule1 =/ Rule2

Additional alternatives may be added to a rule through the use of “=/” between the rule name and the definition.

The rule
#ruleset = alt1 / alt2 / alt3 / alt4 / alt5is equivalent to
#ruleset = alt1 / alt2
#ruleset =/ alt3
#ruleset =/ alt4 / alt5

Value range

%c##-##

A range of numeric values may be specified through the use of a hyphen (“-”).

The rule
#OCTAL = "0" / "1" / "2" / "3" / "4" / "5" / "6" / "7"is equivalent to
#OCTAL = %x30-37

equence group

(Rule1 Rule2)

Elements may be placed in parentheses to group rules in a definition.

To match “elem fubar snafu” or “elem tarfu snafu” the following rule could be constructed:
#group = elem (fubar / tarfu) snafu

To match “elem fubar” or “tarfu snafu” the following rules could be constructed:
#group = elem fubar / tarfu snafu
#group = (elem fubar) / (tarfu snafu)

Variable repetition

n*nRule

To indicate repetition of an element the form &lt;a&gt;*&lt;b&gt;element is used. The optional &lt;a&gt; gives the minimum number of elements to be included with the default of 0. The optional &lt;b&gt; gives the maximum number of elements to be included with the default of infinity.

Use *element for zero or more elements, 1*element for one or more elements, and 2*3element for two or three elements.

pecific repetition

nRule

To indicate an explicit number of elements the form &lt;a&gt;element is used and is equivalent to &lt;a&gt;*&lt;a&gt;element.

Use 2DIGIT to get two numeric digits and 3DIGIT to get three numeric digits. (DIGIT is defined below under 'Core rules'. Also see "zip-code" in the example below.)

Optional sequence

[Rule]

To indicate an optional element the following constructions are equivalent:
# [fubar snafu]
#*1(fubar snafu)
#0*1(fubar snafu)

Comment

; comment

A semicolon (“;”) starts a comment that continues to the end of the line.

Operator precedence

The following operators have the given precedence from tightest binding to loosest binding:
#Strings, Names formation
#Comment
#Value range
#Repetition
#Grouping, Optional
#Concatenation
#Alternative

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.

Example

The postal address example given in the Backus–Naur Form (BNF) page may be specified as follows:

postal-address = name-part street zip-part

name-part = *(personal-part SP) last-name [SP suffix] CRLFname-part =/ personal-part CRLF

personal-part = first-name / (initial ".")first-name = *ALPHAinitial = ALPHAlast-name = *ALPHAsuffix = ("Jr." / "Sr." / 1*("I" / "V" / "X"))

street = [apt SP] house-num SP street-name CRLFapt = 1*4DIGIThouse-num = 1*8(DIGIT / ALPHA)street-name = 1*VCHAR

zip-part = town-name "," SP state 1*2SP zip-code CRLFtown-name = 1*(ALPHA / SP)state = 2ALPHAzip-code = 5DIGIT ["-" 4DIGIT]

Pitfalls

[http://www.ietf.org/rfc/rfc5234.txt RFC 5234] adds a warning in conjunction to the definition of LWSP as follows: ; Use of this linear-white-space rule ; permits lines containing only white ; space that are no longer legal in ; mail headers and have caused ; interoperability problems in other ; contexts. ; Do not use when defining mail ; headers and use with caution in ; other contexts.

References


Wikimedia Foundation. 2010.

Игры ⚽ Нужна курсовая?

Look at other dictionaries:

  • Augmented Backus-Naur Form — ABNF (Augmented Backus Naur form) est une extension du métalangage BNF, adaptée aux besoin de la normalisation sur Internet. ABNF est le langage standard à l IETF pour décrire un langage dans les RFC. Il est très proche de l EBNF mais s en… …   Wikipédia en Français

  • Backus-Naur form — Saltar a navegación, búsqueda El Backus Naur form (BNF) (también conocido como Backus Naur formalism, Backus normal form o Panini Backus Form) es una metasintaxis usada para expresar gramáticas libres de contexto: es decir, una manera formal de… …   Wikipedia Español

  • Augmented Backus-Naur fForm — Augmented Backus Naur Form ABNF (Augmented Backus Naur form) est une extension du métalangage BNF, adaptée aux besoin de la normalisation sur Internet. ABNF est le langage standard à l IETF pour décrire un langage dans les RFC. Il est très proche …   Wikipédia en Français

  • Extended Backus–Naur Form — In computer science, Extended Backus–Naur Form (EBNF) is a metasyntax notation used to express context free grammars: that is, a formal way to describe computer programming languages and other formal languages. It is an extension of the basic… …   Wikipedia

  • Backus–Naur Form — In computer science, Backus–Naur Form (BNF) is a metasyntax used to express context free grammars: that is, a formal way to describe formal languages. John Backus and Peter Naur developed a context free grammar to define the syntax of a… …   Wikipedia

  • Angereicherte Backus-Naur-Form — Die angereicherte Backus Naur Form (ABNF, engl. augmented BNF) ist eine Variante der Backus Naur Form Metasprache zur Beschreibung von Syntax Notationen. Sie wurde ursprünglich als RFC 2234 zur eindeutigen Spezifikation von RFC Internet Standards …   Deutsch Wikipedia

  • Notación de Backus-Naur — La notación de Backus Naur, también conocida por sus denominaciones inglesas Backus Naur form (BNF), Backus Naur formalism o Backus normal form, es una metasintaxis usada para expresar gramáticas libres de contexto: es decir, una manera formal de …   Wikipedia Español

  • ABNF — Augmented Backus Naur Form ABNF (Augmented Backus Naur form) est une extension du métalangage BNF, adaptée aux besoin de la normalisation sur Internet. ABNF est le langage standard à l IETF pour décrire un langage dans les RFC. Il est très proche …   Wikipédia en Français

  • ABNF — Augmented Backus Naur Form (RFC 2234) …   Acronyms

  • ABNF — Augmented Backus Naur Form (RFC 2234) …   Acronyms von A bis Z

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”