In BNF, the syntax is written out in a line. Square
brackets, [ and ], braces, { and
}, and the vertical bar symbol, |, are used to describe
the syntax. Collectively, these symbols are known as
controls.
Blanks are used to separate the syntax elements from the square brackets,
braces and vertical bars. Use your screen reader's "speak next
word" (usually Control + RightArrow key) and "speak prior word"
(usually Control + LeftArrow key) to move between successive BNF
controls and syntax elements.
Characters that you need to include when you are constructing your command
(for example, left and right brackets ( and ), and
separators such as a comma) are located at the point at which you need to type
them in. For example, a left bracket can be read out before a list of
options. In some programming languages, such as C, C++, and Java,
square brackets, braces and the vertical bar symbol are used within the
language. For ease of identification, where the square bracket, brace
or vertical bar symbol appears in the syntax diagram as a part of the
programming language, it is preceded by the escape character, which is a
\ (backslash). For example, if you hear \{, you
know that you should actually type in the { at that point when you
are constructing your command, and that the { is not a part of the
structure of the syntax diagram.
The BNF syntax works as follows:
- Braces { and } are used to indicate a group of
syntax elements, in the same way as ( and ) are
used in algebra. For example, AUTH( { USERID | SYSTEMID } )
shows that USERID and SYSTEMID are the group of options
for the AUTH keyword. Note that this example syntax includes
a ( and ) that you need to type in around the option you
select. If you selected the USERID option, your command
would be AUTH(USERID).
- Square brackets [ and ] mean a construct that
is optional. The optional construct is started by [
and ended by ]. The square brackets [ and
], and the braces { and }, can both be used
on the same group of syntax elements. For example, the presence of the
square brackets in the syntax [ AUTH( { USERID | SYSTEMID } ) ]
means that you could leave out the keyword AUTH and its options
from the command you construct.
- The vertical bar | is an OR sign and means an
alternative. All constructs to the right of the | are
an alternative to the construct to the left of the |. The
scope of the | is delimited by either the end of the group or
construct, shown by ] or }, or the end of the
syntax. The vertical bar applies to all the items in the delimited
group, not just those items immediately adjacent to the bar. For
example, { A | B C } means "either A, or B and C". If
you wanted to indicate "either A and C, or B and C", the correct syntax would
be { A | B } C.
- Exclamation marks ! placed around a value indicate the
default value in a set of alternatives. For example, AUTH(
{ !USERID! | SYSTEMID } ) means that USERID is the
default option for the AUTH keyword. Take careful note of
the position of any square brackets, [ and ], around a
construct containing a default. If there are square brackets around the
whole construct but not around the set of alternatives, for example [
AUTH( { !USERID! | SYSTEMID } ) ], this means that a default applies for
the whole construct. If you omit the AUTH keyword from your
finished command, the default setting AUTH(USERID) will be included
automatically. However, if there are square brackets around the whole
construct and also around the set of alternatives, for example [
AUTH [ ( { !USERID! | SYSTEMID } ) ] ], this means that a default
applies only for the set of alternatives. In this case, if you omit the
AUTH keyword from your finished command, no default setting will be
included. If you include the AUTH keyword but do not state
your choice of option, the default option USERID will be
applied.
- An ellipse ... following a construct
means that the syntax elements given in that construct can optionally be
repeated. For example, { HOST | STATE | TYPE }
... means that you can include more than one of the
keywords HOST, STATE, and TYPE. Note
that if the construct only includes one syntax element, you can repeat that
same syntax element more than once. However, if the construct includes
more than one syntax element, you can use more than one of the elements, but
you cannot use each element more than once. In the example above, you
could write HOST STATE, but you could not write HOST
HOST.
- A syntax element that starts and ends with a % (percentage
symbol) means that the element is the name of a syntax fragment rather than a
literal. It indicates a reference that is defined
elsewhere. For example, %OP1% means that at this point, you
should refer to the separate syntax fragment OP1.
OP1, in the syntax from which this example was taken, gave a list
of further options.
© IBM Corporation 1994, 2002. All Rights Reserved