PUMA Library Reference Manual
Loading...
Searching...
No Matches
Puma::CT_List Class Reference

#include <Puma/CTree.h>

Inheritance diagram for Puma::CT_List:

Description

Base class for tree nodes representing lists.

Public Types

enum  {
  OPEN = 1 ,
  CLOSE = 2 ,
  OPEN_CLOSE = 3 ,
  SEPARATORS = 4 ,
  FORCE_EMPTY = 8 ,
  END_SEP = 16 ,
  NO_LAST_SEP = 32 ,
  INTRO = 64
}
 List properties. More...

Public Member Functions

CT_List * IsList ()
 Get a pointer to this CT_List.
int Entries () const
 Get the number of list entries.
CTree * Entry (int n) const
 Get the n-th list entry.
int Sons () const
 Get the number of sons.
CTree * Son (int n) const
 Get the n-th son.
int Index (CTree *son)
 Get the index of the given son, or -1 if not found.
int GetProperties () const
 Get the list properties.
void AddProperties (int p)
 Add a list property.
void AddSon (CTree *s)
 Add a son.
void PrefixSon (CTree *s)
 Prepend a son.
void InsertSon (CTree *before, CTree *son)
 Insert a son before another son.
void ReplaceSon (CTree *old_son, CTree *new_son)
 Replace a son.
void RemoveSon (CTree *son)
 Remove a son.
void InsertSon (int idx, CTree *s)
 Insert a son at the given index.
void ReplaceSon (int idx, CTree *s)
 Replace the son at the given index.
void RemoveSon (int idx)
 Remove the son at the given index.
Public Member Functions inherited from Puma::CTree
virtual ~CTree ()
 Destructor.
virtual const char * NodeName () const =0
 Get the node name (node identifier).
virtual Token * token () const
 Get the first token of the syntactic construct represented by this sub-tree.
virtual Token * end_token () const
 Get the last token of the syntactic construct represented by this sub-tree.
virtual CT_Token * token_node () const
 Get the CT_Token node of the first token of the syntactic construct represented by this sub-tree.
virtual CT_Token * end_token_node () const
 Get the CT_Token node of the last token of the syntactic construct represented by this sub-tree.
virtual CTree * Parent () const
 Get the parent node.
virtual CTypeInfo * Type () const
 Get the semantic type of the node.
virtual CExprValue * Value () const
 Get the calculated value of the expression.
virtual CSemScope * SemScope () const
 Get the scope opened by the node.
virtual CSemValue * SemValue () const
 Get the semantic value of the node.
virtual CSemObject * SemObject () const
 Get the semantic information of the node.
virtual CT_SimpleName * IsSimpleName ()
 Get a pointer to CT_SimpleName if the current node represents a name.
virtual CT_String * IsString ()
 Get a pointer to CT_String if the current node represents a string.
virtual CT_Declarator * IsDeclarator ()
 Get a pointer to CT_Declarator if the current node represents a declarator.
virtual CT_Statement * IsStatement ()
 Get a pointer to CT_Statement if the current node represents a statement.
virtual CT_Expression * IsExpression ()
 Get a pointer to CT_Expression if the current node represents a expression.
virtual CT_Decl * IsDeclaration ()
 Get a pointer to CT_Decl if the current node represents a declaration.
virtual CT_Call * IsCall ()
 Get a pointer to CT_Call if the current node represents a call expression.
virtual CT_DelayedParse * IsDelayedParse ()
 Get a pointer to CT_DelayedParse if the current node represents a delayed code fragment.
bool HasValueNull () const
 Return true if the tree has the constant value 0.

Protected Member Functions

 CT_List (int size=5, int incr=5, int props=0)
 Constructor.
Protected Member Functions inherited from Puma::CTree
CTree * Son (CTree *const *sons, int len, int n) const
 Get the n-th son from given sons array.
int Sons (CTree *const *sons, int len) const
 Get the number of sons in the given sons array.
void ReplaceSon (CTree **sons, int len, CTree *old_son, CTree *new_son)
 Replace a son.
