Repository navigation
Refactor nested GrammarExpr sequences to FormalProduction flat-list rhs across extdeps Wave-1/2a language files (prereqs met: #3796 + #3805 on main) - #3837
Conversation
…for all Wave-1/2a language files Converts XxxGrammarRelationRow.production from GrammarProduction to FormalProduction across all remaining extdeps language files: cpp, java, kotlin (plus fixes to the WIP partial work on go and wasm). - cpp/java/kotlin: add formal_terminal_symbol + formal_rhs + formal_production helpers; update relation row type + constructor; switch grammar_relation_row_node to formal_production_to_node; add FormalProduction/FormalTerminal/etc. to grammar imports - go: fix incomplete WIP — emitted no longer from row.production.emitted (GrammarProduction field); use go_mvp1_emitted_add_fn_node() directly since GoGrammarRelationRow has no emitted field - wasm: add missing formal terminal/rhs/production helpers GrammarProduction + GrammarExpr scaffold retained for grammar roots (CP-1b dual-carrier hold). All 273 files compile with 0 diagnostics. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Superseded by #3828 (valiant-boar-99) which covers all 10 files including dag.dag and python.dag. Good work on the local validation — the broader PR will carry this forward. |
briansrls
left a comment
There was a problem hiding this comment.
Review metadata
- Provider / model:
codex/unknown - Commit:
3dfab499· Trigger:schedule - Thinking:
236s wall
BLOCKING (2)
Root Cause
src/v4/extdeps/languages/go.dagFormalProduction correctly carries only lhs/rhs, but GoGrammarRelationRow was not widened to carry emitted output after that split → add an emitted Node field or shared relation carrier and project row.emitted.src/v4/extdeps/languages/kotlin.dagKotlinGrammarRelationRow still derives only production/tokens after FormalProduction drops emitted → model emitted on the row or shared grammar-relation carrier and have the projection consume that field.
| go_named_edge(name: grammar_relation_field_production, target: grammar_production_to_node(production: row.production)), | ||
| go_named_edge(name: grammar_relation_field_emitted, target: row.production.emitted), | ||
| go_named_edge(name: grammar_relation_field_production, target: formal_production_to_node(production: row.production)), | ||
| go_named_edge(name: grammar_relation_field_emitted, target: go_mvp1_emitted_add_fn_node()), |
There was a problem hiding this comment.
BLOCKING: The relation-row projection now fabricates the MVP1 emitted node instead of reading an emitted fact from the row, so replacing GrammarProduction with FormalProduction silently drops emission authority and violates INVARIANTS.md P2 facts-flow-forward.
| kotlin_named_edge( | ||
| name: grammar_relation_field_emitted, | ||
| target: production.emitted | ||
| target: kotlin_mvp1_emitted_add_fn_node() |
There was a problem hiding this comment.
BLOCKING: The relation-row projection hardcodes kotlin_mvp1_emitted_add_fn_node after switching to FormalProduction, leaving emitted output outside the row’s typed authority and violating INVARIANTS.md P2 single-authority/facts-flow-forward.
Summary
Converts
XxxGrammarRelationRow.productionfromGrammarProduction(with nestedGrammarExpr Sequencetree) toFormalProduction(flatList<FormalGrammarSymbol>rhs) across all Wave-1/2a extdeps language files. This is the forward step enabled byformal_production_to_nodelanding in grammar.dag (#3805) and completes the T-4.17 grammar-as-data migration for the relation-row carrier type.Files changed:
cpp.dag,java.dag,kotlin.dag,go.dag,wasm.dag(plus the WIP commit already on branch coveringrust.dag,swift.dag,typescript.dag).Per-file changes:
cpp/java/wasm: addxxx_formal_terminal_symbol,xxx_formal_rhs_from_token_classes,xxx_formal_production_mvp1_fn_addhelpers; updateXxxGrammarRelationRow.productiontype; switchxxx_grammar_relation_row_nodetoformal_production_to_node; addFormalProduction/FormalTerminal/FormalTerminalOccurrence/FormalNonterminal/FormalGrammarSymbol/formal_production_to_nodeto grammar imports, removegrammar_production_to_nodekotlin: addkotlin_formal_production_from_nonemptyhelper; updatekotlin_grammar_relation_row_nodeto use formal production +formal_production_to_node+ directkotlin_mvp1_emitted_add_fn_node()callgo: fix incomplete WIP —row.production.emittedaccess fails now thatproductionisFormalProduction; usego_mvp1_emitted_add_fn_node()directlyrust/swift/typescript: already covered by WIP commit on branchGrammarProduction/GrammarExprscaffold retained for grammar roots (CP-1b dual-carrier hold). TheGramBuild1State+grammar_sequence_from_token_classesadapters are preserved as they still serve grammar root builders.Test plan
ctrl-build -- cargo run -p v2-compiler --bin v2-compiler -- compile --source-root src/v4 --output-dir /tmp/gunbc-v4-check-sleek-ferret→compiled: 273 files emitted, 0 diagnosticspython3 scripts/strict_deprose_dag.py --check→OK