Bash++
Bash++ compiler internal documentation
Public Member Functions | Protected Attributes | Friends | List of all members
AST::ASTNode Class Referenceabstract

The base class for all non-terminal nodes in the Bash++ AST. Each ASTNode contains information about its type, children, and position in the source code. More...

#include <ASTNode.h>

Inheritance diagram for AST::ASTNode:
Inheritance graph
[legend]
Collaboration diagram for AST::ASTNode:
Collaboration graph
[legend]

Public Member Functions

 ASTNode ()=default
 
virtual constexpr AST::NodeType getType () const =0
 
void addChild (const std::shared_ptr< ASTNode > &child)
 Add a child node to this AST node. This function also:
 
void addChildren (const std::vector< std::shared_ptr< ASTNode > > &childs)
 Add a vector of child nodes to this AST node. This function also:
 
const std::vector< std::shared_ptr< ASTNode > > & getChildren () const
 
void setPosition (const AST::FilePosition &pos)
 
void setPosition (uint32_t line, uint32_t column)
 
const AST::FilePositiongetPosition () const
 
void setEndPosition (const AST::FilePosition &pos)
 
void setEndPosition (uint32_t line, uint32_t column)
 
const AST::FilePositiongetEndPosition () const
 
uint32_t getLine () const
 
uint32_t getCharPositionInLine () const
 
std::shared_ptr< ASTNodegetChildAt (size_t index) const
 
std::shared_ptr< ASTNodegetFirstChild () const
 
std::shared_ptr< ASTNodegetLastChild () const
 
size_t getChildrenCount () const
 
void clear ()
 
void clearChildren ()
 
virtual std::ostream & prettyPrint (std::ostream &os, int indentation_level=0) const =0
 

Protected Attributes

std::vector< std::shared_ptr< ASTNode > > children
 
AST::FilePosition position
 
AST::FilePosition end_position
 

Friends

std::ostream & operator<< (std::ostream &os, const ASTNode &node)
 

Detailed Description

The base class for all non-terminal nodes in the Bash++ AST. Each ASTNode contains information about its type, children, and position in the source code.

Constructor & Destructor Documentation

◆ ASTNode()

AST::ASTNode::ASTNode ( )
default

Member Function Documentation

◆ addChild()

void AST::ASTNode::addChild ( const std::shared_ptr< ASTNode > &  child)

Add a child node to this AST node. This function also:

  1. Filters out null child nodes
  2. Merges consecutive RawText nodes into a single RawText node to optimize the AST structure.
Parameters
childThe child AST node to add.

◆ addChildren()

void AST::ASTNode::addChildren ( const std::vector< std::shared_ptr< ASTNode > > &  childs)

Add a vector of child nodes to this AST node. This function also:

  1. Filters out null child nodes
  2. Merges consecutive RawText nodes into a single RawText node to optimize the AST structure.
Parameters
childsThe vector of child AST nodes to add.

◆ clear()

void AST::ASTNode::clear ( )

◆ clearChildren()

void AST::ASTNode::clearChildren ( )

◆ getCharPositionInLine()

uint32_t AST::ASTNode::getCharPositionInLine ( ) const

◆ getChildAt()

std::shared_ptr< ASTNode > AST::ASTNode::getChildAt ( size_t  index) const

◆ getChildren()

const std::vector< std::shared_ptr< ASTNode > > & AST::ASTNode::getChildren ( ) const

◆ getChildrenCount()

size_t AST::ASTNode::getChildrenCount ( ) const

◆ getEndPosition()

const AST::FilePosition & AST::ASTNode::getEndPosition ( ) const

◆ getFirstChild()

std::shared_ptr< ASTNode > AST::ASTNode::getFirstChild ( ) const

◆ getLastChild()

std::shared_ptr< ASTNode > AST::ASTNode::getLastChild ( ) const

◆ getLine()

uint32_t AST::ASTNode::getLine ( ) const

◆ getPosition()

const AST::FilePosition & AST::ASTNode::getPosition ( ) const

◆ getType()

virtual constexpr AST::NodeType AST::ASTNode::getType ( ) const
constexprpure virtual

◆ prettyPrint()

virtual std::ostream & AST::ASTNode::prettyPrint ( std::ostream &  os,
int  indentation_level = 0 
) const
pure virtual

◆ setEndPosition() [1/2]

void AST::ASTNode::setEndPosition ( const AST::FilePosition pos)

◆ setEndPosition() [2/2]

void AST::ASTNode::setEndPosition ( uint32_t  line,
uint32_t  column 
)

◆ setPosition() [1/2]

void AST::ASTNode::setPosition ( const AST::FilePosition pos)

◆ setPosition() [2/2]

void AST::ASTNode::setPosition ( uint32_t  line,
uint32_t  column 
)

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const ASTNode node 
)
friend

Member Data Documentation

◆ children

std::vector<std::shared_ptr<ASTNode> > AST::ASTNode::children
protected

◆ end_position

AST::FilePosition AST::ASTNode::end_position
protected

◆ position

AST::FilePosition AST::ASTNode::position
protected

The documentation for this class was generated from the following files: