Re: Lacing C/C++ code (Michael Gschwind)
Mon, 29 Nov 1993 13:30:38 GMT

          From comp.compilers

Related articles
Lacing C/C++ code (1993-11-14)
Re: Lacing C/C++ code (1993-11-15)
Re: Lacing C/C++ code (Prashant V Hedaoo) (1993-11-16)
Re: Lacing C/C++ code (1993-11-29)
| List of all articles for this month |

Newsgroups: comp.compilers
From: (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 <> 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.)

Michael Gschwind, Institut fuer Technische Informatik, TU Wien
snail: Treitlstrasse 3-182-2 || A-1040 Wien || Austria
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.