Augmented BNF taken from RFC 2616
supplemented by RFC 2234
An augmented Backus-Naur Form (BNF) similar to that used by RFC 822.
The augmented BNF includes the following constructs:
name = definition
The name of a rule is simply the name itself (without any
enclosing "<" and ">") and is separated from its definition by the
equal "=" character. White space is only significant in that
indentation of continuation lines is used to indicate a rule
definition that spans more than one line. Certain basic rules are
in uppercase, such as SP, LWS, HT, CRLF, DIGIT, ALPHA, etc. Angle
brackets are used within definitions whenever their presence will
facilitate discerning the use of rule names.
"literal"
Quotation marks surround literal text. Unless stated otherwise,
the text is case-insensitive.
rule1 | rule2
Elements separated by a bar ("|") are alternatives, e.g., "yes |
no" will accept yes or no.
(rule1 rule2)
Elements enclosed in parentheses are treated as a single element.
Thus, "(elem (foo | bar) elem)" allows the token sequences "elem
foo elem" and "elem bar elem".
*rule
The character "*" preceding an element indicates repetition. The
full form is "<n>*<m>element" indicating at least <n> and at most
<m> occurrences of element. Default values are 0 and infinity so
that "*(element)" allows any number, including zero; "1*element"
requires at least one; and "1*2element" allows one or two.
[rule]
Square brackets enclose optional elements; "[foo bar]" is
equivalent to "*1(foo bar)".
N rule
Specific repetition: "<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.
#rule
A construct "#" is defined, similar to "*", for defining lists of
elements. The full form is "<n>#<m>element" indicating at least
<n> and at most <m> elements, each separated by one or more commas
(",") and OPTIONAL linear white space (LWS). This makes the usual
form of lists very easy; a rule such as
( *LWS element *( *LWS "," *LWS element ))
can be shown as
1#element
Wherever this construct is used, null elements are allowed, but do
not contribute to the count of elements present. That is,
"(element), , (element) " is permitted, but counts as only two
elements. Therefore, where at least one element is required, at
least one non-null element MUST be present. Default values are 0
and infinity so that "#element" allows any number, including zero;
"1#element" requires at least one; and "1#2element" allows one or
two.
; comment
A semi-colon, set off some distance to the right of rule text,
starts a comment that continues to the end of line. This is a
simple way of including useful notes in parallel with the
specifications.
implied *LWS
The grammar described by this specification is word-based. Except
where noted otherwise, linear white space (LWS) can be included
between any two adjacent words (token or quoted-string), and
between adjacent words and separators, without changing the
interpretation of a field. At least one delimiter (LWS and/or
separators) MUST exist between any two tokens (for the definition
of "token" below), since they would otherwise be interpreted as a
single token.
_______________________________________________________________________
For Example:
OCTET = <any 8-bit sequence of data>
CHAR = <any US-ASCII character (octets 0 - 127)>
UPALPHA = <any US-ASCII uppercase letter "A".."Z">
LOALPHA = <any US-ASCII lowercase letter "a".."z">
ALPHA = UPALPHA | LOALPHA
DIGIT = <any US-ASCII digit "0".."9">
ALPHANUM = ALPHA | DIGIT
CTL = <any US-ASCII control character
(octets 0 - 31) and DEL (127)>
CR = <US-ASCII CR, carriage return (13)>
LF = <US-ASCII LF, linefeed (10)>
SP = <US-ASCII SP, space (32)>
HT = <US-ASCII HT, horizontal-tab (9)>
<"> = <US-ASCII double-quote mark (34)>
CRLF = CR LF
LWS = [CRLF] 1*( SP | HT )
TEXT = <any OCTET except CTLs, but including LWS>
HEX = "A" | "B" | "C" | "D" | "E" | "F"
| "a" | "b" | "c" | "d" | "e" | "f" | DIGIT
QUOTEDPAIR = "\" CHAR
QUOTEDTEXT = <any TEXT except <">, "\" & CR>
QUOTEDSTRING = ( <"> *( QUOTEDTEXT | QUOTEDPAIR ) <"> )
TIME = 2DIGIT ":" 2DIGIT ":" 2DIGIT
; 00:00:00 - 23:59:59
DATE = 4DIGIT "-" 2DIGIT "-" 2DIGIT
TIMESTAMP = DATE "T" TIME "TZ"
; In UTC
; ISO 8601
SMALLINT =
NUM_PART =
MACHINE_NUM = NUM_PART "." NUM_PART "." NUM_PART "." NUM_PART
NAME_PART = ALPHA 0*24(ALPHANUM | "-")
MACHINE_NAME = NAME_PART 0*3( "." NAME_PART )
MACHINE_PART = MACHINE_NAME | MACHINE_NUM
PORT = SMALLINT
ADDRESS = MACHINE_PART | ( MACHINE_PART ":" PORT )
INT_PAIR = SMALLINT-SMALLINT
INT_ITEM = SMALLINT | INT_PAIR
INT_RANGE = INT_ITEM *( "," INT_ITEM )
; *******************************************
; *
; * Project Fairdice specific defintions
; *
; *******************************************
NAME = 1*25(ALPHANUM)
DISPLAY_STR = 1*250(TEXT)
OPAQUE_STR = 0*60000(OCTET)
PASSWORD = 1*250(ALPHANUM)
USER_NAME = NAME
SERVER_ID = ADDRESS
HOST_ID = NAME | ADDRESS
LINK_ID = SERVER_ID " ^ " HOST_ID
GAME_SIZE = SMALLINT ; the number of players in the game
PLAYER_ID = SMALLINT ; an int between 1..GAME_SIZE (inclusive)
PARTICIPANT_ID = SMALLINT ; an int between 0..GAME_SIZE (inclusive)
GAME_ID = NAME
ALLOWED_CHAR = ALPHA | DIGIT | "." | "<" | ">" | "(" | ")" |
"-" | "_" | "," | "'" | " " | "+" | "=" | "&" |
";" | "*" | "%" | "[" | "]" | ":" | "/" | "\" | "@"
; note, that is the literal "\" character, not escaped
; characters in general and specifically disallowed are
SPECIAL_CHAR = "|" | "^" | "\n" | "\0"
(TOP)(UP)