2 |
7u83 |
1 |
/*
|
|
|
2 |
Crown Copyright (c) 1997
|
|
|
3 |
|
|
|
4 |
This TenDRA(r) Computer Program is subject to Copyright
|
|
|
5 |
owned by the United Kingdom Secretary of State for Defence
|
|
|
6 |
acting through the Defence Evaluation and Research Agency
|
|
|
7 |
(DERA). It is made available to Recipients with a
|
|
|
8 |
royalty-free licence for its use, reproduction, transfer
|
|
|
9 |
to other parties and amendment for any purpose not excluding
|
|
|
10 |
product development provided that any such use et cetera
|
|
|
11 |
shall be deemed to be acceptance of the following conditions:-
|
|
|
12 |
|
|
|
13 |
(1) Its Recipients shall ensure that this Notice is
|
|
|
14 |
reproduced upon any copies or amended versions of it;
|
|
|
15 |
|
|
|
16 |
(2) Any amended version of it shall be clearly marked to
|
|
|
17 |
show both the nature of and the organisation responsible
|
|
|
18 |
for the relevant amendment or amendments;
|
|
|
19 |
|
|
|
20 |
(3) Its onward transfer from a recipient to another
|
|
|
21 |
party shall be deemed to be that party's acceptance of
|
|
|
22 |
these conditions;
|
|
|
23 |
|
|
|
24 |
(4) DERA gives no warranty or assurance as to its
|
|
|
25 |
quality or suitability for any purpose and DERA accepts
|
|
|
26 |
no liability whatsoever in relation to any use to which
|
|
|
27 |
it may be put.
|
|
|
28 |
*/
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
/**********************************************************************
|
|
|
32 |
$Author: release $
|
|
|
33 |
$Date: 1998/01/17 15:56:05 $
|
|
|
34 |
$Revision: 1.1.1.1 $
|
|
|
35 |
$Log: comp_eq_exp.c,v $
|
|
|
36 |
* Revision 1.1.1.1 1998/01/17 15:56:05 release
|
|
|
37 |
* First version to be checked into rolling release.
|
|
|
38 |
*
|
|
|
39 |
* Revision 1.2 1995/09/12 10:59:14 currie
|
|
|
40 |
* gcc pedanttry
|
|
|
41 |
*
|
|
|
42 |
* Revision 1.1 1995/04/13 09:08:06 currie
|
|
|
43 |
* Initial revision
|
|
|
44 |
*
|
|
|
45 |
***********************************************************************/
|
|
|
46 |
/* a rather more complicated equivalence of expressions - allows sequences and
|
|
|
47 |
conditionals with tests which only jump to nearest conditional outlab;
|
|
|
48 |
initial call : comp_eq_exp(a,b,nilexp,nilexp) */
|
|
|
49 |
|
|
|
50 |
#include "config.h"
|
|
|
51 |
#include "tags.h"
|
|
|
52 |
#include "expmacs.h"
|
|
|
53 |
#include "exptypes.h"
|
|
|
54 |
#include "shapemacs.h"
|
|
|
55 |
#include "common_types.h"
|
|
|
56 |
#include "exp.h"
|
|
|
57 |
#include "comp_eq_exp.h"
|
|
|
58 |
|
|
|
59 |
bool comp_eq_explist
|
|
|
60 |
PROTO_N ( (a, b, laba, labb) )
|
|
|
61 |
PROTO_T ( exp a X exp b X exp laba X exp labb )
|
|
|
62 |
{
|
|
|
63 |
if (a==nilexp) return (b==nilexp);
|
|
|
64 |
if (b==nilexp || !comp_eq_exp(a,b,laba,labb) ) return 0;
|
|
|
65 |
if (last(a)) return (last(b));
|
|
|
66 |
if (last(b)) return 0;
|
|
|
67 |
return comp_eq_explist(bro(a), bro(b), laba, labb);
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
bool comp_eq_exp
|
|
|
72 |
PROTO_N ( (a, b, laba, labb) )
|
|
|
73 |
PROTO_T ( exp a X exp b X exp laba X exp labb )
|
|
|
74 |
{
|
|
|
75 |
if (name(a) != name(b) || !eq_shape(sh(a), sh(b))) return 0;
|
|
|
76 |
if (name(a) == seq_tag) {
|
|
|
77 |
return (comp_eq_explist(son(son(a)), son(son(b)), laba, labb) &&
|
|
|
78 |
comp_eq_exp(bro(son(a)), bro(son(b)),laba,labb) );
|
|
|
79 |
}
|
|
|
80 |
if (name(a) == cond_tag) {
|
|
|
81 |
exp fa = son(a);
|
|
|
82 |
exp fb = son(b);
|
|
|
83 |
return (comp_eq_exp(fa,fb, bro(fa), bro(fb)) &&
|
|
|
84 |
comp_eq_exp(bro(son(bro(fa))), bro(son(bro(fb))), laba, labb) );
|
|
|
85 |
}
|
|
|
86 |
if (name(a)==test_tag) {
|
|
|
87 |
return(pt(a)==laba && pt(b)==labb && props(a)==props(b) &&
|
|
|
88 |
comp_eq_explist(son(a),son(b), laba, labb) );
|
|
|
89 |
}
|
|
|
90 |
if (name(a)==name_tag) {
|
|
|
91 |
return (son(a)==son(b) && no(a)==no(b));
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
return (is_a(name(a)) && no(a)==no(b) &&
|
|
|
95 |
comp_eq_explist(son(a), son(b), laba, labb) );
|
|
|
96 |
}
|