summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorItamar <itamar8910@gmail.com>2021-02-06 15:48:46 +0200
committerAndreas Kling <kling@serenityos.org>2021-02-08 23:10:38 +0100
commit2d2b3ba5edc794a75a42d3dc14aca811b9d26592 (patch)
tree875191f45d5d39c87b6593bd1b27e0833ce453e9 /Userland
parent8ed65d7b486fdee170e98f727f2788769cb9c406 (diff)
downloadserenity-2d2b3ba5edc794a75a42d3dc14aca811b9d26592.zip
LibCpp: Include CPP_DEBUG in AK/Debug.h
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibCpp/Parser.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/Userland/Libraries/LibCpp/Parser.cpp b/Userland/Libraries/LibCpp/Parser.cpp
index d9a5c8cc98..c5d00d5c6d 100644
--- a/Userland/Libraries/LibCpp/Parser.cpp
+++ b/Userland/Libraries/LibCpp/Parser.cpp
@@ -24,8 +24,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-// #define CPP_DEBUG
-
#ifdef CPP_DEBUG
# define DEBUG_SPAM
#endif
@@ -33,6 +31,7 @@
#include "Parser.h"
#include "AK/LogStream.h"
#include "AST.h"
+#include <AK/Debug.h>
#include <AK/ScopeGuard.h>
#include <AK/ScopeLogger.h>
#include <LibCpp/Lexer.h>
@@ -49,7 +48,7 @@ Parser::Parser(const StringView& program)
continue;
m_tokens.append(move(token));
}
-#ifdef CPP_DEBUG
+#if CPP_DEBUG
dbgln("Program:");
dbgln("{}", m_program);
dbgln("Tokens:");
@@ -229,10 +228,12 @@ bool Parser::match_variable_declaration()
save_state();
ScopeGuard state_guard = [this] { load_state(); };
+ // Type
if (!peek(Token::Type::KnownType).has_value() && !peek(Token::Type::Identifier).has_value())
return false;
consume();
+ // Identifier
if (!peek(Token::Type::Identifier).has_value())
return false;
consume();
@@ -243,9 +244,10 @@ bool Parser::match_variable_declaration()
error("initial value of variable is not an expression");
return false;
}
+ return true;
}
- return true;
+ return match(Token::Type::Semicolon);
}
NonnullRefPtr<VariableDeclaration> Parser::parse_variable_declaration(ASTNode& parent)
@@ -706,7 +708,7 @@ void Parser::error(StringView message)
m_tokens[m_state.token_index].m_start.column);
}
m_errors.append(formatted_message);
- dbgln("{}", formatted_message);
+ dbgln<CPP_DEBUG>("{}", formatted_message);
}
bool Parser::match_expression()
@@ -1019,5 +1021,4 @@ NonnullRefPtr<IfStatement> Parser::parse_if_statement(ASTNode& parent)
}
return if_statement;
}
-
}