in reply to Maintaining horrible C with Parse::RecDescent

I think RMGir is on the right track .. instead of trying to parse all of the C in the file, find a regexp (or a grammer) that will *JUST* pull out the defintions of all the large arrays.

His suggestion of /^[A-Z_]+ [a-z_0-9]+ = {/ will probably catch too much (i'm guessing you have plenty of small arrays you aren't worried about) but if there's some "minimum array nest depth" that you are interested in, you can write a regexp to find those...

$_ = ...; # file contents my $min_depth = 4; while (/([A-Z_]+ [a-z_0-9]+ = \{([^\}]*\{){$min_depth,}[^;]*;)/g) { my $array = $1; .... }
(completely untested,of course)

Replies are listed 'Best First'.
Re: Re: Maintaining horrible C with Parse::RecDescent
by RMGir (Prior) on Mar 18, 2002 at 12:43 UTC
    Interesting, hossman!

    I haven't tested it either, but I have this fear that that could be a scarily slow regex.

    Could be worth a try,though.

    Oh, one possible optimization would be to make the quantifier {$min_depth} instead of {$min_depth,}. That would put the regex into the faster [^;]* part quicker. Maybe? It's all guesses :)
    --
    Mike