mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
65 lines
2.2 KiB
C++
65 lines
2.2 KiB
C++
#ifndef POLSERVER_SOURCEFILEPROCESSOR_H
|
|
#define POLSERVER_SOURCEFILEPROCESSOR_H
|
|
|
|
#include <EscriptGrammar/EscriptParserBaseVisitor.h>
|
|
|
|
#include <memory>
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
#include "bscript/compiler/astbuilder/ProgramBuilder.h"
|
|
#include "bscript/compiler/model/UserFunctionInclusion.h"
|
|
|
|
namespace Pol::Bscript::Compiler
|
|
{
|
|
class Profile;
|
|
class SourceFile;
|
|
|
|
class SourceFileProcessor : public EscriptGrammar::EscriptParserBaseVisitor
|
|
{
|
|
public:
|
|
SourceFileProcessor( const SourceFileIdentifier&, BuilderWorkspace&, bool is_src,
|
|
UserFunctionInclusion );
|
|
|
|
public:
|
|
void use_module( const std::string& name, SourceLocation& including_location,
|
|
long long* micros_counted = nullptr );
|
|
void process_source( SourceFile& );
|
|
void process_include( SourceFile&, long long* micros_counted );
|
|
|
|
void handle_include_declaration( EscriptGrammar::EscriptParser::IncludeDeclarationContext*,
|
|
long long* micros_counted );
|
|
std::optional<std::string> locate_include_file( const SourceLocation& source_location,
|
|
const std::string& include_name );
|
|
|
|
void handle_use_declaration( EscriptGrammar::EscriptParser::UseDeclarationContext*,
|
|
long long* micros_counted );
|
|
|
|
antlrcpp::Any visitIncludeDeclaration(
|
|
EscriptGrammar::EscriptParser::IncludeDeclarationContext* ) override;
|
|
antlrcpp::Any visitFunctionDeclaration(
|
|
EscriptGrammar::EscriptParser::FunctionDeclarationContext* ) override;
|
|
antlrcpp::Any visitProgramDeclaration(
|
|
EscriptGrammar::EscriptParser::ProgramDeclarationContext* ) override;
|
|
antlrcpp::Any visitStatement( EscriptGrammar::EscriptParser::StatementContext* ) override;
|
|
antlrcpp::Any visitUseDeclaration(
|
|
EscriptGrammar::EscriptParser::UseDeclarationContext* ) override;
|
|
|
|
SourceLocation location_for( antlr4::ParserRuleContext& ) const;
|
|
|
|
protected:
|
|
Profile& profile;
|
|
Report& report;
|
|
const SourceFileIdentifier& source_file_identifier;
|
|
BuilderWorkspace& workspace;
|
|
|
|
ProgramBuilder tree_builder;
|
|
|
|
private:
|
|
const bool is_src;
|
|
const UserFunctionInclusion user_function_inclusion;
|
|
};
|
|
|
|
} // namespace Pol::Bscript::Compiler
|
|
|
|
#endif // POLSERVER_SOURCEFILEPROCESSOR_H
|