Skip to content

Commit 2d2b3ba

Browse files
itamar8910awesomekling
authored andcommitted
LibCpp: Include CPP_DEBUG in AK/Debug.h
1 parent 8ed65d7 commit 2d2b3ba

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

AK/Debug.h.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@
6666
#cmakedefine01 CPP_LANGUAGE_SERVER_DEBUG
6767
#endif
6868

69+
#ifndef CPP_DEBUG
70+
#cmakedefine01 CPP_DEBUG
71+
#endif
72+
6973
#ifndef CRYPTO_DEBUG
7074
#cmakedefine01 CRYPTO_DEBUG
7175
#endif

Userland/Libraries/LibCpp/Parser.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,14 @@
2424
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2525
*/
2626

27-
// #define CPP_DEBUG
28-
2927
#ifdef CPP_DEBUG
3028
# define DEBUG_SPAM
3129
#endif
3230

3331
#include "Parser.h"
3432
#include "AK/LogStream.h"
3533
#include "AST.h"
34+
#include <AK/Debug.h>
3635
#include <AK/ScopeGuard.h>
3736
#include <AK/ScopeLogger.h>
3837
#include <LibCpp/Lexer.h>
@@ -49,7 +48,7 @@ Parser::Parser(const StringView& program)
4948
continue;
5049
m_tokens.append(move(token));
5150
}
52-
#ifdef CPP_DEBUG
51+
#if CPP_DEBUG
5352
dbgln("Program:");
5453
dbgln("{}", m_program);
5554
dbgln("Tokens:");
@@ -229,10 +228,12 @@ bool Parser::match_variable_declaration()
229228
save_state();
230229
ScopeGuard state_guard = [this] { load_state(); };
231230

231+
// Type
232232
if (!peek(Token::Type::KnownType).has_value() && !peek(Token::Type::Identifier).has_value())
233233
return false;
234234
consume();
235235

236+
// Identifier
236237
if (!peek(Token::Type::Identifier).has_value())
237238
return false;
238239
consume();
@@ -243,9 +244,10 @@ bool Parser::match_variable_declaration()
243244
error("initial value of variable is not an expression");
244245
return false;
245246
}
247+
return true;
246248
}
247249

248-
return true;
250+
return match(Token::Type::Semicolon);
249251
}
250252

251253
NonnullRefPtr<VariableDeclaration> Parser::parse_variable_declaration(ASTNode& parent)
@@ -706,7 +708,7 @@ void Parser::error(StringView message)
706708
m_tokens[m_state.token_index].m_start.column);
707709
}
708710
m_errors.append(formatted_message);
709-
dbgln("{}", formatted_message);
711+
dbgln<CPP_DEBUG>("{}", formatted_message);
710712
}
711713

712714
bool Parser::match_expression()
@@ -1019,5 +1021,4 @@ NonnullRefPtr<IfStatement> Parser::parse_if_statement(ASTNode& parent)
10191021
}
10201022
return if_statement;
10211023
}
1022-
10231024
}

0 commit comments

Comments
 (0)