11# C Parser Reference
22
3- Status: current reference for the parse-only C frontend. The ` c_parser `
3+ Status: current reference for the partial C frontend. The ` c_parser `
44package, typed parser models, explicit C CLI parse path, raw directive
55metadata, compiler-assisted preprocessing, source-location remapping, project
6- indexes, parser goldens, and C standard-type probe are implemented. C semantic
7- readiness , semantic IR conversion , and ` .pyi ` generation remain future work and
8- are intentionally rejected by the CLI .
6+ indexes, parser goldens, C standard-type probe, first semantic IR conversion
7+ subset , semantic readiness path , and starter exact-contract C ` .pyi `
8+ generation are implemented .
99
1010## Purpose
1111
@@ -52,8 +52,11 @@ Implemented:
5252 the ` c_parser ` package entrypoints
5353- ` CParseError ` with compiler-style diagnostic formatting
5454- explicit ` x2py --language c --parse ` output
55+ - explicit ` x2py --language c --semantics ` and
56+ ` x2py --language c --wrap-readiness ` output
57+ - starter exact-contract ` x2py --language c --pyi ` output for the supported C
58+ semantic subset
5559- C JSON partial output and ` --out ` behavior
56- - rejection of C ` --semantics ` , ` --pyi ` , and ` --wrap-readiness `
5760- raw lexer records with comment stripping, line-continuation folding, and
5861 lightweight token source locations
5962- top-level source splitting that tracks braces, parentheses, brackets, and
@@ -123,14 +126,19 @@ Implemented:
123126 ` tests/data/c/errors/parser/ ` , and partial-parser regression inputs under
124127 ` tests/data/c/json/ ` , ` tests/data/c/tinyexpr/ ` , ` tests/data/c/linmath/ ` ,
125128 ` tests/data/c/nanosvg/ ` , and top-level C inputs from ` tests/data/c/stb/ `
129+ - ` semantics.c2ir ` conversion for the first identity subset: scalar
130+ functions, const/mutable pointer storage contracts, declared arrays,
131+ structs/opaque structs, enums, numeric macro constants, local typedef
132+ chains, standard-type probe facts, and explicit semantic readiness blockers
126133
127134Still deferred:
128135
129136- callback policy metadata beyond parser-side callback candidates
130137- broad compiler-extension declarators
131138- broader typedef/tag conflict policy beyond the implemented basic project
132139 resolution
133- - semantic readiness, semantic IR conversion, and ` .pyi ` generation
140+ - richer C ownership/callback projection policy beyond exact starter ` .pyi `
141+ stubs
134142
135143## Supported C Subset
136144
@@ -292,9 +300,8 @@ target-relevant flags from the matching entry to the probe explicitly.
292300For cross targets, provide a runner, for example `--runner=qemu-aarch64
293301--runner=-L --runner=/opt/aarch64-sysroot`.
294302
295- The eventual C semantic converter should accept this report as target context.
296- The parser model remains source-faithful and does not embed host ABI
297- assumptions.
303+ The C semantic converter accepts this report as target context. The parser
304+ model remains source-faithful and does not embed host ABI assumptions.
298305
299306## Public API
300307
@@ -603,16 +610,16 @@ Test families should mirror the Fortran parser:
603610- typedef tests
604611- macro/constant tests
605612- include/project tests
606- - semantic readiness tests once C semantic conversion exists
613+ - C semantic readiness tests
607614- CLI tests
608615- semantic conversion tests
609616- ` .pyi ` generation/parser tests
610617- fixture/golden parser tests
611618- error fixture/golden tests
612619- corpus parse-only tests
613620
614- The C test area contains active partial-parser/raw-metadata tests plus narrowly
615- scoped roadmap skips under ` tests/parser/c/ ` . The active tests cover
621+ The C test area contains active partial-parser/raw-metadata tests, including
622+ parse-only cJSON regression coverage under ` tests/parser/c/ ` . The active tests cover
616623public entrypoints, empty model serialization, CLI discovery, JSON/output-file
617624behavior, unsupported C stages, comment stripping, line-continuation folding,
618625top-level splitting, include collection, simple macro collection, macro-shaped
@@ -625,8 +632,8 @@ prototypes/definitions, function-definition start/end locations, JSON golden
625632serialization, fatal diagnostic goldens, and project-level callback typedef
626633resolution. The ` json ` regression inputs
627634intentionally retain recoverable diagnostics from unsupported constructs; they
628- do not claim complete library parsing. Remaining parser-suite skips cover the
629- pinned/provenanced corpus target . Golden comparison tests rewrite their baselines when
635+ do not claim complete library parsing. A separately pinned/provenanced corpus
636+ target remains deferred without disabling parser tests . Golden comparison tests rewrite their baselines when
630637` C_PARSER_UPDATE_GOLDENS=1 ` is set. Future implementation branches should
631638activate only the tests for the capability they implement.
632639
0 commit comments