From a6d3fedf836430e8174438c3f2692440314927be Mon Sep 17 00:00:00 2001 From: dimgigov Date: Sun, 31 May 2026 18:35:04 +0300 Subject: [PATCH] Phase 7.10: extend struct field support to 64 fields, add field4-7 in parser Parser (src_bux/parser.bux): - Increased struct field limit from 8 to 64 - Added field4-field7 slots in struct field assignment - Safeguard: fields beyond slot 7 are parsed but not stored (counted only) Known issues: - buxc2 segfaults on ast.bux (Decl struct has 30+ fields, sizeof mismatch between Bux parser's Decl and C compiler's Decl) - Full bootstrap requires Decl struct in ast.bux to match actual Decl layout All 18 examples pass, all unit tests pass. --- _selfhost/src/parser.bux | 14 +++++++++++++- src_bux/parser.bux | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/_selfhost/src/parser.bux b/_selfhost/src/parser.bux index 2e93a1b..ba897bc 100644 --- a/_selfhost/src/parser.bux +++ b/_selfhost/src/parser.bux @@ -744,7 +744,7 @@ func parserParseStructDecl(p: *Parser, isPublic: bool) -> *Decl { discard parserExpect(p, tkLBrace, "expected '{'"); while !parserCheck(p, tkRBrace) && parserPeek(p, 0) != tkEndOfFile { - if d.fieldCount >= 8 { break; } + if d.fieldCount >= 64 { break; } if parserCheck(p, tkNewLine) { discard parserAdvance(p); continue; } if parserCheck(p, tkSemicolon) { discard parserAdvance(p); continue; } let beforePos: int = p.pos; @@ -770,6 +770,18 @@ func parserParseStructDecl(p: *Parser, isPublic: bool) -> *Decl { } else if d.fieldCount == 3 { d.field3.name = fName.text; d.field3.refFieldType = fType; + } else if d.fieldCount == 4 { + d.field4.name = fName.text; + d.field4.refFieldType = fType; + } else if d.fieldCount == 5 { + d.field5.name = fName.text; + d.field5.refFieldType = fType; + } else if d.fieldCount == 6 { + d.field6.name = fName.text; + d.field6.refFieldType = fType; + } else if d.fieldCount == 7 { + d.field7.name = fName.text; + d.field7.refFieldType = fType; } d.fieldCount = d.fieldCount + 1; } diff --git a/src_bux/parser.bux b/src_bux/parser.bux index 2e93a1b..ba897bc 100644 --- a/src_bux/parser.bux +++ b/src_bux/parser.bux @@ -744,7 +744,7 @@ func parserParseStructDecl(p: *Parser, isPublic: bool) -> *Decl { discard parserExpect(p, tkLBrace, "expected '{'"); while !parserCheck(p, tkRBrace) && parserPeek(p, 0) != tkEndOfFile { - if d.fieldCount >= 8 { break; } + if d.fieldCount >= 64 { break; } if parserCheck(p, tkNewLine) { discard parserAdvance(p); continue; } if parserCheck(p, tkSemicolon) { discard parserAdvance(p); continue; } let beforePos: int = p.pos; @@ -770,6 +770,18 @@ func parserParseStructDecl(p: *Parser, isPublic: bool) -> *Decl { } else if d.fieldCount == 3 { d.field3.name = fName.text; d.field3.refFieldType = fType; + } else if d.fieldCount == 4 { + d.field4.name = fName.text; + d.field4.refFieldType = fType; + } else if d.fieldCount == 5 { + d.field5.name = fName.text; + d.field5.refFieldType = fType; + } else if d.fieldCount == 6 { + d.field6.name = fName.text; + d.field6.refFieldType = fType; + } else if d.fieldCount == 7 { + d.field7.name = fName.text; + d.field7.refFieldType = fType; } d.fieldCount = d.fieldCount + 1; }