aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-17 10:30:02 +0000
committer_ov4 <ov4@ov4.org>2026-10-17 10:30:02 +0000
commitf5246db6d045ffb86d6717e1b1c37f03bcb2b75b (patch)
tree468f4fba2e7ef75f29f90fd64af7d4e1fe05f50f /include
parent066a378ca09ccc5d8074a942cf4bf1b9d4f40729 (diff)
feat(parser): parse OVERLOAD prefix on FUNCTION and PROCEDURE
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'include')
-rw-r--r--include/cps/FunctionAST.h6
-rw-r--r--include/cps/Lexer.h1
-rw-r--r--include/cps/Parser.h4
3 files changed, 7 insertions, 4 deletions
diff --git a/include/cps/FunctionAST.h b/include/cps/FunctionAST.h
index 4dfe908..9995a4c 100644
--- a/include/cps/FunctionAST.h
+++ b/include/cps/FunctionAST.h
@@ -30,6 +30,7 @@ class PrototypeAST {
std::vector<ParamDecl> Params;
std::string ReturnType;
bool IsExternal;
+ bool IsOverload;
std::string OwnerClass;
bool IsPublic;
@@ -37,13 +38,14 @@ public:
PrototypeAST(const std::string &Name,
std::vector<ParamDecl> Params,
const std::string &ReturnType,
- bool IsExternal = false, std::string OwnerClass = {}, bool IsPublic = true)
- : Name(Name), Params(std::move(Params)), ReturnType(ReturnType), IsExternal(IsExternal),
+ bool IsExternal = false, std::string OwnerClass = {}, bool IsPublic = true, bool IsOverload = false)
+ : Name(Name), Params(std::move(Params)), ReturnType(ReturnType), IsExternal(IsExternal), IsOverload(IsOverload),
OwnerClass(std::move(OwnerClass)), IsPublic(IsPublic) {}
const std::string &getName() const { return Name; }
const std::vector<ParamDecl> &getParams() const { return Params; }
const std::string &getReturnType() const { return ReturnType; }
+ bool isOverload() const { return IsOverload; }
bool isExternal() const { return IsExternal; }
const std::string &getOwnerClass() const { return OwnerClass; }
bool isPublic() const { return IsPublic; }
diff --git a/include/cps/Lexer.h b/include/cps/Lexer.h
index 957ca48..40f168e 100644
--- a/include/cps/Lexer.h
+++ b/include/cps/Lexer.h
@@ -67,6 +67,7 @@ enum Token {
tok_colon = -300, // :
+ tok_overload = -399,
tok_function = -400,
tok_endfunction = -401,
tok_return = -402,
diff --git a/include/cps/Parser.h b/include/cps/Parser.h
index 9a53e95..d9e8358 100644
--- a/include/cps/Parser.h
+++ b/include/cps/Parser.h
@@ -73,8 +73,8 @@ class Parser {
std::vector<std::unique_ptr<FunctionDefAST>> *Methods = nullptr);
bool ParseRecordField(std::vector<RecordFieldDecl> &Out, bool IsPublic);
- std::unique_ptr<FunctionDefAST> ParseFunction(const std::string &OwnerClass = {}, bool IsPublic = true);
- std::unique_ptr<FunctionDefAST> ParseProcedure(const std::string &OwnerClass = {}, bool IsPublic = true);
+ std::unique_ptr<FunctionDefAST> ParseFunction(const std::string &OwnerClass = {}, bool IsPublic = true, bool IsOverload = false);
+ std::unique_ptr<FunctionDefAST> ParseProcedure(const std::string &OwnerClass = {}, bool IsPublic = true, bool IsOverload = false);
std::unique_ptr<StmtAST> ParseCallStmt();
std::unique_ptr<StmtAST> ParseReturnStmt();
std::optional<std::vector<ParamDecl>> ParsePrototypeArgs(bool AllowByRef);