(*  This example defines Extended BNF informally.  Many of the syntax
rules include a comment to explain their meaning; inside a comment a
meta identifier is enclosed in angle brackets  <  and  >  to avoid
confusion with similar English words.  The non-terminal symbols
<letter>, <decimal_digit> and <character> are NOT defined.  The position
of <comments> is stated in a comment but not formally defined.  *)

(*  A <syntax_rule> defines the sequences of symbols represented by a
<meta_identifier>  *)
syntax = syntax_rule, { syntax_rule } ;
syntax_rule = meta_identifier, '=', definitions_list, ';' ;

(*  |  separates alternative <single_definitions>  *)
definitions_list = single_definition, { '|', single_definition } ;

(* ,  separates successive <terms>  *)
single_definition = term, { ',', term } ;

(*  A <term> represents any sequence of symbols that is defined by the
<factor> but not defined by the <exception>  *)
term = factor, ['-', exception] ;

(*  A <factor> may be used as an <exception> if it could be replaced by
a <factor> containing no <meta_identifiers>  *)
exception =  factor;

(*  The <integer> specifies the number of repetitions of the
<primary>  *)
factor = [ integer, '*' ], primary ;

primary = optional_sequence | repeated_sequence | special_sequence
          | grouped_sequence | meta_identifier | terminal_string
          | empty ;

empty = ;

(*  The brackets  [  and  ]  enclose symbols which are optional  *)
optional_sequence = '[', definitions_list, ']' ;

(*  The brackets  {  and  }  enclose symbols which may be repeated any
number of times  *)
repeated_sequence = '{', definitions_list, '}' ;

(*  The brackets  (  and  )  allow any <definitions_list> to be a
<primary>  *)
grouped_sequence = '(', definitions_list, ')' ;

(*  A <terminal_string> represents the <characters> between the quote
symbols '_'  or  "_"  *)
terminal_string = "'", character - "'", { character - "'" }, "'"
                  | '"', character - '"', { character - '"' }, '"' ;

(*  A <meta_identifier> is the name of a syntactic element of the
language being defined  *)
meta_identifier = letter, { letter | decimal_digit } ;

integer = decimal_digit, { decimal_digit } ;

(*  The meaning of a <special_sequence> is not defined in the standard
metalanguage.  *)
special_sequence = '?', { character - '?' }, '?' ;

(*  A comment is allowed anywhere outside a <terminal_string>,
<meta_identifier>, <integer> or <special_sequence>  *)
comment = '(*', { comment_symbol }, '*)' ;

comment_symbol = comment | terminal_string | special_sequence
                 | character ;
