-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Right now working on translate-c code is awkward because we have to simultaneously create AST nodes, which is a tree structure, while outputting a list of tokens and source in a linear order. If we had a more specialized AST data structure for translate-c, we could generate the token list and source from it instead of having to duplicate the logic.
It ends up causing bugs like this: #6707
And this hack:
Lines 26 to 28 in 245d98d
/// translate-c uses this to avoid having to emit correct newlines | |
/// TODO get rid of this hack | |
generated: bool = false, |
To explain another way, the current process is:
- clang analysis => zig AST + source + token list => std.zig.render
Proposed process is:
- clang analysis => TranslateCNode Tree => zig AST + source + token list => std.zig.render
The translate-c node tree data structure does not need to map to zig AST, it just has to be whatever is convenient for the translate-c implementation.
This probably would have a small performance penalty; the main objective with this proposal is to increase maintainability.
cc @Vexu