code-yeongyu / code-yeongyu/c11-compiler-zig-omo

[Sisyphus] phase-2 / zcc / Wave 3 — Parser (expressions + statements)

Open
#18 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
3
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## Scope
Parse C11 expressions and statements, completing the parser.

## Deliverables
- Extend `phase2/zcc/src/parse.zig` with expression and statement parsing.
- Extend `phase2/zcc/src/ast.zig` with expression and statement AST nodes.

## Grammar Coverage
- Full expression grammar via precedence climbing / Pratt parser: primary, postfix, unary, cast, multiplicative, additive, shift, relational, equality, bitwise AND/XOR/OR, logical AND/OR, conditional, assignment, comma.
- All statements: labeled (`case`, `default`, identifier-label), compound, expression, selection (`if`, `switch`), iteration (`while`, `do-while`, `for`), jump (`goto`, `continue`, `break`, `return`).
- `_Generic` selection expressions.
- Compound literals.
- Designated initializers (`[index]`, `.member`, range designators).

## Success Criteria
1. Successfully parse reference files `011.c`, `017.c` through `023.c` from `phase1/c11-ref/`.
2. `_Generic` selection in `001.c` and designated initializers in `010.c` parse correctly.
3. AST snapshots are stable across runs.

## Dependencies on Prior Waves
- **Wave 0** — build system.
- **Wave 1** — lexer.
- **Wave 2** — declaration/type parser (expressions depend on type names for casts).

## Suggested Role Assignment
`parser-engineer`

## Test Corpus Expectations
- Parse `011`, `017..023` from `phase1/c11-ref/` and produce AST; compare against golden snapshots.
- Specific tests for `_Generic` and designated initializers.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with phase2/zcc/src/parse.zig and phase2/zcc/src/ast.zig, then review the Wave 1 lexer and Wave 2 declaration/type parser dependencies. Run the parser against phase1/c11-ref/011.c and 017.c through 023.c, plus 001.c and 010.c, and compare AST output with golden snapshots; done means all listed grammar cases parse and snapshots are stable.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, zig
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.