mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:17:44 +00:00
LibCpp: Return empty TranslationUnit from Parser::parse() if no tokens exist
Fixes #5704. Fixes #5825. Fixes #5827.
This commit is contained in:
parent
8e84ca6b16
commit
6c8185151e
1 changed files with 2 additions and 0 deletions
|
@ -75,6 +75,8 @@ void Parser::initialize_program_tokens(const StringView& program)
|
||||||
NonnullRefPtr<TranslationUnit> Parser::parse()
|
NonnullRefPtr<TranslationUnit> Parser::parse()
|
||||||
{
|
{
|
||||||
SCOPE_LOGGER();
|
SCOPE_LOGGER();
|
||||||
|
if (m_tokens.is_empty())
|
||||||
|
return create_root_ast_node({}, {});
|
||||||
auto unit = create_root_ast_node(m_tokens.first().start(), m_tokens.last().end());
|
auto unit = create_root_ast_node(m_tokens.first().start(), m_tokens.last().end());
|
||||||
while (!done()) {
|
while (!done()) {
|
||||||
if (match_comment()) {
|
if (match_comment()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue