summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCpp/Parser.cpp
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2021-07-28 05:37:52 +0430
committerAndreas Kling <kling@serenityos.org>2021-08-02 01:03:59 +0200
commitb3cbe1456969586994c0612f46a5ce9c55a41f25 (patch)
tree0267db987f8229c6118ccdbd4cd84c4cb8affaaf /Userland/Libraries/LibCpp/Parser.cpp
parent331911412745eded57f5e5c461d4cd7fbcdedb68 (diff)
downloadserenity-b3cbe1456969586994c0612f46a5ce9c55a41f25.zip
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.
Diffstat (limited to 'Userland/Libraries/LibCpp/Parser.cpp')
-rw-r--r--Userland/Libraries/LibCpp/Parser.cpp8
1 files changed, 8 insertions, 0 deletions
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<FunctionDeclaration> 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<FunctionDefinition> 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;