void ReplaceSon (CTree *&son, CTree *old_son, CTree *new_son)
 Replace a son if it equals the given son.
void AddSon (CTree *&son, CTree *new_son)
 Add a new son.
void SetParent (const CTree *parent)
 Set the parent tree node.
void SetParent (CTree *node, const CTree *parent)
 Set the parent tree node of the given tree node.
 CTree ()
 Default constructor.

Additional Inherited Members

Static Public Attributes inherited from Puma::CTree
static int alloc
static int release

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

List properties.

Enumerator
OPEN 

List has a start token, like ':' in ":a(1),b(2)"

CLOSE 

List has an end token

OPEN_CLOSE 

List has opening and closing delimiters, like '(' and ')'

SEPARATORS 

List has separators, like ','

FORCE_EMPTY 

List pretend to be empty, like for "(void)"

END_SEP 

List has trailing separator, like "a,b,c,"

NO_LAST_SEP 

List has no separator before last element, like "(a,b...)"

INTRO 

List has an introduction chararacter, like "=" in "={a,b}"

Constructor & Destructor Documentation

◆ CT_List()

Puma::CT_List::CT_List ( int size = 5,
int incr = 5,
int props = 0 )
inlineprotected

Constructor.

Parameters
sizeThe initial list size.
incrThe initial increment count.
propsThe list properties (bit array).

Member Function Documentation

◆ AddProperties()

void Puma::CT_List::AddProperties ( int p)
inline

Add a list property.

Parameters
pThe property to add.

◆ AddSon()

void Puma::CT_List::AddSon ( CTree * s)

Add a son.

Parameters
sThe son to add.

◆ Entries()

int Puma::CT_List::Entries ( ) const

Get the number of list entries.

◆ Entry()

CTree * Puma::CT_List::Entry ( int n) const

Get the n-th list entry.

Parameters
nThe index of the entry.
Returns
The list entry or NULL.

◆ GetProperties()

int Puma::CT_List::GetProperties ( ) const
inline

Get the list properties.

◆ Index()

int Puma::CT_List::Index ( CTree * son)

Get the index of the given son, or -1 if not found.

◆ InsertSon() [1/2]

void Puma::CT_List::InsertSon ( CTree * before,
CTree * son )

Insert a son before another son.

Parameters
beforeThe son to insert the new son before.
sonThe son to insert.

◆ InsertSon() [2/2]

void Puma::CT_List::InsertSon ( int idx,
CTree * s )

Insert a son at the given index.

Parameters
idxThe index at which to insert.
sThe son to insert.

◆ IsList()

CT_List * Puma::CT_List::IsList ( )
inlinevirtual

Get a pointer to this CT_List.

Reimplemented from Puma::CTree.

◆ PrefixSon()

void Puma::CT_List::PrefixSon ( CTree * s)

Prepend a son.

Parameters
sThe son to prepend.

◆ RemoveSon() [1/2]

void Puma::CT_List::RemoveSon ( CTree * son)

Remove a son.

Parameters
sonThe son to remove.

◆ RemoveSon() [2/2]

void Puma::CT_List::RemoveSon ( int idx)

Remove the son at the given index.

Parameters
idxThe index of the son to remove.

◆ ReplaceSon() [1/2]

void Puma::CT_List::ReplaceSon ( CTree * old_son,
CTree * new_son )
virtual

Replace a son.

Parameters
old_sonThe son to replace.
new_sonThe new son.

Reimplemented from Puma::CTree.

◆ ReplaceSon() [2/2]

void Puma::CT_List::ReplaceSon ( int idx,
CTree * s )

Replace the son at the given index.

Parameters
idxThe index of the son to replace.
sThe new son.

◆ Son()

CTree * Puma::CT_List::Son ( int n) const
inlinevirtual

Get the n-th son.

Parameters
nThe index of the son.
Returns
The n-th son or NULL.

Reimplemented from Puma::CTree.

Reimplemented in Puma::CT_PrivateName.

◆ Sons()

int Puma::CT_List::Sons ( ) const
inlinevirtual

Get the number of sons.

Implements Puma::CTree.

Reimplemented in Puma::CT_PrivateName.