Refactoring - Compiler & parser moved to separate header
This commit is contained in:
parent
0c9ca6c04e
commit
fd0df03428
7 changed files with 54 additions and 38 deletions
|
@ -217,12 +217,3 @@ class X_OpFailure : public std::exception
|
|||
};
|
||||
|
||||
} // namespace ops
|
||||
|
||||
|
||||
class T_OpsCompiler : public ebcl::A_PrivateImplementation
|
||||
{
|
||||
public:
|
||||
T_OpsCompiler( ) noexcept;
|
||||
|
||||
ops::P_OpProgram compile( T_OpsParserOutput const& input ) noexcept;
|
||||
};
|
||||
|
|
1
demo.cc
1
demo.cc
|
@ -3,6 +3,7 @@
|
|||
#include "sync.hh"
|
||||
#include "rendertarget.hh"
|
||||
#include "globals.hh"
|
||||
#include "opcomp.hh"
|
||||
#include <ebcl/Files.hh>
|
||||
#include <ebcl/SRDText.hh>
|
||||
|
||||
|
|
29
opast.hh
29
opast.hh
|
@ -1334,32 +1334,3 @@ class T_BinaryOperatorNode : public A_ExpressionNode
|
|||
|
||||
|
||||
} // namespace opast
|
||||
|
||||
|
||||
/*= PARSER ===================================================================*/
|
||||
|
||||
// Parser output. Consists in a root node as well as other details (table of
|
||||
// constants, data types, etc...)
|
||||
struct T_OpsParserOutput
|
||||
{
|
||||
opast::T_RootNode root;
|
||||
T_KeyValueTable< T_String , opast::E_DataType > types;
|
||||
};
|
||||
|
||||
// The actual parser
|
||||
class T_OpsParser : public ebcl::A_PrivateImplementation
|
||||
{
|
||||
private:
|
||||
T_Array< ebcl::T_SRDError > errors_;
|
||||
T_OwnPtr< T_OpsParserOutput > output_;
|
||||
|
||||
public:
|
||||
T_OpsParser( ) noexcept;
|
||||
|
||||
bool parse( ebcl::T_SRDList const& input ) noexcept;
|
||||
|
||||
T_Array< ebcl::T_SRDError > const& errors( ) const noexcept
|
||||
{ return errors_; }
|
||||
T_OwnPtr< T_OpsParserOutput > result( ) noexcept
|
||||
{ return std::move( output_ ); }
|
||||
};
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "externals.hh"
|
||||
#include "control.hh"
|
||||
#include "opcomp.hh"
|
||||
#include <ebcl/Algorithms.hh>
|
||||
|
||||
#define INVASIVE_TRACES
|
||||
|
|
50
opcomp.hh
Normal file
50
opcomp.hh
Normal file
|
@ -0,0 +1,50 @@
|
|||
#pragma once
|
||||
#ifndef REAL_BUILD
|
||||
# include "externals.hh"
|
||||
#endif
|
||||
#include <ebcl/SRDData.hh>
|
||||
|
||||
|
||||
/*= PARSER ===================================================================*/
|
||||
|
||||
namespace opast { class T_RootNode; }
|
||||
|
||||
// Parser output. Consists in a root node as well as other details (table of
|
||||
// constants, data types, etc...)
|
||||
struct T_OpsParserOutput
|
||||
{
|
||||
opast::T_RootNode root;
|
||||
T_KeyValueTable< T_String , opast::E_DataType > types;
|
||||
};
|
||||
|
||||
// The actual parser
|
||||
class T_OpsParser : public ebcl::A_PrivateImplementation
|
||||
{
|
||||
private:
|
||||
T_Array< ebcl::T_SRDError > errors_;
|
||||
T_OwnPtr< T_OpsParserOutput > output_;
|
||||
|
||||
public:
|
||||
T_OpsParser( ) noexcept;
|
||||
|
||||
bool parse( ebcl::T_SRDList const& input ) noexcept;
|
||||
|
||||
T_Array< ebcl::T_SRDError > const& errors( ) const noexcept
|
||||
{ return errors_; }
|
||||
T_OwnPtr< T_OpsParserOutput > result( ) noexcept
|
||||
{ return std::move( output_ ); }
|
||||
};
|
||||
|
||||
|
||||
/*= COMPILER ===================================================================*/
|
||||
|
||||
namespace ops { struct T_OpProgram; using P_OpProgram = T_OwnPtr< T_OpProgram >; }
|
||||
|
||||
// Generates bytecode based on the type-checked tree produced by the parser
|
||||
class T_OpsCompiler : public ebcl::A_PrivateImplementation
|
||||
{
|
||||
public:
|
||||
T_OpsCompiler( ) noexcept;
|
||||
|
||||
ops::P_OpProgram compile( T_OpsParserOutput const& input ) noexcept;
|
||||
};
|
|
@ -1,5 +1,6 @@
|
|||
#include "externals.hh"
|
||||
#include "opast.hh"
|
||||
#include "opcomp.hh"
|
||||
#include <ebcl/Algorithms.hh>
|
||||
|
||||
using namespace ebcl;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "externals.hh"
|
||||
#include "opast.hh"
|
||||
#include "control.hh"
|
||||
#include "opcomp.hh"
|
||||
#include <ebcl/Files.hh>
|
||||
#include <ebcl/SRDText.hh>
|
||||
#include <ebcl/Algorithms.hh>
|
||||
|
|
Loading…
Reference in a new issue