tech-invite   World Map     

IETF     RFCs     Groups     SIP     ABNFs    |    3GPP     Specs     Glossaries     Architecture     IMS     UICC    |    search     info

ABNF grammars

|   SIP_Messages   |   SIP_URIs   |   SIP_Headers   |   SIP_Private_Headers   |   SIP_Response_Codes   |   SIP_basic_rules   |   SIP_common_rules   |   SDP_Session_Description   |   SDP_Attributes   |   RFC723x_HTTP_1.1   |   RFC3986_Generic_URI   |   RFC3987_IRI   |   RFC5322_IMF   |   RFC4975_MSRP   |   draft2326bis_RTSP_2.0   |   RFC5234_ABNF_Notation   |

Augmented Backus-Naur Form (ABNF) Notation and Rules – RFC 5234

|   Core_Rules   |   Operators   |   Definition   |

RFC 5234 – Appendix B.1

Top


OCTET   =
%x00-FF
;  8 bits of data

CHAR   =
%x01-7F
;  any 7-bit US-ASCII character,
;  excluding NUL

VCHAR   =
%x21-7E
;  visible (printing) characters

ALPHA   =
%x41-5A   /   %x61-7A
;  A-Z  /  a-z

DIGIT   =
%x30-39
;  0-9

CTL   =
%x00-1F    /    %x7F
;  any US-ASCII control character:
;  (octets 0 - 31) and DEL (127)

HTAB   =
%x09
;  horizontal tab

LF   =
%x0A
;  linefeed

CR   =
%x0D
;  carriage return

SP   =
%x20
;  space

DQUOTE   =
%x22
;  " (Double Quote)

BIT   =
"0"  /  "1"

HEXDIG   =
DIGIT  /  "A"  /  "B"  /  "C"  /  "D"  /  "E"  /  "F"
;  Note: according to the 'char-val' rule,
;  letters (A-F) are case insensitive

CRLF   =
CR   LF
;  Internet standard newline

WSP   =
SP  /  HTAB
;  white space

LWSP   =
*( WSP  /  CRLF   WSP )
;  linear white space (past newline)


|   Core_Rules   |   Operators   |   Definition   |

RFC 5234 – Appendix B.1

Top

Concatenation
Rule1   Rule2

Alternatives
Rule1  /  Rule2

Incremental Alternatives
Rule1  =/  Rule2
The rule set:
ruleset = alt1 / alt2
ruleset /= alt3
is the same as specifying:
ruleset = alt1 / alt2 / alt3

Value Range Alternatives
%c##-##

Sequence Group
( Rule1   Rule2 )

Variable Repetition
*Rule
The full form is: <a>*<b>element
where <a> and <b> are optional decimal values,
indicating at least <a> and at most <b> occurrences of element.
Default values are 0 and infinity so that:
*<element>
allows any number, including zero
1*<element>
requires at least one
3*3<element>
allows exactly 3
1*2<element>
allows one or two

Specific Repetition
nRule
A rule of the form: <n>element
is equivalent to: <n>*<n>element
That is, exactly <n> occurrences of <element>.
Thus 2DIGIT is a 2-digit number, and 3ALPHA is a string of three alphabetic characters.

Optional Sequence
[ Rule ]

Comment
;  Comment


|   Core_Rules   |   Operators   |   Definition   |

RFC 5234 – Section 4

Top

rulelist   =
1*( rule  /  ( *c-wsp   c-nl ) )

rule   =
rulename
defined-as
elements
c-nl
; continues if next line starts with white space

rulename   =
ALPHA   *( ALPHA  /  DIGIT  /  "-" )

defined-as   =
*c-wsp   ( "="  /  "=/" )   *c-wsp
; basic rules definition and incremental alternatives

elements   =
c-wsp   =
WSP  /  ( c-nl   WSP )

c-nl   =
comment  /  CRLF
; comment or newline

comment   =
";"   *( WSP  /  VCHAR)   CRLF

alternation   =
concatenation   *( *c-wsp   "/"   *c-wsp   concatenation )

concatenation   =
repetition   *( 1*c-wsp   repetition )

repetition   =
[ repeat ]   element

repeat   =
1*DIGIT  /  ( *DIGIT   "*"   *DIGIT )

element   =
rulename  /  group  /  option  /  char-val  /  num-val  /  prose-val

group   =
"("   *c-wsp   alternation   CRLF   *c-wsp   ")"

option   =
"["   *c-wsp   alternation   CRLF   *c-wsp   "]"

char-val   =
DQUOTE   *( %x20-21  /  %x23-7E )   DQUOTE

; quoted string of SP and VCHAR without DQUOTE
;
; NOTE: ABNF strings are case-insensitive.
;     Hence: rulename = "abc" and: rulename = "aBc"
;     will match "abc", "Abc", "aBc", "abC", "ABc", "aBC", "AbC", and "ABC".
;     To specify a rule that IS case SENSITIVE, specify the characters individually.
;         For example:
;             rulename = %d97 %d98 %d99
;             or
;             rulename = %d97.98.99
;         will match only the string that comprises only the lowercased characters, abc.


num-val   =
"%"   ( bin-val  /  dec-val  /  hex-val )

bin-val   =
"b"   1*BIT   [ 1*( "."   1*BIT )  /  ("-"   1*BIT) ]
; series of concatenated bit values or single ONEOF range

dec-val   =
"d"   1*DIGIT   [ 1*( "."   1*DIGIT  /  ("-"   1*DIGIT ) ]

hex-val   =
"x"   1*HEXDIG   [ 1*( "."   1*HEXDIG )  /  ( "-"   1*HEXDIG ) ]

prose-val   =
"<"   *( %x20-3D  /  %x3F-7E )   ">"

; bracketed string of SP and VCHAR without angles
; prose description, to be used as last resort


Top