Back to index

texmacs  1.0.7.15
Functions
path.cpp File Reference
#include "path.hpp"
#include "analyze.hpp"

Go to the source code of this file.

Functions

bool zero_path (path p)
int hash (path p)
string as_string (path p)
path as_path (string s)
bool version_inf_eq (string v1, string v2)
bool version_inf (string v1, string v2)
path path_add (path p, int plus)
path path_add (path p, int plus, int pos)
path path_up (path p)
path path_up (path p, int times)
bool path_inf (path p1, path p2)
bool path_inf_eq (path p1, path p2)
bool path_less (path p1, path p2)
bool path_less_eq (path p1, path p2)
path operator/ (path p, path q)
path common (path start, path end)
bool has_subtree (tree t, path p)
treesubtree (tree &t, path p)
treeparent_subtree (tree &t, path p)

Function Documentation

Definition at line 43 of file path.cpp.

                   {
  int i, j, n= N(s);
  for (i=0; i<n; i++)
    if (is_digit (s[i])) break;
  if (i==n) return path ();
  for (j=i; j<n; j++)
    if (!is_digit (s[j])) break;
  return path (as_int (s (i, j)), as_path (s (j, n)));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 36 of file path.cpp.

                   {
  if (is_nil (p)) return "";
  if (is_atom (p)) return as_string (p->item);
  return as_string (p->item) * "." * as_string (p->next);
}

Here is the call graph for this function:

path common ( path  start,
path  end 
)

Definition at line 139 of file path.cpp.

                              {
  if (is_nil (start) || is_nil (end)) return path ();
  if (start->item != end->item) return path ();
  return path (start->item, common (start->next, end->next));
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool has_subtree ( tree  t,
path  p 
)

Definition at line 150 of file path.cpp.

                             {
  if (is_nil (p)) return true;
  int i= p->item;
  return is_compound (t) && i >= 0 && i < N(t) && has_subtree (t[i], p->next);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int hash ( path  p)

Definition at line 27 of file path.cpp.

              {
  if (is_nil (p)) return 0;
  else {
    int h= hash (p->next);
    return p->item ^ ((h<<7) + (h>>25));
  }
}

Here is the call graph for this function:

path operator/ ( path  p,
path  q 
)

Definition at line 130 of file path.cpp.

                            {
  if (is_nil (q)) return p;
  else if (is_nil (p) || (p->item != q->item)) {
    FAILED ("path did not start with required path"); }
  else return p->next / q->next;
  return path (); // NOT REACHED
}

Here is the call graph for this function:

tree& parent_subtree ( tree t,
path  p 
)

Definition at line 163 of file path.cpp.

                                 {
  ASSERT (!is_nil (p), "path too short");
  if (is_nil (p->next)) return t;
  else return parent_subtree (t[p->item], p->next);
}

Here is the call graph for this function:

Here is the caller graph for this function:

path path_add ( path  p,
int  plus 
)

Definition at line 70 of file path.cpp.

                            {
  if (is_atom (p)) return path (p->item+plus);
  return path (p->item, path_add (p->next, plus));
}

Here is the call graph for this function:

Here is the caller graph for this function:

path path_add ( path  p,
int  plus,
int  pos 
)

Definition at line 76 of file path.cpp.

                                     {
  p= copy (p);
  p[pos]+=plus;
  return p;
}

Here is the call graph for this function:

bool path_inf ( path  p1,
path  p2 
)

Definition at line 95 of file path.cpp.

                            {
  if (is_nil (p1) || is_nil (p2)) return false;
  if (p1->item<p2->item) return true;
  if (p1->item>p2->item) return false;
  return path_inf (p1->next, p2->next);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool path_inf_eq ( path  p1,
path  p2 
)

Definition at line 103 of file path.cpp.

                               {
  if (is_nil (p1) || is_nil (p2)) return (p1 == p2);
  if (p1->item<p2->item) return true;
  if (p1->item>p2->item) return false;
  return path_inf_eq (p1->next, p2->next);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool path_less ( path  p1,
path  p2 
)

Definition at line 111 of file path.cpp.

                             {
  return path_less_eq (p1, p2) && (p1 != p2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool path_less_eq ( path  p1,
path  p2 
)

Definition at line 116 of file path.cpp.

                                {
  if (is_nil (p1) || is_nil (p2)) return p1 == p2;
  if (is_atom (p1) || is_atom (p2)) {
    if (is_atom (p1) && is_atom (p2)) return p1->item <= p2->item;
    if ((p1->item == 0) && is_nil (p1->next)) return true;
    if ((p2->item == 1) && is_nil (p2->next)) return true;
    return false;
  }
  if (p1->item<p2->item) return true;
  if (p1->item>p2->item) return false;
  return path_less_eq (p1->next, p2->next);
}

Here is the call graph for this function:

Here is the caller graph for this function:

path path_up ( path  p)

Definition at line 83 of file path.cpp.

                 {
  ASSERT (!is_nil (p), "path is too short");
  if (is_nil (p->next)) return path ();
  return path (p->item, path_up (p->next));
}

Here is the call graph for this function:

path path_up ( path  p,
int  times 
)

Definition at line 90 of file path.cpp.

                            {
  return head (p, N(p)-times);
}

Here is the call graph for this function:

tree& subtree ( tree t,
path  p 
)

Definition at line 157 of file path.cpp.

                          {
  if (is_nil (p)) return t;
  else return subtree (t[p->item], p->next);
}

Here is the call graph for this function:

bool version_inf ( string  v1,
string  v2 
)

Definition at line 60 of file path.cpp.

                                   {
  if (v1 == v2) return false;
  return version_inf_eq (v1, v2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool version_inf_eq ( string  v1,
string  v2 
)

Definition at line 54 of file path.cpp.

                                      {
  if (starts (v2, v1)) return true;
  return path_inf_eq (as_path (v1), as_path (v2));
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool zero_path ( path  p)

Definition at line 21 of file path.cpp.

                   {
  if (is_nil (p)) return true;
  return (p->item == 0) && zero_path (p->next);
}

Here is the call graph for this function:

Here is the caller graph for this function: