The SPIP compiler, in the ecrire/public/compiler.php file, is called using the
compiler() function from within the
Compilation starts by calling the appropriate parser depending on the grammar requested (the concrete syntax of the template). So it is the
phraser_html() parser which is called in the ecrire/public/phraser_html.php file. It transforms the syntax of the template into a table (
$boucles) of lists of PHP objects forming the concrete syntax that the compilation function will analyse.
For each loop found, SPIP performs a certain number of processes, starting by looking for which SQL tables match and which joins have been declared for these tables.
It then calculates the criteria applied on the loops (declared in ecrire/public/criteres.php or via plugins), and then the content of the loops (which have tags defined for some of them in ecrire/public/balises.php). It then proceeds to calculate the template elements that are outside of any loop.
Finally, it runs the loop functions that are dec-ared in the ecrire/public/boucles.php file. The result of all this builds a PHP-coded executable with a PHP function for each loop, and an overall PHP function for the whole template.
It is then this executable code which the compiler returns. This code will be stored in the cache then executed by the composer with the contextual parameters that have been passed. The result is the code for the requested page, which will be stored in cache (by calling the
cacher() function a second time, in the
assembler.php file) and then sent out to the browser (or if it is an inclusion, added to a page fragment). It may still contain PHP when certain details must display depending on the person visiting the page, such as with dynamic forms.