Subversion Repositories tendra.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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:06 $
34
$Revision: 1.1.1.1 $
35
$Log: spec_tok.c,v $
36
 * Revision 1.1.1.1  1998/01/17  15:56:06  release
37
 * First version to be checked into rolling release.
38
 *
39
 * Revision 1.1  1995/04/13  09:08:06  currie
40
 * Initial revision
41
 *
42
***********************************************************************/
43
 
44
/*
45
^^^	21/12/92  jmf	Added ~div as special token
46
^^^	26/03/93  jmf	Changes for new spec 2.1
47
^^^	24/05/93  jmf	Added ~alloca as special token, not alloc
48
^^^	10/06/93  jmf	Change long to int, remove extern declarations.
49
^^^	19/08/93  jmf	Put arith_type, promote, sign_promote, convert
50
^^^			into c_arith-type.h in machine directories.
51
^^^	19/08/93  jmf	Set crt_lno in exp_to_source
52
^^^	23/09/93  jmf	Use natmacs.h
53
*/
54
 
55
#include "config.h"
56
#include "common_types.h"
57
#include "basicread.h"
58
#include "tags.h"
59
#include "exp.h"
60
#include "expmacs.h"
61
#include "diag_fns.h"
62
#include "flags.h"
63
#include "check.h"
64
#include "me_fns.h"
65
#include "externs.h"
66
#include "installglob.h"
67
#include "messages_r.h"
68
#include "main_reads.h"
69
#include "install_fns.h"
70
#include "c_arith_type.h"
71
#include "natmacs.h"
72
#include "spec_tok.h"
73
 
74
 
75
/* intercepts specially defined tokens */
76
 
77
tokval special_token
78
    PROTO_N ( (t, pars, sortcode, done) )
79
    PROTO_T ( token t X bitstream pars X int sortcode X int * done )
