From b17f101cfc75565f9991c856ec62f1e17b0ab104 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Sun, 18 Oct 2026 06:09:01 +0000 Subject: feat(operators): add member and unary overloads with explicit calls Select member and global candidates together, enforce private access, and reuse argument marshalling. Materialize temporary receivers for chaining and register them for the existing object cleanup mechanism. Co-Authored-By: Claude Opus 5.5 --- lib/Parser/ParserFunction.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'lib/Parser/ParserFunction.cc') diff --git a/lib/Parser/ParserFunction.cc b/lib/Parser/ParserFunction.cc index 3ff54da..dfb689a 100644 --- a/lib/Parser/ParserFunction.cc +++ b/lib/Parser/ParserFunction.cc @@ -140,6 +140,10 @@ std::string Parser::ParseOperatorName(int &Op) { return {}; } getNextToken(); + if (CurTok != '(') { + sourceDiagnostic(Lex.getLine(), "error: Expected '(' after operator name at line %d\n", Lex.getLine()); + return {}; + } return operatorName(Op); } @@ -339,13 +343,20 @@ std::unique_ptr Parser::ParseExternDecl() { std::unique_ptr Parser::ParseCallStmt() { int Line = Lex.getLine(); getNextToken(); - if (CurTok != tok_identifier) { + if (CurTok != tok_identifier && CurTok != tok_operator) { cps::sourceDiagnostic(Lex.getLine(), "error: Expected callee name after CALL\n"); return nullptr; } - std::string Callee = Lex.IdentifierStr; - getNextToken(); + std::string Callee; + if (CurTok == tok_operator) { + int Op; + Callee = ParseOperatorName(Op); + if (Callee.empty()) return nullptr; + } else { + Callee = Lex.IdentifierStr; + getNextToken(); + } std::vector Accesses; if (!ParseDesignatorSuffix(Accesses)) return nullptr; -- cgit v1.3.1-4-g156e