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.
This commit is contained in:
2026-05-31 18:35:04 +03:00
parent 6744a35c03
commit a6d3fedf83
2 changed files with 26 additions and 2 deletions
+13 -1
View File
@@ -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;
}
+13 -1
View File
@@ -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;
}