Maintaining Perl 5 Core (Dave Mitchell): October 2025
Fri, 21-Nov-2025 by
alh
edit post
Dave writes:
Last month was mostly spent doing a second big refactor of
ExtUtils::ParseXS. My previous refactor converted the parser to assemble
each XSUB into an Abstract Syntax Tree (AST) and only then emit the C code
for it (previously the parsing and C code emitting were interleaved on the
fly). This new work extends that so that the whole XS file is now one big
AST, and the C code is only generated once all parsing is complete.
As well as fixing lots of minor parsing bugs along the way, another
benefit of this big refactoring is that ExtUtils::ParseXS becomes
manageable once again. Rather than one big 1400-line parsing loop, the
parsing and code generating is split up into lots of little methods in
subclasses which represent the nodes of the AST and which process just one
thing.
As an example, the logic which handled (permissible) duplicate
XSUB declarations in different C processor branches, such as
#ifdef USE_2ARG
int foo(int i, int j)
#else
int foo(int i)
#endif
used to be spread over many parts of the program; it's now almost all
concentrated into the parsing and code-emitting methods of a single Node
subclass.
This branch is currently pushed and undergoing review.
My earlier work on rewriting the XS reference manual, perlxs.pod, was made
into a PR a month ago, and this month I revised it based on reviewers'
feedback.
Summary:
* 11:39 modernise perlxs.pod
* 64:57 refactor Extutils::ParseXS: file-scoped AST
Total:
* 76:36 (HH::MM)
Comments (0)