On 12.10.21 15:52, Andrew Dunstan wrote:
> I haven't been through the whole thing, but I did notice this: the
> comment stripping code looks rather fragile. I think it would blow up if
> there were a continuation line not starting with qr/\s*\*/. It's a lot
> simpler and more robust to do this if you slurp the file in whole.
> Here's what we do in the buildfarm code:
>
> my $src = file_contents($_);
> # strip C comments
> # We used to use the recipe in perlfaq6 but there is actually no point.
> # We don't need to keep the quoted string values anyway, and
> # on some platforms the complex regex causes perl to barf and crash.
> $src =~ s{/\*.*?\*/}{}gs;
>
> After you've done that splitting it into lines is pretty simple.
Here is an updated patch, with some general rebasing, and the above
improvement. It now also generates #include lines necessary in
copyfuncs etc. to pull in all the node types it operates on.
Further, I have looked more into the "metadata" approach discussed in
[0]. It's pretty easy to generate that kind of output from the data
structures my script produces. You just loop over all the node types
and print stuff and keep a few counters. I don't plan to work on that
at this time, but I just wanted to point out that if people wanted to
move into that direction, my patch wouldn't be in the way.
[0]:
https://www.postgresql.org/message-id/flat/20190828234136.fk2ndqtld3onfrrp%40alap3.anarazel.de