Re: Simple parser for C/C++
- From: Alexandre Ferrieux <alexandre.ferrieux@xxxxxxxxx>
- Date: Fri, 28 Sep 2007 20:14:56 -0000
On Sep 28, 8:59 pm, Esa Heikkinen <esa.heikki...@xxxxxx> wrote:
Michael already directed you to the page on the wiki which is probablyOk .. i understand, but i think it would be exist simpler way to detect
the best starting point for parsing C.
only things i want. I don't want to parse all code. Maybe i do not need
parser at all ?
Unfortunately C is not "partially parsable", because the same token
from the lexer can have wildly different syntactic roles depending on
the surrounding tokens.
So, what to do if you don't want to use and augment an existing full-
fledged C/C++ parser ?
Two radically different approaches:
1) Obstinacy: compile it with a true C compiler, with debugging info
enabled, and then analyze the resulting object files to extract line
number information for beginning and end of functions. In unix I'd do
this with gcc and objdump.
2) Pragmatism: give style rules to your developers, like in doxygen et
al., so that the interesting parts of the code become subject to
simple grepping (or regexp, I suddenly remember we are on c.l.t ;-).
Notice that the style rules may be much simpler than doxygen's comment-
typing, e.g by playing only with indentation:
/* uninstrumented beginning */
#include <stdlib.h>
...
/* ============ HERE_BEGINS_INSTRUMENTED_PART == */
int
foo
(char *a,void *b,float c)
{
/* indented body */
}
The code above is just slightly disturbed by the constraints of your
goal. So it is 99% as readable for humans (some would say 150% ;-),
and 500% for Tcl...
(Now of course if you have read-only access to the code, this is not
an option.)
-Alex
.
- References:
- Simple parser for C/C++
- From: Esa Heikkinen
- Re: Simple parser for C/C++
- From: Helmut Giese
- Re: Simple parser for C/C++
- From: Esa Heikkinen
- Simple parser for C/C++
- Prev by Date: Re: 8.5 beta and decimal precision handling
- Next by Date: Re: 8.5 beta and decimal precision handling
- Previous by thread: Re: Simple parser for C/C++
- Next by thread: Re: Simple parser for C/C++
- Index(es):
Relevant Pages
|