Annotation of OpenXM_contrib2/asir2000/parse/evall.c, Revision 1.1
1.1 ! noro 1: /* $OpenXM: OpenXM/src/asir99/parse/evall.c,v 1.2 1999/11/18 05:42:03 noro Exp $ */
! 2: #include <ctype.h>
! 3: #include "ca.h"
! 4: #include "parse.h"
! 5: #include "base.h"
! 6: #include "al.h"
! 7: #if !defined(THINK_C)
! 8: #include <sys/types.h>
! 9: #include <sys/stat.h>
! 10: #endif
! 11:
! 12: pointer evall();
! 13:
! 14: pointer evall(id,a1,a2)
! 15: lid id;
! 16: Obj a1,a2;
! 17: {
! 18: F f;
! 19: Obj d;
! 20: oFOP op;
! 21: NODE n1,n2;
! 22:
! 23: switch ( id ) {
! 24: case L_EQ:
! 25: op = AL_EQUAL; break;
! 26: case L_NE:
! 27: op = AL_NEQ; break;
! 28: case L_GT:
! 29: op = AL_GREATERP; break;
! 30: case L_LT:
! 31: op = AL_LESSP; break;
! 32: case L_GE:
! 33: op = AL_GEQ; break;
! 34: case L_LE:
! 35: op = AL_LEQ; break;
! 36: case L_AND:
! 37: op = AL_AND; break;
! 38: case L_OR:
! 39: op = AL_OR; break;
! 40: case L_NOT:
! 41: op = AL_NOT; break;
! 42: case L_IMPL:
! 43: op = AL_IMPL; break;
! 44: case L_REPL:
! 45: op = AL_REPL; break;
! 46: case L_EQUIV:
! 47: op = AL_EQUIV; break;
! 48: default:
! 49: error("evall : unknown id");
! 50: }
! 51: if ( AL_ATOMIC(op) ) {
! 52: arf_sub(CO,a1,a2,&d);
! 53: MKAF(f,op,(P)d);
! 54: } else if ( AL_JUNCT(op) ) {
! 55: if ( FOP((F)a1) == op ) {
! 56: if ( FOP((F)a2) == op )
! 57: n2 = FJARG((F)a2);
! 58: else
! 59: MKNODE(n2,(F)a2,0);
! 60: node_concat_dup(FJARG((F)a1),n2,&n1);
! 61: } else if ( FOP((F)a2) == op )
! 62: MKNODE(n1,a1,FJARG((F)a2));
! 63: else {
! 64: MKNODE(n2,a2,0); MKNODE(n1,a1,n2);
! 65: }
! 66: MKJF(f,op,n1);
! 67: } else if ( AL_UNI(op) )
! 68: MKUF(f,op,(F)a1);
! 69: else if ( AL_EXT(op) )
! 70: MKBF(f,op,(F)a1,(F)a2);
! 71: return (pointer)f;
! 72: }
! 73:
! 74: node_concat_dup(n1,n2,nr)
! 75: NODE n1,n2,*nr;
! 76: {
! 77: NODE r0,r,n;
! 78:
! 79: for ( r0 = 0, n = n1; n; n = NEXT(n) ) {
! 80: NEXTNODE(r0,r); BDY(r) = BDY(n);
! 81: }
! 82: if ( !r0 )
! 83: *nr = n2;
! 84: else {
! 85: NEXT(r) = n2; *nr = r0;
! 86: }
! 87: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>