Back to index

texmacs  1.0.7.15
Public Member Functions | Private Member Functions | Private Attributes | Friends
tree Class Reference

#include <tree.hpp>

Collaboration diagram for tree:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 tree (const tree &x)
 ~tree ()
atomic_repoperator-> ()
treeoperator= (tree x)
 tree ()
 tree (string l)
 tree (const char *l)
 tree (tree_label l, int n=0)
 tree (tree_label l, array< tree > a)
 tree (tree t, int n)
 tree (tree_label l, tree t1)
 tree (tree_label l, tree t1, tree t2)
 tree (tree_label l, tree t1, tree t2, tree t3)
 tree (tree_label l, tree t1, tree t2, tree t3, tree t4)
 tree (tree_label l, tree t1, tree t2, tree t3, tree t4, tree t5)
 tree (tree_label l, tree t1, tree t2, tree t3, tree t4, tree t5, tree t6)
 tree (tree_label l, tree t1, tree t2, tree t3, tree t4, tree t5, tree t6, tree t7)
 tree (tree_label l, tree t1, tree t2, tree t3, tree t4, tree t5, tree t6, tree t7, tree t8)
treeoperator[] (int i)
tree operator() (int start, int end)

Private Member Functions

 tree (tree_rep *rep2)

Private Attributes

tree_reprep

Friends

class tree_pointer_rep
class tree_position_rep
class tree_addendum_rep
class edit_observer_rep
class undo_observer_rep
class tree_links_rep
class link_repository_rep
int N (tree t)
int arity (tree t)
tree_label L (tree t)
tree_labelLR (tree t)
array< treeA (tree t)
array< tree > & AR (tree t)
bool is_atomic (tree t)
bool is_compound (tree t)
bool is_generic (tree t)
bool operator== (tree t, tree_label lab)
bool operator!= (tree t, tree_label lab)
bool operator== (tree t, string s)
bool operator!= (tree t, string s)
bool operator== (tree t, const char *s)
bool operator!= (tree t, const char *s)
tree_repinside (tree t)
bool strong_equal (tree t, tree u)
bool is_func (tree t, tree_label l)
bool is_func (tree t, tree_label l, int i)
tree copy (tree t)
tree freeze (tree t)
bool operator== (tree t, tree u)
bool operator!= (tree t, tree u)
treeoperator<< (tree &t, tree t2)
treeoperator<< (tree &t, array< tree > a)
tm_ostreamoperator<< (tm_ostream &out, tree t)
tree operator* (tree t1, tree t2)
void print_tree (tree t, int tab=0)
list< treeas_trees (list< pointer > l)
blackbox as_blackbox (const tree &t)

Detailed Description

Definition at line 30 of file tree.hpp.


Constructor & Destructor Documentation

tree::tree ( tree_rep rep2) [inline, private]

Definition at line 148 of file tree.hpp.

: rep (rep2) { rep->ref_count++; }
tree::tree ( const tree x) [inline]

Definition at line 149 of file tree.hpp.

: rep (x.rep) { rep->ref_count++; }
tree::~tree ( ) [inline]

Definition at line 150 of file tree.hpp.

                    {
  if ((--rep->ref_count)==0) { destroy_tree_rep (rep); rep= NULL; } }

Here is the call graph for this function:

tree::tree ( ) [inline]

Definition at line 161 of file tree.hpp.

                  :
  rep (tm_new<atomic_rep> (string ())) {}
tree::tree ( string  l) [inline]

Definition at line 165 of file tree.hpp.

                          :
  rep (tm_new<atomic_rep> (s)) {}
tree::tree ( const char *  l) [inline]

Definition at line 163 of file tree.hpp.

                               :
  rep (tm_new<atomic_rep> (s)) {}
tree::tree ( tree_label  l,
int  n = 0 
) [inline]

Definition at line 167 of file tree.hpp.

                                     :
  rep (tm_new<compound_rep> (l, array<tree> (n))) {}
tree::tree ( tree_label  l,
array< tree a 
) [inline]

Definition at line 169 of file tree.hpp.

                                             :
  rep (tm_new<compound_rep> (l, a)) {}
tree::tree ( tree  t,
int  n 
) [inline]

Definition at line 171 of file tree.hpp.

                               :
  rep (tm_new<compound_rep> (t.rep->op, array<tree> (n))) {
    CHECK_COMPOUND (t); }
