diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/cps/Parser.h | 4 | ||||
| -rw-r--r-- | include/cps/TypeAST.h | 1 | ||||
| -rw-r--r-- | include/cps/TypeSystem.h | 5 |
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, |
