polserver/pol-core/bscript/compiler/astbuilder/TreeBuilder.cpp
turleypol 1463b76c7c
Includes are now all relative to pol-core basefolder (#906)
* all except pol

* pol and includes under defines

* something weird has happened

* remove own folder from include searchpath

* fixed remaining, adapted include style for external headers

* missing include
2026-07-25 23:01:18 +02:00

44 lines
1.3 KiB
C++

#include "bscript/compiler/astbuilder/TreeBuilder.h"
#include "bscript/compiler/Antlr4Inc.h"
#include "bscript/compiler/ast/ValueConsumer.h"
#include "bscript/compiler/astbuilder/BuilderWorkspace.h"
#include "bscript/compiler/file/SourceLocation.h"
namespace Pol::Bscript::Compiler
{
TreeBuilder::TreeBuilder( const SourceFileIdentifier& source_file_identifier,
BuilderWorkspace& workspace )
: report( workspace.report ),
source_file_identifier( source_file_identifier ),
workspace( workspace )
{
}
std::unique_ptr<Expression> TreeBuilder::consume_expression_result(
std::unique_ptr<Expression> expression )
{
return std::make_unique<ValueConsumer>( expression->source_location, std::move( expression ) );
}
SourceLocation TreeBuilder::location_for( antlr4::ParserRuleContext& ctx ) const
{
return SourceLocation( &source_file_identifier, ctx );
}
SourceLocation TreeBuilder::location_for( antlr4::tree::TerminalNode& ctx ) const
{
return SourceLocation( &source_file_identifier, ctx );
}
std::string TreeBuilder::text( antlr4::tree::TerminalNode* terminal )
{
return terminal->getSymbol()->getText();
}
std::string TreeBuilder::text( antlr4::Token* token )
{
return token->getText();
}
} // namespace Pol::Bscript::Compiler