From f5a2541ed3faf9a942b867e2d54577352153afce Mon Sep 17 00:00:00 2001 From: _ov4 Date: Tue, 13 Oct 2026 13:40:57 +0000 Subject: Refactor record fields to preserve visibility and share parsing Co-Authored-By: Claude Fable 5.1 --- include/cps/Parser.h | 4 +++- include/cps/TypeAST.h | 1 + include/cps/TypeSystem.h | 5 ++++- 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/cps/Parser.h b/include/cps/Parser.h index 49f418c..7344015 100644 --- a/include/cps/Parser.h +++ b/include/cps/Parser.h @@ -49,7 +49,9 @@ class Parser { bool ParseDesignatorSuffix(std::vector &Out); std::unique_ptr ParseTypeDecl(); - bool ParseRecordField(std::vector &Out); + std::optional> ParseRecordBody( + const std::string &Name, int Line, int EndToken); + bool ParseRecordField(std::vector &Out, bool IsPublic); std::unique_ptr ParseFunction(); std::unique_ptr ParseProcedure(); diff --git a/include/cps/TypeAST.h b/include/cps/TypeAST.h index d349859..601b49b 100644 --- a/include/cps/TypeAST.h +++ b/include/cps/TypeAST.h @@ -15,6 +15,7 @@ namespace cps { struct RecordFieldDecl { std::string Name; std::string TypeName; + bool IsPublic = true; // TYPE fields are always public. }; // TYPE = (value1, value2, ...) diff --git a/include/cps/TypeSystem.h b/include/cps/TypeSystem.h index 06ffe96..2ef1cd6 100644 --- a/include/cps/TypeSystem.h +++ b/include/cps/TypeSystem.h @@ -11,6 +11,8 @@ namespace cps { +struct RecordFieldDecl; + // Enum ordinals are 0-based: DECLARE zero-init and array memset(0) then // produce the first enumerator, a valid value. inline constexpr int64_t kEnumOrdinalBase = 0; @@ -35,6 +37,7 @@ enum class TypeKind { struct RecordFieldInfo { std::string TypeName; unsigned Index = 0; // struct field index + bool IsPublic = true; }; struct RecordPayload { @@ -117,7 +120,7 @@ public: const std::vector &Values, std::string &Err); bool defineRecord(const std::string &Name, - const std::vector> &Fields, + const std::vector &Fields, std::string &Err); bool definePointer(const std::string &Name, const std::string &PointeeName, -- cgit v1.3.1-4-g156e