80
{
81
  tokval tkv;
82
  UNUSED(sortcode);
83
 
84
  if (t -> tok_name == (char*)0) {
85
    SET(tkv); /* call looks at done to see if result is meaningful */
86
    return tkv;
87
  };
88
 
89
#if is80x86
90
  if (!strcmp(t -> tok_name, "~div"))  {
91
      exp arg1, arg2;
92
      place old_place;
93
      old_place = keep_place();
94
      set_place(pars);
95
      arg1 = hold_check(d_exp());
96
      arg2 = hold_check(d_exp());
97
 
98
      set_place(old_place);
99
      tkv.tk_exp = me_b2(arg1, arg2, div0_tag);
100
      *done = 1;
101
      return tkv;
102
  };
103
  if (!strcmp(t -> tok_name, "~arith_type")) {
104
    int a, b;
105
    place old_place;
106
    signed_nat sn;
107
    old_place = keep_place();
108
    set_place(pars);
109
    sn = d_signed_nat();
110
    a = snatint(sn);
111
    sn = d_signed_nat();
112
    b = snatint(sn);
113
    set_place(old_place);
114
    snatint(sn) = arith_type(a, b);
115
    tkv.tk_signed_nat = sn;
116
    *done = 1;
117
    return tkv;
118
  };
119
  if (!strcmp(t -> tok_name, "~promote")) {
120
    int a;
121
    place old_place;
122
    signed_nat sn;
123
    old_place = keep_place();
124
    set_place(pars);
125
    sn = d_signed_nat();
126
    a = snatint(sn);
127
    set_place(old_place);
128
    snatint(sn) = promote(a);
129
    tkv.tk_signed_nat = sn;
130
    *done = 1;
131
    return tkv;
132
  };
133
  if (!strcmp(t -> tok_name, "~sign_promote")) {
134
    int a;
135
    place old_place;
136
    signed_nat sn;
137
    old_place = keep_place();
138
    set_place(pars);
139
    sn = d_signed_nat();
140
    a = snatint(sn);
141
    set_place(old_place);
142
    snatint(sn) = sign_promote(a);
143
    tkv.tk_signed_nat = sn;
144
    *done = 1;
145
    return tkv;
146
  };
147
  if (!strcmp(t -> tok_name, "~convert")) {
148
    int a;
149
    place old_place;
150
    signed_nat sn;
151
    old_place = keep_place();
152
    set_place(pars);
153
    sn = d_signed_nat();
154
    a = snatint(sn);
155
    set_place(old_place);
156
    tkv.tk_variety = convert((unsigned)a);
157
    *done = 1;
158
    return tkv;
159
  };
160
#endif
161
  if (!strcmp(t -> tok_name, "~alloca"))  {
162
      exp arg1;
163
      place old_place;
164
      old_place = keep_place();
165
      set_place(pars);
166
      arg1 = hold_check(d_exp());
167
      set_place(old_place);
168
      tkv.tk_exp = hold_check(me_u3(f_pointer(long_to_al(8)),
169
			   arg1, alloca_tag));
170
      *done = 1;
171
      has_alloca = 1;
172
      return tkv;
173
  };
174
 
175
  if (!strcmp(t -> tok_name, "~exp_to_source") ||
176
      !strcmp(t -> tok_name, "~diag_id_scope") ||
177
      !strcmp(t -> tok_name, "~diag_type_scope") ||
178
      !strcmp(t -> tok_name, "~diag_tag_scope"))  {
179
 
180
      place old_place;
181
      old_place = keep_place();
182
      set_place(pars);
183
      tkv.tk_exp = hold_check(d_exp());
184
      *done = 1;
185
 
186
      if (!diagnose)
187
        {
188
          set_place(old_place);
189
          return tkv;
190
        };
191
 
192
     if (!strcmp(t -> tok_name, "~exp_to_source"))
193
       {exp r;
194
        diag_info * di = read_exp_to_source();
195
	crt_lno = natint(di -> data.source.end.line_no);
196
	crt_charno = natint(di -> data.source.end.char_off);
197
	crt_flnm = di -> data.source.beg.file->file.ints.chars;
198
        r = getexp(sh(tkv.tk_exp), nilexp, 0, tkv.tk_exp, nilexp,
199
                   1, 0, diagnose_tag);
200
        setfather(r, tkv.tk_exp);
201
        dno(r) = di;
202
        tkv.tk_exp = r;
203
        set_place(old_place);
204
        return tkv;
205
       };
206
 
207
     if (!strcmp(t -> tok_name, "~diag_id_scope"))
208
       {exp r;
209
        diag_info * di = read_diag_id_scope();
210
        r = getexp(sh(tkv.tk_exp), nilexp, 0, tkv.tk_exp, nilexp,
211
                   2, 0, diagnose_tag);
212
        setfather(r, tkv.tk_exp);
213
        dno(r) = di;
214
        tkv.tk_exp = r;
215
        set_place(old_place);
216
        return tkv;
217
       };
218
 
219
     if (!strcmp(t -> tok_name, "~diag_type_scope"))
220
       {exp r;
221
        diag_info * di = read_diag_type_scope();
222
        r = getexp(sh(tkv.tk_exp), nilexp, 0, tkv.tk_exp, nilexp,
223
                   3, 0, diagnose_tag);
224
        setfather(r, tkv.tk_exp);
225
        dno(r) = di;
226
        tkv.tk_exp = r;
227
        set_place(old_place);
228
        return tkv;
229
       };
230
 
231
     if (!strcmp(t -> tok_name, "~diag_tag_scope"))
232
       {exp r;
233
        diag_info * di = read_diag_tag_scope();
234
        r = getexp(sh(tkv.tk_exp), nilexp, 0, tkv.tk_exp, nilexp,
235
                   4, 0, diagnose_tag);
236
        setfather(r, tkv.tk_exp);
237
        dno(r) = di;
238
        tkv.tk_exp = r;
239
        set_place(old_place);
240
        return tkv;
241
       };
242
 
243
 
244
  };
245
 
246
  SET(tkv); /* call looks at done to see if result is meaningful */
247
  return tkv;
248
}