in reply to Parse C-like define statements
I suggest approaching the problem as seeing the file as a graph. Each #define is a node, with as (outgoing) edges edges to nodes its definition is refering to.
Now that you have made a graph, first you need to find out whether there are any loops - if there are, determine what you are going to do with them. Throw them out, die(), whatever. Second, do a topological sort, then you can process the defines like you are doing now:
$defines{$_} =~ s/<(\w+)>/$defines{$1}/g;
Luckely, there's a graph module on CPAN that could help you.
Abigail
|
|---|