tree::tree ( tree_label  l,
tree  t1 
)

Definition at line 30 of file tree.cpp.

                                :
  rep (tm_new<compound_rep> (l, array<tree> (1)))
{
  (static_cast<compound_rep*> (rep))->a[0]=t1;
}
tree::tree ( tree_label  l,
tree  t1,
tree  t2 
)

Definition at line 36 of file tree.cpp.

                                         :
  rep (tm_new<compound_rep> (l, array<tree> (2)))
{
  (static_cast<compound_rep*> (rep))->a[0]=t1;
  (static_cast<compound_rep*> (rep))->a[1]=t2;
}
tree::tree ( tree_label  l,
tree  t1,
tree  t2,
tree  t3 
)

Definition at line 43 of file tree.cpp.

                                                  :
  rep (tm_new<compound_rep> (l, array<tree> (3)))
{
  (static_cast<compound_rep*> (rep))->a[0]=t1;
  (static_cast<compound_rep*> (rep))->a[1]=t2;
  (static_cast<compound_rep*> (rep))->a[2]=t3;
}
tree::tree ( tree_label  l,
tree  t1,
tree  t2,
tree  t3,
tree  t4 
)

Definition at line 51 of file tree.cpp.

                                                           :
  rep (tm_new<compound_rep> (l, array<tree> (4)))
{
  (static_cast<compound_rep*> (rep))->a[0]=t1;
  (static_cast<compound_rep*> (rep))->a[1]=t2;
  (static_cast<compound_rep*> (rep))->a[2]=t3;
  (static_cast<compound_rep*> (rep))->a[3]=t4;
}
tree::tree ( tree_label  l,
tree  t1,
tree  t2,
tree  t3,
tree  t4,
tree  t5 
)

Definition at line 60 of file tree.cpp.

                                                                    :
  rep (tm_new<compound_rep> (l, array<tree> (5)))
{
  (static_cast<compound_rep*> (rep))->a[0]=t1;
  (static_cast<compound_rep*> (rep))->a[1]=t2;
  (static_cast<compound_rep*> (rep))->a[2]=t3;
  (static_cast<compound_rep*> (rep))->a[3]=t4;
  (static_cast<compound_rep*> (rep))->a[4]=t5;
}
tree::tree ( tree_label  l,
tree  t1,
tree  t2,
tree  t3,
tree  t4,
tree  t5,
tree  t6 
)

Definition at line 70 of file tree.cpp.

                                                                :
  rep (tm_new<compound_rep> (l, array<tree> (6)))
{
  (static_cast<compound_rep*> (rep))->a[0]=t1;
  (static_cast<compound_rep*> (rep))->a[1]=t2;
  (static_cast<compound_rep*> (rep))->a[2]=t3;
  (static_cast<compound_rep*> (rep))->a[3]=t4;
  (static_cast<compound_rep*> (rep))->a[4]=t5;
  (static_cast<compound_rep*> (rep))->a[5]=t6;
}
tree::tree ( tree_label  l,
tree  t1,
tree  t2,
tree  t3,
tree  t4,
tree  t5,
tree  t6,
tree  t7 
)

Definition at line 82 of file tree.cpp.

                                                                         :
  rep (tm_new<compound_rep> (l, array<tree> (7)))
{
  (static_cast<compound_rep*> (rep))->a[0]=t1;
  (static_cast<compound_rep*> (rep))->a[1]=t2;
  (static_cast<compound_rep*> (rep))->a[2]=t3;
  (static_cast<compound_rep*> (rep))->a[3]=t4;
  (static_cast<compound_rep*> (rep))->a[4]=t5;
  (static_cast<compound_rep*> (rep))->a[5]=t6;
  (static_cast<compound_rep*> (rep))->a[6]=t7;
}
tree::tree ( tree_label  l,
tree  t1,
tree  t2,
tree  t3,
tree  t4,
tree  t5,
tree  t6,
tree  t7,
tree  t8 
)

Definition at line 95 of file tree.cpp.

                                              :
  rep (tm_new<compound_rep> (l, array<tree> (8)))
{
  (static_cast<compound_rep*> (rep))->a[0]=t1;
  (static_cast<compound_rep*> (rep))->a[1]=t2;
  (static_cast<compound_rep*> (rep))->a[2]=t3;
  (static_cast<compound_rep*> (rep))->a[3]=t4;
  (static_cast<compound_rep*> (rep))->a[4]=t5;
  (static_cast<compound_rep*> (rep))->a[5]=t6;
  (static_cast<compound_rep*> (rep))->a[6]=t7;
  (static_cast<compound_rep*> (rep))->a[7]=t8;
}

