Jim Roskind's C grammar (c5.y)

Ian Cottam <ian@cs.man.ac.uk>
4 Aug 91 15:57:19 GMT

          From comp.compilers

Related articles
Jim Roskind's C grammar (c5.y) ian@cs.man.ac.uk (Ian Cottam) (1991-08-04)
| List of all articles for this month |

Newsgroups: comp.lang.c,comp.compilers
From: Ian Cottam <ian@cs.man.ac.uk>
Followup-To: comp.lang.c
Keywords: C, parse
Organization: Department of Computer Science, University of Manchester UK
Date: 4 Aug 91 15:57:19 GMT

In the interesting grammar for C kindly supplied to the Usenet community by
"jar@hq.ileaf.com (Jim Roskind)", a simple hack to identify typedef names is
used in order to allow users to experiment with his grammar. The hack is that
typedef names must begin with a capital letter.


I have made a small modification to the grammar and flex files to make the
handling of typedef names a *little* more realistic. In the modified version
I keep a list of typedef names and the lexer simply searches this list to
determine if IDENTIFIER or TYPEDEFname should be returned to yacc. Of course,
this is still a hack in that the proper scope rules are not used.
Nevertheless, this change enables a large number of C modules to be analysed
*without* having to edit all the typedefs.


If I get any more time, I may put the proper scoping in.


For people that have access to large amounts of C code (e.g. UNIX source) and
some sort of `context grep', I would be interested in what percentage of
typedefs are actually local to a function or block.
--
Ian Cottam, Room IT209, Department of Computer Science,
University of Manchester, Oxford Road, Manchester, M13 9PL, U.K.
Tel: (+44) 61-275 6157 FAX: (+44) 61-275-6236
Internet: ian%cs.man.ac.uk; JANET: ian@uk.ac.man.cs
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.