You only need to parse the "module <module name>" and "import <module name>" statements. No need to parse all of C++ for that. You could probably even do that with a regex.
Re:C++ Modules Might Be Dead-On-Arrival
by galangalalgol on Monday January 28, 2019 @10:17AM
(#19018035)
It also has to do all the preprocessing to see which import statements get hit. I don't think templates could control at compile time which module to import, at least I hope not.
But if some_function() does return 8, we use the specialisation and the foo<8>::bar is an int with value 99; so we ask is 99 less than the expression 0>(1) (aka "false", promoted to the int 0).
That is, there are two entirely different but valid parses depending on whether we are compiling on a 32- or 64-bit system.
Parsing C++ is hard.
EDIT: Godbolt example: https://godbolt.org/z/yR3YHW