|ANSI C PreProcessor firstname.lastname@example.org (2002-01-03)|
|Re: ANSI C PreProcessor email@example.com (Ben Pfaff) (2002-01-04)|
|Re: ANSI C PreProcessor firstname.lastname@example.org (2002-01-05)|
|From:||email@example.com (Nick Maclaren)|
|Date:||5 Jan 2002 01:40:42 -0500|
|Organization:||University of Cambridge, England|
|Posted-Date:||05 Jan 2002 01:40:42 EST|
Ben Pfaff <firstname.lastname@example.org> wrote:
>email@example.com (yuval) writes:
>> Now I am in the grammar part. I want to get a BNF grammar for the C
>There is a grammar for the C preprocessor in the C standard.
>Google for n869 to get a C99 draft.
I suppose that I need to say that the drafts were published solely for
the purpose of public comment and may not be reproduced ad lib.
Whether your posting is a breach of the USA's chauvististic DMCA, I
don't know - but it could be, because the DMCA is that bad.
However, let's get technical. The first point is that there are at
least THREE grammars in the C standard, which use THREE different
rules for the resolution of ambiguities. And none are BNF, as such,
though none are VERY different. All use the same notation, but which
rules should be used depend on context.
Confusions in this area have led to significant incompatibilities
between implementations, many heated debates about what the standard
says, and quite significant changes between C90 and C99. In the area
of the preprocessor, the languages are different, though the
differences affect only known problem areas - as far as I know.
Examples of such areas include (but are not limited to):
The handling of white space, especially at end of line
What is and is not allowed in a header name
The handling of things like '# fred' or '# pragma A " B '
What is really important to note when writing such a preprocessor is
that it is ESSENTIAL not to assume that the grammar means what it
appears to mean at first glance. Often it doesn't, and quite often
there is no explicit specification of what it does mean in the
standard itself. So take care.
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QH, England.
Tel.: +44 1223 334761 Fax: +44 1223 334679
[The paper version of the C99 standard costs a fortune, but you can
buy a PDF copy from ANSI at http://webstore.ansi.org/ansidocstore/.
Click to the (default) NCITS category, then scroll down to
"ANSI/ISO/IEC 9899-1999" near the bottom of the page. It costs
$18 which is pretty reasonable for a 554 page document. ANSI gets
most of its revenue from sales of standards, if you think it's worth
having a C standard, pay the $18. -John]
Return to the
Search the comp.compilers archives again.