Re: Parsing C typedefs using yacc (Paco Moreno Seco)
17 Dec 1995 00:25:11 -0500

          From comp.compilers

Related articles
Parsing C typedefs using yacc (Andrew Dunbar) (1995-12-09)
Re: Parsing C typedefs using yacc (1995-12-10)
Re: Parsing C typedefs using yacc (1995-12-17)
Re: Parsing typedefs with C (2) (1995-12-18)
| List of all articles for this month |

From: (Paco Moreno Seco)
Newsgroups: comp.compilers
Date: 17 Dec 1995 00:25:11 -0500
Organization: Compilers Central
References: 95-12-033
Keywords: C, parse

  Andrew Dunbar <> writes:

>I'm trying to parse C using yacc but I've hit a problem with
>typedefs. [Is there an approximate way to parse typedefs without
>expanding all the include files?]
>I'm only trying to make some tools to manipulate indenting, alter
>the names of global variables and such. It does not have to be
>100% accurate.

  I'm afraid you'll have to process include files (I can't imagine
another solution). If you are interested on a C grammar for yacc and
lex, you can download it from my ftp-site:

  In that directory you can find a C grammar for yacc and lex which
does not solve the "typedef problem" (I ftped it from , file c-grammar.gz, and its author is Jeff Lee
jeff@gatech). The files are scan.l.bak and gram.y.bak .

  I made some changes to these files to fix the "typedef problem"
(didn,t fix the "include problem", sorry) and I added some extra
actions to build a linked (linked) list of all tokens and lexemes of
the source program. These actions could be used to write something
like a pretty printer (or to build an indenting tool). There is no
documentation and no comments (except a few ones in spanish), but I
think you would have no problem understanding it (if so, please email
me and I will help you).

  Hope this helps!

  Paco Moreno Seco

Post a followup to this message

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