05-05-2008 01:52 AM
05-05-2008 05:45 PM
05-05-2008 11:22 PM
05-05-2008 11:53 PM
05-06-2008 06:55 AM
One method is to parse the C file as a compiler does, looking for the list of symbols that make up the declaration section of the c function. For example,
<type> <fn name> ( <type> <var name> ....) {
It might be sufficient to just detect "<type><fn name> (", this might be sufficient to be uniquely identified as a function.
For this you can use the ANSI character manipulation commands in CVI.
Pseudocode for a simple parser:
open file as a stream
while not EOF, get next character {
build characters into a recognizable token, which could be a <type>, a <fn name>, a symbol "(){},;"
once a sequence of tokens is recognized that matches the target <type><fn name>(, then you have found a function name --> handle this
if no sequence of interest, and if the detected sequence is handled, let while loop repeat until EOF
}
close the input file
Best regards,
KC
05-06-2008 06:57 AM
05-06-2008 07:58 AM
Following on in the same theme, Googling for C parser finds any number of hits on the web, many of which are free to use (depending on circumstances). If I were you, I'd pick a couple that looked as if they were close to what you wanted to do and see if you could modify them appropriately.