YACC grammar for C language
Michael Meissner
meissner at xyzzy.UUCP
Thu Jan 12 13:57:42 AEST 1989
In article <175 at calmasd.GE.COM> jhh at calmasd.GE.COM (Jung Hamel) writes:
|
| Does anybody have or know of YACC grammar for C that does
| not require the lexical analyser to differentiate typedef
| names from other identifier names. We have tried to "fix" a
| grammar with this but always get an illegal grammar for YACC.
| Our lexical analyser does not have access to the full set of
| typedef names.
In short, it can't be done without a context sensitive parser (ie,
without things like the lexical analyser knowing about the symbol
table). Among other things, the following fragment:
(identifer) * expression
can be parsed either as a cast of dereferncing a pointer expression
(if identifier is a typedef name) or multiplication (if identifier is
a variable). This "feature" has probably been cursed by all C
implementators ever afterward (I know I sure did).
IMHO it is one of four things I would change if I could have my way
and have all the extant source code change overnight. In case you are
wondering, the other three are:
1) Change operator priorities, so that: x & mask == result, would
be evaluated as (x & mask) == value;
2) Remove macro procedures and add inline capability as a mandated
feature (including deletion of the inline function if there are
no callers);
3) Fix the overloading of "extern" and "static", and mandate one global
memory model (ie, the fact that UNIX supports a relaxed REF/DEF
scheme, wheras K&R and ANSI mandate the more strict single DEF,
multiple references model).
Sigh, these won't get changed because the time for such changes has
long since past.
--
Michael Meissner, Data General.
Uucp: ...!mcnc!rti!xyzzy!meissner
Arpa: meissner at dg-rtp.DG.COM (or) meissner%dg-rtp.DG.COM at relay.cs.net
More information about the Comp.lang.c
mailing list