Member Function Documentation

tree tree::operator() ( int  start,
int  end 
)

Definition at line 111 of file tree.cpp.

                                     {
  int i;
  tree r (rep->op, end-begin);
  for (i=begin; i<end; i++)
    r[i-begin]= (static_cast<compound_rep*> (rep))->a[i];
  return r;
}

Here is the call graph for this function:

atomic_rep * tree::operator-> ( void  ) [inline]

Definition at line 152 of file tree.hpp.

                                      {
  CHECK_ATOMIC (*this);
  return static_cast<atomic_rep*> (rep); }
tree & tree::operator= ( tree  x) [inline]

Definition at line 155 of file tree.hpp.

                                     {
  x.rep->ref_count++;
  if ((--rep->ref_count)==0) destroy_tree_rep (rep);
  rep= x.rep;
  return *this; }

Here is the call graph for this function:

tree & tree::operator[] ( int  i) [inline]

Definition at line 175 of file tree.hpp.

                                     {
  CHECK_COMPOUND (*this);
  return (static_cast<compound_rep*> (rep))->a[i]; }

Friends And Related Function Documentation

array<tree> A ( tree  t) [friend]

Definition at line 190 of file tree.hpp.

                              {
  CHECK_COMPOUND (t);
  return (static_cast<compound_rep*> (t.rep))->a; }
array<tree>& AR ( tree  t) [friend]

Definition at line 193 of file tree.hpp.

                                {
  CHECK_COMPOUND (t);
  return (static_cast<compound_rep*> (t.rep))->a; }
int arity ( tree  t) [friend]

Definition at line 181 of file tree.hpp.

                          {
  if (t.rep->op == STRING) return 0;
  else return N ((static_cast<compound_rep*> (t.rep))->a); }
blackbox as_blackbox ( const tree t) [friend]

Definition at line 27 of file generic_tree.hpp.

                            {
  return ((generic_rep*) t.rep) -> data;
}
list<tree> as_trees ( list< pointer l) [friend]
tree copy ( tree  t) [friend]

Definition at line 132 of file tree.cpp.

              {
  if (is_atomic (t)) return tree (copy (t->label));
  else {
    int i, n= N(t);
    tree t2 (t, n);
    for (i=0; i<n; i++) t2[i]= copy (t[i]);
    return t2;
  }
}
friend class edit_observer_rep [friend]

Definition at line 92 of file tree.hpp.

tree freeze ( tree  t) [friend]

Definition at line 143 of file tree.cpp.

                {
  if (is_atomic (t)) return copy (t->label);
  if (is_func (t, UNFREEZE, 1)) return t[0];
  else {
    int i, n= N(t);
    tree r (t, n);
    for (i=0; i<n; i++)
      r[i]= freeze (t[i]);
    return r;
  }
}
tree_rep* inside ( tree  t) [friend]

Definition at line 214 of file tree.hpp.

                                 {
  return t.rep; }
bool is_atomic ( tree  t) [friend]

Definition at line 197 of file tree.hpp.

{ return (((int) t.rep->op) == 0); }
bool is_compound ( tree  t) [friend]

Definition at line 198 of file tree.hpp.

{ return (((int) t.rep->op) > STRING); }
bool is_func ( tree  t,
tree_label  l 
) [friend]

Definition at line 219 of file tree.hpp.

                                           {
  return (t.rep->op==l) && (N(t)!=0); }
bool is_func ( tree  t,
tree_label  l,
int  i 
) [friend]

Definition at line 221 of file tree.hpp.

                                                  {
  return (t.rep->op==l) && (N(t)==i); }
bool is_generic ( tree  t) [friend]

Definition at line 199 of file tree.hpp.

{ return ((int) t.rep->op) < 0; }
tree_label L ( tree  t) [friend]

Definition at line 186 of file tree.hpp.

                             {
  return t.rep->op; }
friend class link_repository_rep [friend]

Definition at line 95 of file tree.hpp.

tree_label& LR ( tree  t) [friend]

Definition at line 188 of file tree.hpp.

                               {
  return t.rep->op; }
int N ( tree  t) [friend]

