New preprocessor, work in progress #719
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a rewrite of the Preprocessor, based on the algorithm described in https://www.spinellis.gr/blog/20060626/cpp.algo.pdf
Main inspiration was that the existing one doesn't work with some more esoteric cases, such as https://github.com/Hirrolot/metalang99 and was having trouble figuring out why.
Right now it's hidden behind a flag
-fnew-preprocessor
, and it only preprocesses; it isn't tied into the parser at all. And there is still a lot of work to do - currently I'm not handling expansion locations at all, and there are lots of missing smaller features + probably lots of memory leaks.One big improvement is using a persistent treap for hideset management, which massively reduces the amount of copying when adding items to a set or performing union/intersection operations.