diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-18 06:09:01 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-18 06:09:01 +0000 |
| commit | b17f101cfc75565f9991c856ec62f1e17b0ab104 (patch) | |
| tree | 6c925f06c45dbaa557a0451cfca33f17be71ec67 /lib/Parser/ParserFunction.cc | |
| parent | 16231050058131860f710073c17d3bca7c6637eb (diff) | |
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 <noreply@anthropic.com>
Diffstat (limited to 'lib/Parser/ParserFunction.cc')
| -rw-r--r-- | lib/Parser/ParserFunction.cc | 17 |
1 files changed, 14 insertions, 3 deletions
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<StmtAST> Parser::ParseExternDecl() { std::unique_ptr<StmtAST> 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<DesignatorAccess> Accesses; if (!ParseDesignatorSuffix(Accesses)) return nullptr; |
