std_cases_xsb_i.h

00001 /* File:      std_cases_xsb_i.h
00002 ** Author(s): Kostis F. Sagonas
00003 ** Contact:   xsb-contact@cs.sunysb.edu
00004 ** 
00005 ** Copyright (C) The Research Foundation of SUNY, 1986, 1993-1998
00006 ** 
00007 ** XSB is free software; you can redistribute it and/or modify it under the
00008 ** terms of the GNU Library General Public License as published by the Free
00009 ** Software Foundation; either version 2 of the License, or (at your option)
00010 ** any later version.
00011 ** 
00012 ** XSB is distributed in the hope that it will be useful, but WITHOUT ANY
00013 ** WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00014 ** FOR A PARTICULAR PURPOSE.  See the GNU Library General Public License for
00015 ** more details.
00016 ** 
00017 ** You should have received a copy of the GNU Library General Public License
00018 ** along with XSB; if not, write to the Free Software Foundation,
00019 ** Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00020 **
00021 ** $Id: std_cases_xsb_i.h,v 1.17 2006/01/27 17:50:19 dwarren Exp $
00022 ** 
00023 */
00024 
00025 
00026   case IS_ATTV: /* r1: ?term */
00027     return isattv(ptoc_tag(CTXTc 1));
00028 
00029   case VAR:             /* r1: ?term */
00030     return isref(ptoc_tag(CTXTc 1));
00031     
00032   case NONVAR:  /* r1: ?term */
00033     return isnonvar(ptoc_tag(CTXTc 1));
00034     
00035   case ATOM:            /* r1: ?term */
00036     return isatom(ptoc_tag(CTXTc 1));
00037     
00038   case INTEGER: /* r1: ?term */ {
00039       int tag = ptoc_tag(CTXTc 1);
00040       return (isinteger(tag) || isboxedinteger(tag));
00041   }
00042     
00043   case REAL:            /* r1: ?term */
00044   {
00045     Cell term = ptoc_tag(CTXTc 1);
00046     return isofloat(term);
00047   }  
00048   case NUMBER:  /* r1: ?term */ {
00049       Cell tag = ptoc_tag(CTXTc 1);
00050       return (isnumber(tag) || isboxedinteger(tag) || isboxedfloat(tag));
00051   }
00052   case ATOMIC: {        /* r1: ?term */
00053     Cell term = ptoc_tag(CTXTc 1);
00054     return (isatomic(term) || isboxedinteger(term) || isboxedfloat(term));
00055   }
00056 
00057   case COMPOUND: {      /* r1: ?term */
00058     Cell term = ptoc_tag(CTXTc 1);
00059     return (((isconstr(term) && get_arity(get_str_psc(term))) ||
00060             (islist(term))) && !isboxedfloat(term) && !isboxedinteger(term));
00061   }
00062 
00063   case CALLABLE: {      /* r1: ?term */
00064     Cell term = ptoc_tag(CTXTc 1);
00065     return ((isconstr(term) && !isboxed(term)) || isstring(term) || islist(term));
00066   }
00067 
00068   case IS_LIST: /* r1: ?term */
00069     return is_proper_list(ptoc_tag(CTXTc 1));
00070     
00071   case IS_MOST_GENERAL_TERM: /* r1: ?term */
00072     return is_most_general_term(ptoc_tag(CTXTc 1)); 
00073 
00074   case FUNCTOR: /* r1: ?term; r2: ?functor; r3: ?arity (int)    */
00075     return functor_builtin(CTXT);
00076     
00077   case ARG:     /* r1: +index (int); r2: +term; r3: ?arg (term) */
00078     return arg_builtin(CTXT);
00079     
00080   case UNIV:    /* r1: ?term; r2: ?list */
00081     return univ_builtin(CTXT);
00082     
00083   case HiLog_ARG:       /* r1: +index (int); r2: +term; r3: ?arg (term) */
00084     return hilog_arg(CTXT);
00085 
00086   case HiLog_UNIV:      /* r1: ?term; r2: ?list */
00087     break;
00088     
00089   /* atom_chars should be redefined to return char-atoms rather than ASCII
00090      codes */ 
00091   case ATOM_CHARS:      /* r1: ?term; r2: ?character symbol list        */
00092     return atom_to_list(CTXTc ATOM_CHARS);
00093   case ATOM_CODES:      /* r1: ?term; r2: ?character ascii code list    */
00094     return atom_to_list(CTXTc ATOM_CODES);
00095     
00096   /* number_chars should be redefined to return digit-atoms */
00097   case NUMBER_CHARS:    /* r1: ?term; r2: ?character symbol list        */
00098     return number_to_list(CTXTc NUMBER_CHARS);
00099   case NUMBER_CODES:    /* r1: ?term; r2: ?character code list  */
00100     return number_to_list(CTXTc NUMBER_CODES);
00101   case NUMBER_DIGITS:   /* r1: ?term; r2: ?digit list   */
00102     return number_to_list(CTXTc NUMBER_DIGITS);
00103     
00104     
00105   case PUT: {   /* r1: +integer */
00106     Cell term = ptoc_tag(CTXTc 1);
00107     if (isinteger(term)) {
00108       putc(int_val(term), fileptr(pflags[CURRENT_OUTPUT]));
00109     } else {
00110       if (isnonvar(term)) err_handle(CTXTc TYPE, 1, "put", 1, "integer", term);
00111       else err(INSTANTIATION, 1, "put", 1);
00112     }
00113     break;
00114   }
00115   case TAB: {   /* r1: +integer */
00116     Cell term = ptoc_tag(CTXTc 1);
00117     if (isinteger(term)) {
00118       int  i;
00119       for (i=1; i<=int_val(term); i++)
00120         putc(' ', fileptr(pflags[CURRENT_OUTPUT]));
00121     } else {
00122       if (isnonvar(term)) err_handle(CTXTc TYPE, 1, "tab", 1, "integer", term);
00123       else err(INSTANTIATION, 1, "tab", 1);
00124     }
00125     break;
00126   }
00127 
00128   case SORT:            /* r1: +list of terms; r2: ?sorted list of terms */
00129   return sort(CTXT);
00130     
00131   case KEYSORT: /* r1: +list of terms of the form Key-Value;    */
00132     /* r2: ?sorted list of terms                        */
00133    return keysort(CTXT);
00134 
00135   case PARSORT: /* r1: +list of terms of the form Key-Value;    */
00136     /* r2: +list of sort paramater specs                        */
00137     /* r3: ?sorted list of terms                        */
00138    return parsort(CTXT);
00139 

Generated on Wed Jul 26 13:30:42 2006 for XSB by  doxygen 1.4.5