-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed as not planned
Closed as not planned
Copy link
Labels
enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.frontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.standard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.translate-cC to Zig source translation feature (@cImport)C to Zig source translation feature (@cImport)
Milestone
Description
Currently Zig has the file src-self-hosted/c_tokenizer.zig which is used to tokenize macros for translate-c purposes. It also has some functions in src-self-hosted/translate_c.zig which do AST parsing of C tokens:
parseCPrimaryExprparseCExprparseCSuffixOpExpr- etc
Zig has set a (in my opinion successful) precedent in exposing its own tokenizer, parser, and AST in the standard library, in these files:
std/lib/zig/ast.zigstd/lib/zig/parse.zigstd/lib/zig/render.zigstd/lib/zig/tokenizer.zig
Now it is time to do the same for C:
- Decouple C tokenization and AST building from translate-c
- Expose C tokenization and AST building (and rendering?) in
std/lib/c/*in the same way as zig. - Complete the implementation of C tokenization and AST building. Make it compatible with the specification as well as GCC extensions, and make it robust. Someone should be able to write a C compiler in zig comfortably by using the standard library C tokenizer and parser.
- translate-c should use this generic and robust C tokenizer and parser API, rather than its current, only-what-we-need-to-make-it-work implementation.
cc @Vexu
mlarouche, jayschwa, watzon, codehippo, moosichu and 6 more
Metadata
Metadata
Assignees
Labels
enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.frontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.standard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.translate-cC to Zig source translation feature (@cImport)C to Zig source translation feature (@cImport)