Search code examples
ebnf

EBNF whitespacing in meta identifiers


I looked at the ISO spec pdf for EBNF here (I couldn't find the official one except on the ISO website, where it appears to cost money), and I don't quite understand the whitespace.

Does anyone know whether the official standards allow spaces in meta identifiers? Based off the meta identifier in the standards document (section 8.1), I would say no, but if you take a look at that same example in that same standards document, it appears to be saying yes.

In the comment at the top of 8.1 in that document, it appears to be saying that it is defining EBNF using itself. What I'm confused about this is lines such as this:

meta identifier = letter, {letter | decimal digit}
(* A <meta identifier> is the name of a
syntactic element of the language being
defined *);

meta identifier should be a meta identifier in itself, but as far as I can see, it doesn't fit a meta identifier (letter then any amount of numbers or letters).

Does anyone know what's going on?


Solution

  • Actually, the official ISO EBNF spec (ISO/IEC 14977:1996) can be freely downloaded from the ISO website here. That actually defines meta identifier as following:

    meta identifier = letter, {meta identifier character};
    
    meta identifier character = letter | decimal digit;
    

    It refers to 4.14 and 4.15 in this definition. There it says clearly that a meta identifier character consists only of letters and decimal digits.

    It is indeed strange that the EBNF they use to specify EBNF does allow spaces in identifiers. I always believed EBNF allows whitespace in identifiers. This is also what Wikipedia says (although the grammar there is incomplete in other ways):

    identifier = letter , { letter | digit | " " } ;
    

    So perhaps they have overlooked this in the standard? Or we are both missing something. Anyway, I hope you can maybe figure it out now that you have the official standard.