Re: Lacing C/C++ code

mike@vlsivie.tuwien.ac.at (Michael Gschwind)
Mon, 29 Nov 1993 13:30:38 GMT

          From comp.compilers

Related articles
Lacing C/C++ code elan@tasha.cheme.cornell.edu (1993-11-14)
Re: Lacing C/C++ code ltd@netcom.com (1993-11-15)
Re: Lacing C/C++ code prashanth@cdotd.ernet.in (Prashant V Hedaoo) (1993-11-16)
Re: Lacing C/C++ code mike@vlsivie.tuwien.ac.at (1993-11-29)
| List of all articles for this month |
Newsgroups: comp.compilers
From: mike@vlsivie.tuwien.ac.at (Michael Gschwind)
Keywords: C
Organization: TU Wien
References: 93-11-092 93-11-109
Date: Mon, 29 Nov 1993 13:30:38 GMT

Prashant V Hedaoo <prashanth@cdotd.ernet.in> writes:
      [How to find the start/end of C functios using reg-exps]


Our moderator adds:
      [I'd be concerned that this approach could be confused by declarations of
      pointers to functions. -John]


Those should have a semi-colon at the end of the declaration, so this is a
simple way to check it it's the declaration of a pointer to function or a
function. If the next token is a ';' you have a pointer to function, if it
is ( id * ';' )* '{' it's a function. This of course modulo any nifty CPP
#ifdef's and comments. (I can't really imagine you can do a full blown job
before you preprocess the file. Any token could really be MACRO and blow
all your assumptions about the code to pieces. But for most code, the
regexp approach should do the job.)


mike
--
Michael Gschwind, Institut fuer Technische Informatik, TU Wien
snail: Treitlstrasse 3-182-2 || A-1040 Wien || Austria
email: mike@vlsivie.tuwien.ac.at
phone: +(43)(1)58801 8156 fax: +(43)(1)569 697
--


Post a followup to this message

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