From e847e4c53cf21fcb96f7ed7765e305a7ec8e6c19 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Sat, 17 Oct 2026 08:31:27 +0000 Subject: feat(classes): parse DELETE destructor methods and DELETE statement Co-Authored-By: Claude Opus 5.5 --- lib/Parser/Parser.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lib/Parser/Parser.cc') 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> 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 Parser::ParseStatement() { } std::unique_ptr 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 Accesses; + if (!ParseDesignatorSuffix(Accesses)) return nullptr; + auto Target = std::make_unique(Name, std::move(Accesses), Line); + return std::make_unique(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()); -- cgit v1.3.1-4-g156e