csourceparser.pl - extract components from sourcecode written in the C programming language
This documentation refers to csourceparser.pl version 0.1.0
./csourceparser.pl [OPTION] ... FILE ...
Print signatures of functions defined in a C-file:
./csourceparser.pl -f myprog.c
Print all declarations in a C-file:
./csourceparser.pl -d myprog.c
Print all structures in a C-file:
./csourceparser.pl -u myheader.h
One or more C-Sourcefiles to parse.
Show parsed source code with line numbers
Prints (global) declarations in the sourcefile to stdout
Print error messages generated by Parse::RecDescent to the file 'errfile'
Prints the signatures of functions defined in the source file to stdout (the function bodys are ommited)
Print this help
Generate precompiled parsers Cgrammar.pm and DecommentGrammar.pm in the current working directory. Precompiled parsers will speed up parsing. If these files are available in the current working directory they will be used automatically. Every time the --precompile option is set the precompiled parsers are generateted newly so this option should only be used only once. Also, don't forget to recreate the precompiled parseres if you modify the grammar.
Show which lines had been skipped during parse due to parser errors or unrecognized tokens in the C source code
Print full tracecode generated by Parse::RecDescent. Note: this can be a lot
Print all structs and unions defined in the C sourcefile
Each use encreases verbosity level by one.
If you don't get the output you expect try to set the -sc options to see what happens. When the parser can't handle the input it will silently get skipped (for empty lines this is a normal behaviour).
If the parser doesn't behave as you expect take a look at the tracecode, e.g. ./csourceparser -t file.c 2> trace for full tracecode or ./csourceparser -vv file.c 2> trace to see only parser level 3 (C-parser) trace code. Depending on the size of the input file(s) this could take some time and may occupy some hd-space.
Please refer to the Parse::RecDescent documentation if you get errors after modifying the grammar.
Macros in C-Files could not be parsed at this time. Any declarations and definitions containing macros my cause errors. Perhaps this feature could be implemented in the future by using a "real" preprocessor like m4.
Please report problems to Hendrik Sirges (hendrik.sirges at fh-swf.de) Patches are welcome.
Hendrik Sirges <hendrik.sirges[at]fh-swf.de>
This program is Copyright 2005 by Hendrik Sirges. This program is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License or the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
If you do not have a copy of the GNU General Public License write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.