diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-17 08:31:27 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-17 08:31:27 +0000 |
| commit | e847e4c53cf21fcb96f7ed7765e305a7ec8e6c19 (patch) | |
| tree | d065b2a3f0243df19e7013f433304d8032f83c7b /lib/Parser/Parser.cc | |
| parent | c372c08dc940db58f1da9cadeb64b4cb3c837704 (diff) | |
feat(classes): parse DELETE destructor methods and DELETE statement
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'lib/Parser/Parser.cc')
| -rw-r--r-- | lib/Parser/Parser.cc | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/Parser/Parser.cc b/lib/Parser/Parser.cc index d3b2daa..a7e7edf 100644 --- a/lib/Parser/Parser.cc +++ b/lib/Parser/Parser.cc @@ -45,7 +45,7 @@ std::vector<std::unique_ptr<StmtAST>> Parser::Parse() { void Parser::syncToStatementStart() { while (CurTok != tok_eof) { switch (CurTok) { - case tok_constant: case tok_declare: case tok_identifier: case tok_input: case tok_output: + case tok_delete: case tok_constant: case tok_declare: case tok_identifier: case tok_input: case tok_output: case tok_case: case tok_endcase: case tok_otherwise: case tok_if: case tok_while: case tok_repeat: case tok_for: case tok_function: case tok_procedure: case tok_call: case tok_return: @@ -94,6 +94,20 @@ std::unique_ptr<StmtAST> Parser::ParseStatement() { } std::unique_ptr<StmtAST> Parser::ParseStatementImpl() { + if (CurTok == tok_delete) { + int Line = Lex.getLine(); + getNextToken(); + if (CurTok != tok_identifier) { + fprintf(stderr, "error: DELETE requires an object designator at line %d\n", Line); + return nullptr; + } + std::string Name = Lex.IdentifierStr; + getNextToken(); + std::vector<DesignatorAccess> Accesses; + if (!ParseDesignatorSuffix(Accesses)) return nullptr; + auto Target = std::make_unique<DesignatorExprAST>(Name, std::move(Accesses), Line); + return std::make_unique<DeleteStmtAST>(std::move(Target)); + } if (CurTok == tok_case) return ParseCaseStmt(); if (CurTok == tok_endcase || CurTok == tok_otherwise) { fprintf(stderr, "error: Unexpected CASE terminator at line %d\n", Lex.getLine()); |
