(* W3C EBNF for ISO/IEC 14977 : 1996 EBNF *) (* Scoured from https://www.cl.cam.ac.uk/~mgk25/iso-14977.pdf *) syntax = syntax_rule, {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 *); terminal_string = ("'", first_terminal_character, {first_terminal_character}, "'") | ('"', second_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, {decimal_digit} ; special_sequence = '?', {special_sequence_character}, '?' (* The meaning of a is not defined in the standard metalanguage. *); comment = '(*', {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" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" ; decimal_digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "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 = ' ' | ':' | '+' | '_' | '%' | '@' | '&' | '#' | '$' | '<' | '>' | '\' | '^' | '`' | '~' ; 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 = '}' | ':)' ;