aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-13 13:40:57 +0000
committer_ov4 <ov4@ov4.org>2026-10-13 13:40:57 +0000
commitf5a2541ed3faf9a942b867e2d54577352153afce (patch)
treed5f737fdb8d77dc67d46cc12f8603c7df6a168c7 /include
parent5b08d59dba28b99cf991c02e837297fbfdb190c9 (diff)
Refactor record fields to preserve visibility and share parsing
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Diffstat (limited to 'include')
-rw-r--r--include/cps/Parser.h4
-rw-r--r--include/cps/TypeAST.h1
-rw-r--r--include/cps/TypeSystem.h5
3 files changed, 8 insertions, 2 deletions
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<DesignatorAccess> &Out);
std::unique_ptr<StmtAST> ParseTypeDecl();
- bool ParseRecordField(std::vector<RecordFieldDecl> &Out);
+ std::optional<std::vector<RecordFieldDecl>> ParseRecordBody(
+ const std::string &Name, int Line, int EndToken);
+ bool ParseRecordField(std::vector<RecordFieldDecl> &Out, bool IsPublic);
std::unique_ptr<StmtAST> ParseFunction();
std::unique_ptr<StmtAST> 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 <name> = (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<std::string> &Values,
std::string &Err);
bool defineRecord(const std::string &Name,
- const std::vector<std::pair<std::string, std::string>> &Fields,
+ const std::vector<RecordFieldDecl> &Fields,
std::string &Err);
bool definePointer(const std::string &Name,
const std::string &PointeeName,