ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::expressions::detail::AST Struct Referenceabstract

Description:

Base class for nodes of abstract syntax trees of module ALib Expressions. Note that AST objects (and their data) are allocated in a MonoAllocator and hence have empty destructors.

Definition at line 15 of file ast_impl.inl.

Inheritance diagram for alib::expressions::detail::AST:
[legend]
Collaboration diagram for alib::expressions::detail::AST:
[legend]

Public Field Index:

integer Position
 Position in the original expression string.
 
- Public Field Index: inherited from alib::expressions::detail::ASTBase
Types NodeType
 Type of derived this AST node.
 

Public Method Index:

 AST ()=delete
 Deleted default constructor.
 
 AST (Types type, integer position)
 
virtual ~AST ()
 Virtual destructor.
 
virtual void Assemble (Program &program, MonoAllocator &allocator, AString &normalized)=0
 
virtual ASTOptimize (Normalization normalization)=0
 
- Public Method Index: inherited from alib::expressions::detail::ASTBase
 ASTBase (Types type)
 

Additional Inherited Members

- Public Type Index: inherited from alib::expressions::detail::ASTBase
enum class  Types {
  Literal , Identifier , Function , UnaryOp ,
  BinaryOp , TernaryOp
}
 The type of node. More...
 

Field Details:

◆ Position

integer alib::expressions::detail::AST::Position

Position in the original expression string.

Definition at line 18 of file ast_impl.inl.

Constructor(s) / Destructor Details:

◆ AST()

alib::expressions::detail::AST::AST ( Types type,
integer position )
inline

Constructor

Parameters
typeThe node type.
positionThe index of this AST in the expression string.

Definition at line 26 of file ast_impl.inl.

Here is the call graph for this function:

◆ ~AST()

virtual alib::expressions::detail::AST::~AST ( )
inlinevirtual

Virtual destructor.

Definition at line 32 of file ast_impl.inl.

Method Details:

◆ Assemble()

virtual void alib::expressions::detail::AST::Assemble ( Program & program,
MonoAllocator & allocator,
AString & normalized )
pure virtual

Recursively compiles nested nodes and invokes one of the add-methods of program for itself.

Parameters
programThe program to be compiled.
allocatorAn allocator usable for temporary objects. Its memory is invalid after the compilation process.
[out]normalizedThe normalized string, built during recursive compilation of the AST.

Implemented in alib::expressions::detail::ASTBinaryOp, alib::expressions::detail::ASTConditional, alib::expressions::detail::ASTFunction, alib::expressions::detail::ASTIdentifier, alib::expressions::detail::ASTLiteral, and alib::expressions::detail::ASTUnaryOp.

◆ Optimize()

virtual AST * alib::expressions::detail::AST::Optimize ( Normalization normalization)
pure virtual

Recursively walks through the tree and performs optimizations, dependent on given flags.

As of today, the only optimization performed in this AST itself is to combine nested unary '+' and '-' operators on literals.

Parameters
normalizationThe compiler flags denoting the normalization settings.
Returns
A potentially replaced AST or itself.

Implemented in alib::expressions::detail::ASTBinaryOp, alib::expressions::detail::ASTConditional, alib::expressions::detail::ASTFunction, alib::expressions::detail::ASTIdentifier, alib::expressions::detail::ASTLiteral, and alib::expressions::detail::ASTUnaryOp.

Here is the call graph for this function:

The documentation for this struct was generated from the following file: