GCC::TranslationUnit - Parse the output of gcc -fdump-translation-unit
use GCC::TranslationUnit; # echo '#include <stdio.h>' > stdio.c # gcc -fdump-translation-unit -c stdio.c $node = GCC::TranslationUnit::Parser->parsefile('stdio.c.tu')->root; # list every function/variable name while($node) { if($node->isa('GCC::Node::function_decl') or $node->isa('GCC::Node::var_decl')) { printf "%s declared in %s\n", $node->name->identifier, $node->source; } } continue { $node = $node->chain; }
Provides a module for reading in the -fdump-translation-unit file from GCC and access methods for the data available from within GCC.
Once you read in the file using the Parser, you can traverse the entire structure of the parse tree using methods defined in the GCC::Node::* modules. Look there for information. Each node is blessed into a GCC::Node::* class with that name.
See the source for the GCC::Node modules, and the source to GCC itself
Ashley Winters <awinters@users.sourceforge.net>
Copyright 2003 by Ashley Winters
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install GCC::TranslationUnit, copy and paste the appropriate command in to your terminal.
cpanm
cpanm GCC::TranslationUnit
CPAN shell
perl -MCPAN -e shell install GCC::TranslationUnit
For more information on module installation, please visit the detailed CPAN module installation guide.