Back to index

texmacs  1.0.7.15
Functions
evaluate_boolean.cpp File Reference
#include "evaluate_main.hpp"

Go to the source code of this file.

Functions

tree evaluate_or (tree t)
tree evaluate_xor (tree t)
tree evaluate_and (tree t)
tree evaluate_not (tree t)
tree evaluate_equal (tree t)
tree evaluate_unequal (tree t)
tree evaluate_less (tree t)
tree evaluate_lesseq (tree t)
tree evaluate_greater (tree t)
tree evaluate_greatereq (tree t)

Function Documentation

Definition at line 40 of file evaluate_boolean.cpp.

                      {
  if (N(t)<2) return evaluate_error ("bad and");
  for (int i=0; i<N(t); i++) {
    tree u= evaluate (t[i]);
    if (!is_bool (u)) return evaluate_error ("bad and");
    if (!as_bool (u)) return as_string_bool (false);
  }
  return as_string_bool (true);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 63 of file evaluate_boolean.cpp.

                        {
  if (N(t)!=2) return evaluate_error ("bad equal");
  tree t1= evaluate (t[0]);
  tree t2= evaluate (t[1]);
  if (is_atomic (t1) && is_atomic (t2) &&
      is_length (t1->label) && is_length (t2->label))
    return as_string_bool (as_length (t1) == as_length (t2));
  return as_string_bool (t1 == t2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 117 of file evaluate_boolean.cpp.

                          {
  if (N(t)!=2) return evaluate_error ("bad greater");
  tree t1= evaluate (t[0]);
  tree t2= evaluate (t[1]);
  if (is_compound (t1) || is_compound (t2))
    return evaluate_error ("bad greater");
  string s1= t1->label;
  string s2= t2->label;
  if (is_double (s1) && (is_double (s2)))
    return as_string_bool (as_double (s1) > as_double (s2));
  if (is_length (s1) && is_length (s2))
    return as_string_bool (as_length (s1) > as_length (s2));
  return evaluate_error ("bad greater");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 133 of file evaluate_boolean.cpp.

                            {
  if (N(t)!=2) return evaluate_error ("bad greater or equal");
  tree t1= evaluate (t[0]);
  tree t2= evaluate (t[1]);
  if (is_compound (t1) || is_compound (t2))
    return evaluate_error ("bad greater or equal");
  string s1= t1->label;
  string s2= t2->label;
  if (is_double (s1) && (is_double (s2)))
    return as_string_bool (as_double (s1) >= as_double (s2));
  if (is_length (s1) && is_length (s2))
    return as_string_bool (as_length (s1) >= as_length (s2));
  return evaluate_error ("bad greater or equal");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 85 of file evaluate_boolean.cpp.

                       {
  if (N(t)!=2) return evaluate_error ("bad less");
  tree t1= evaluate (t[0]);
  tree t2= evaluate (t[1]);
  if (is_compound (t1) || is_compound (t2))
    return evaluate_error ("bad less");
  string s1= t1->label;
  string s2= t2->label;
  if (is_double (s1) && is_double (s2))
    return as_string_bool (as_double (s1) < as_double (s2));
  if (is_length (s1) && is_length (s2))
    return as_string_bool (as_length (s1) < as_length (s2));
  return evaluate_error ("bad less");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 101 of file evaluate_boolean.cpp.

                         {
  if (N(t)!=2) return evaluate_error ("bad less or equal");
  tree t1= evaluate (t[0]);
  tree t2= evaluate (t[1]);
  if (is_compound (t1) || is_compound (t2))
    return evaluate_error ("bad less or equal");
  string s1= t1->label;
  string s2= t2->label;
  if (is_double (s1) && (is_double (s2)))
    return as_string_bool (as_double (s1) <= as_double (s2));
  if (is_length (s1) && is_length (s2))
    return as_string_bool (as_length (s1) <= as_length (s2));
  return evaluate_error ("bad less or equal");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 51 of file evaluate_boolean.cpp.

                      {
  if (N(t)!=1) return evaluate_error ("bad not");
  tree u= evaluate(t[0]);
  if (!is_bool (u)) return evaluate_error ("bad not");
  return as_string_bool (!as_bool (u));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 19 of file evaluate_boolean.cpp.

                     {
  if (N(t)<2) return evaluate_error ("bad or");
  for (int i=0; i<N(t); i++) {
    tree u= evaluate (t[i]);
    if (!is_bool (u)) return evaluate_error ("bad or");
    if (as_bool (u)) return as_string_bool (true);
  }
  return as_string_bool (false);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 74 of file evaluate_boolean.cpp.

                          {
  if (N(t)!=2) return evaluate_error ("bad unequal");
  tree t1= evaluate (t[0]);
  tree t2= evaluate (t[1]);
  if (is_atomic (t1) && is_atomic (t2) &&
      is_length (t1->label) && is_length (t2->label))
    return as_string_bool (as_length (t1) != as_length (t2));
  return as_string_bool (t1 != t2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 30 of file evaluate_boolean.cpp.

                      {
  if (N(t)!=2) return evaluate_error ("bad xor");
  tree t1= evaluate (t[0]);
  tree t2= evaluate (t[1]);
  if (!is_bool (t1) || !is_bool (t2))
    return evaluate_error ("bad xor");
  return as_string_bool (as_bool (t1) ^ as_bool (t2));
}

Here is the call graph for this function:

Here is the caller graph for this function: