From b3cbe1456969586994c0612f46a5ce9c55a41f25 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Wed, 28 Jul 2021 05:37:52 +0430 Subject: [PATCH] LibCpp: Allow 'const' after a function's signature This is too lax for functions that aren't class members, but let's allow that anyway. --- Userland/Libraries/LibCpp/Parser.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Userland/Libraries/LibCpp/Parser.cpp b/Userland/Libraries/LibCpp/Parser.cpp index 64c814d717..d41bb415be 100644 --- a/Userland/Libraries/LibCpp/Parser.cpp +++ b/Userland/Libraries/LibCpp/Parser.cpp @@ -132,6 +132,11 @@ NonnullRefPtr Parser::parse_function_declaration(ASTNode& p consume(Token::Type::RightParen); + if (match_keyword("const")) { + consume(); + // FIXME: Note that this function is supposed to be a class member, and `this` has to be const, somehow. + } + RefPtr body; Position func_end {}; if (peek(Token::Type::LeftCurly).has_value()) { @@ -739,6 +744,9 @@ bool Parser::match_function_declaration() while (consume().type() != Token::Type::RightParen && !eof()) { }; + if (match_keyword("const")) + consume(); + if (peek(Token::Type::Semicolon).has_value() || peek(Token::Type::LeftCurly).has_value()) return true;