Definition at line 178 of file tree.hpp.

                      {
  CHECK_COMPOUND (t);
  return N ((static_cast<compound_rep*> (t.rep))->a); }
bool operator!= ( tree  t,
tree_label  lab 
) [friend]

Definition at line 204 of file tree.hpp.

                                                 {
  return (t.rep->op != lab) || (N(t)!=0); }
bool operator!= ( tree  t,
string  s 
) [friend]

Definition at line 208 of file tree.hpp.

                                           {
  return (t.rep->op != STRING) || (t->label != s); }
bool operator!= ( tree  t,
const char *  s 
) [friend]

Definition at line 212 of file tree.hpp.

                                                {
  return (t.rep->op != STRING) || (t->label != s); }
bool operator!= ( tree  t,
tree  u 
) [friend]

Definition at line 126 of file tree.cpp.

                             {
  return (L(t)!=L(u)) ||
    (L(t)==STRING? (t->label!=u->label): (A(t)!=A(u)));
}
tree operator* ( tree  t1,
tree  t2 
) [friend]

Definition at line 156 of file tree.cpp.

                              {
  int i;
  if (is_atomic (t1)) t1= tree (L(t2), t1);
  if (is_atomic (t2)) t2= tree (L(t1), t2);
  tree r (t1, N(t1)+N(t2));
  for (i=0; i<N(t1); i++) r[i]= t1[i];
  for (i=0; i<N(t2); i++) r[i+N(t1)]= t2[i];
  return r;
}
tree& operator<< ( tree t,
tree  t2 
) [friend]

Definition at line 167 of file tree.cpp.

                               {
  CHECK_COMPOUND (t);
  (static_cast<compound_rep*> (t.rep))->a << t2;
  return t;
}
tree& operator<< ( tree t,
array< tree a 
) [friend]

Definition at line 174 of file tree.cpp.

                                     {
  CHECK_COMPOUND (t);
  (static_cast<compound_rep*> (t.rep))->a << a;
  return t;
}
tm_ostream& operator<< ( tm_ostream out,
tree  t 
) [friend]

Definition at line 181 of file tree.cpp.

                                      {
  if (is_atomic (t)) return out << t->label;
  else if (is_compound (t)) {
    int i, n= N(t);
    out << as_string (L(t));
    if (n==0) return out << "()";
    out << " (";
    for (i=0; i< n-1; i++)
      out << t[i] << ", ";
    out << t[i] << ")";
    return out;
  }
  else out << as_blackbox (t);
  return out;
}
bool operator== ( tree  t,
tree_label  lab 
) [friend]

Definition at line 202 of file tree.hpp.

                                                 {
  return (t.rep->op == lab) && (N(t)==0); }
bool operator== ( tree  t,
string  s 
) [friend]

Definition at line 206 of file tree.hpp.

                                           {
  return (t.rep->op == STRING) && (t->label == s); }
bool operator== ( tree  t,
const char *  s 
) [friend]

Definition at line 210 of file tree.hpp.

                                                {
  return (t.rep->op == STRING) && (t->label == s); }
bool operator== ( tree  t,
tree  u 
) [friend]

Definition at line 120 of file tree.cpp.

                             {
  return (L(t)==L(u)) &&
    (L(t)==STRING? (t->label==u->label): (A(t)==A(u)));
}
void print_tree ( tree  t,
int  tab = 0 
) [friend]

Definition at line 198 of file tree.cpp.

                             {
  int i;
  for (i=0; i<tab; i++) cout << " ";
  if (is_atomic (t)) cout << t->label << "\n";
  else {
    cout << as_string (L(t)) << "\n";
    for (i=0; i<N(t); i++) print_tree (t[i], tab+2);
  }
}
bool strong_equal ( tree  t,
tree  u 
) [friend]

Definition at line 216 of file tree.hpp.

                                          {
  return t.rep == u.rep; }
friend class tree_addendum_rep [friend]

Definition at line 91 of file tree.hpp.

friend class tree_links_rep [friend]

Definition at line 94 of file tree.hpp.

friend class tree_pointer_rep [friend]

Definition at line 89 of file tree.hpp.

friend class tree_position_rep [friend]

Definition at line 90 of file tree.hpp.

friend class undo_observer_rep [friend]

Definition at line 93 of file tree.hpp.


Member Data Documentation

tree_rep* tree::rep [private]

Definition at line 31 of file tree.hpp.


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