# W3C EBNF for ISO/IEC 14977 : 1996 EBNF # (Scoured from https://www.cl.cam.ac.uk/~mgk25/iso-14977.pdf) # Extended to allow no syntax_rule to be valid. syntax ::= syntax_rule* syntax_rule ::= meta_identifier defining_symbol definitions_list terminator_symbol (* A defines the sequences of symbols represented by a *) definitions_list ::= single_definition (definition_separator_symbol definitions_list)* (* | separates alternative *) single_definition ::= term (',' term)* (* , separates successive *) term ::= factor ('-' exception)? (* A represents any sequence of symbols that is defined by the but not defined by the *) exception ::= factor (* A may be used as an if it could be replaced by a containingno *) factor ::= (integer '*')? primary (* The specifies the number of repetitions of the *) primary ::= optional_sequence | repeated_sequence | special_sequence | grouped_sequence | meta_identifier | terminal_string | empty optional_sequence ::= start_option_symbol definitions_list end_option_symbol (* The brackets [ and ] enclose symbols which are optional *) repeated_sequence ::= start_repeat_symbol definitions_list end_repeat_symbol (* The brackets { and } enclose symbols which may be repeated any number of times *) grouped_sequence ::= '(' definitions_list ')' (* The brackets ( and ) allow any to be a *) # Note, the following are nominally terminal rules, # although ISO EBNF does not really distinguish between non-terminal and terminal rules. @terminals terminal_string ::= ("'" first_terminal_character+ "'") | ('"' second_terminal_character+ '"') (* A represents the between the quote symbols '_' or "_" *) meta_identifier ::= letter meta_identifier_character* (* A is the name of a syntactic element of the language being defined *) integer ::= decimal_digit+ special_sequence ::= '?' special_sequence_character* '?' (* The meaning of a is not defined in the standard metalanguage. *) comment ::= start_comment_symbol comment_symbol* end_comment_symbol (* A comment is allowed anywhere outside a , , or *) comment_symbol ::= comment | commentless_symbol | other_character commentless_symbol ::= terminal_character | meta_identifier | integer | terminal_string | special_sequence letter ::= [a-zA-Z] # gratuitous comment decimal_digit ::= [0-9] # Extended to allow '_' meta_identifier_character ::= letter | decimal_digit | '_' first_terminal_character ::= terminal_character - "'" second_terminal_character ::= terminal_character - '"' special_sequence_character ::= terminal_character - '?' terminal_character ::= letter | decimal_digit | concatenate_symbol | defining_symbol | definition_separator_symbol | end_comment_symbol | end_group_symbol | end_option_symbol | end_repeat_symbol | except_symbol | first_quote_symbol | repetition_symbol | second_quote_symbol | special_sequence_symbol | start_comment_symbol | start_group_symbol | start_option_symbol | start_repeat_symbol | terminator_symbol | other_character other_character ::= [:+_%@&$<>^` ̃#x20#x23] | '\' gap_separator ::= [#x9#xa#xb#xc#xd#x20] @pass gap_separator+ | comment empty ::= '' concatenate_symbol ::= ',' repetition_symbol ::= '*' except_symbol ::= '-' first_quote_symbol ::= "'" second_quote_symbol ::= '"' start_comment_symbol ::= '(*' end_comment_symbol ::= '*)' start_group_symbol ::= '(' end_group_symbol ::= ')' special_sequence_symbol ::= '?' # Simple terminals that are often extended defining_symbol ::= '=' | ':' definition_separator_symbol ::= '|' | '/' | '!' terminator_symbol ::= ';' | '.' start_option_symbol ::= '[' end_option_symbol ::= ']' start_repeat_symbol ::= '{' | '(:' end_repeat_symbol ::= '}' | ':)' # Symbols described, but not actually used. gap_free_symbol ::= (terminal_character - ['"]) | terminal_string