Subversion Repositories tendra.SVN

Rev

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

Rev Author Line No. Line
2 7u83 1
/*
6 7u83 2
 * Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are met:
7
 *
8
 * 1. Redistributions of source code must retain the above copyright notice,
9
 *    this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
11
 *    this list of conditions and the following disclaimer in the documentation
12
 *    and/or other materials provided with the distribution.
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
14
 *    may be used to endorse or promote products derived from this software
15
 *    without specific, prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 *
29
 * $Id$
30
 */
31
/*
2 7u83 32
    		 Crown Copyright (c) 1997
6 7u83 33
 
2 7u83 34
    This TenDRA(r) Computer Program is subject to Copyright
35
    owned by the United Kingdom Secretary of State for Defence
36
    acting through the Defence Evaluation and Research Agency
37
    (DERA).  It is made available to Recipients with a
38
    royalty-free licence for its use, reproduction, transfer
39
    to other parties and amendment for any purpose not excluding
40
    product development provided that any such use et cetera
41
    shall be deemed to be acceptance of the following conditions:-
6 7u83 42
 
2 7u83 43
        (1) Its Recipients shall ensure that this Notice is
44
        reproduced upon any copies or amended versions of it;
6 7u83 45
 
2 7u83 46
        (2) Any amended version of it shall be clearly marked to
47
        show both the nature of and the organisation responsible
48
        for the relevant amendment or amendments;
6 7u83 49
 
2 7u83 50
        (3) Its onward transfer from a recipient to another
51
        party shall be deemed to be that party's acceptance of
52
        these conditions;
6 7u83 53
 
2 7u83 54
        (4) DERA gives no warranty or assurance as to its
55
        quality or suitability for any purpose and DERA accepts
56
        no liability whatsoever in relation to any use to which
57
        it may be put.
58
*/
59
 
60
 
61
/*** c-code.h --- SID C code stuff.
62
 *
63
 ** Author: Steve Folkes <smf@hermes.mod.uk>
64
 *
65
 *** Commentary:
66
 *
67
 * See the file "c-code.c" for details.
68
 *
69
 *** Change Log:
70
 * $Log: c-code.h,v $
71
 * Revision 1.1.1.1  1998/01/17  15:57:43  release
72
 * First version to be checked into rolling release.
73
 *
74
 * Revision 1.2  1994/12/15  09:56:25  smf
75
 * Brought into line with OSSG C Coding Standards Document, as per
76
 * "CR94_178.sid+tld-update".
77
 *
78
 * Revision 1.1.1.1  1994/07/25  16:04:17  smf
79
 * Initial import of SID 1.8 non shared files.
80
 *
81
**/
82
 
83
/****************************************************************************/
84
 
85
#ifndef H_C_CODE
86
#define H_C_CODE
87
 
88
#include "os-interface.h"
89
#include "c-out-info.h"
90
#include "cstring.h"
91
#include "dalloc.h"
92
#include "dstring.h"
93
#include "entry.h"
94
#include "rstack.h"
95
#include "rule.h"
96
#include "table.h"
97
#include "types.h"
98
 
99
/*--------------------------------------------------------------------------*/
100
 
101
#ifdef FS_NO_ENUM
102
typedef int CCodeItemTypeT, *CCodeItemTypeP;
103
#define CCT_STRING	(0)
104
#define CCT_LABEL	(1)
105
#define CCT_IDENT	(2)
106
#define CCT_MOD_IDENT	(3)
107
#define CCT_REF_IDENT	(4)
108
#define CCT_EXCEPTION	(5)
109
#define CCT_ADVANCE	(6)
110
#define CCT_TERMINAL	(7)
111
#else
112
typedef enum {
113
    CCT_STRING,
114
    CCT_LABEL,
115
    CCT_IDENT,
116
    CCT_MOD_IDENT,
117
    CCT_REF_IDENT,
118
    CCT_EXCEPTION,
119
    CCT_ADVANCE,
120
    CCT_TERMINAL
121
} CCodeItemTypeT, *CCodeItemTypeP;
122
#endif /* defined (FS_NO_ENUM) */
123
 
124
typedef struct CCodeItemT {
125
    struct CCodeItemT	       *next;
126
    CCodeItemTypeT		type;
127
    union {
128
	NStringT		string;
129
	EntryP			ident;
130
    } u;
131
} CCodeItemT, *CCodeItemP;
132
 
133
typedef struct CCodeT {
134
    CCodeItemP			head;
135
    CCodeItemP		       *tail;
136
    unsigned			line;
137
    CStringP			file;
138
    TypeTupleT			param;
139
    TypeTupleT			result;
140
} CCodeT, *CCodeP;
141
 
142
/*--------------------------------------------------------------------------*/
143
 
6 7u83 144
extern CCodeP		c_code_create(CStringP, unsigned);
145
extern void		c_code_append_string(CCodeP, NStringP);
146
extern void		c_code_append_label(CCodeP, NStringP);
147
extern void		c_code_append_identifier(CCodeP, NStringP);
148
extern void		c_code_append_modifiable(CCodeP, NStringP);
149
extern void		c_code_append_reference(CCodeP, NStringP);
150
extern void		c_code_append_exception(CCodeP);
151
extern void		c_code_append_advance(CCodeP);
152
extern void		c_code_append_terminal(CCodeP);
153
extern void		c_code_check(CCodeP, BoolT, BoolT, TypeTupleP,
154
				     TypeTupleP, TableP);
155
extern CStringP		c_code_file(CCodeP);
156
extern unsigned		c_code_line(CCodeP);
157
extern TypeTupleP	c_code_param(CCodeP);
158
extern TypeTupleP	c_code_result(CCodeP);
159
extern void		c_code_deallocate(CCodeP);
2 7u83 160
 
6 7u83 161
extern void		c_output_c_code_action(COutputInfoP, CCodeP,
162
					       TypeTupleP, TypeTupleP,
163
					       SaveRStackP, RuleP);
164
extern void		c_output_c_code_basic(COutputInfoP, CCodeP, TypeTupleP,
165
					      SaveRStackP);
166
extern void		c_output_c_code_assign(COutputInfoP, CCodeP, EntryP,
167
					       EntryP, EntryP, BoolT, BoolT);
168
extern void		c_output_c_code_param_assign(COutputInfoP, CCodeP,
169
						     EntryP, EntryP);
170
extern void		c_output_c_code_result_assign(COutputInfoP, CCodeP,
171
						      EntryP, EntryP);
172
extern void		c_output_c_code(COutputInfoP, CCodeP);
2 7u83 173
 
174
/*--------------------------------------------------------------------------*/
175
 
176
#ifdef FS_FAST
6 7u83 177
#define c_code_file(c)	((c)->file)
178
#define c_code_line(c)	((c)->line)
2 7u83 179
#endif /* defined (FS_FAST) */
180
 
181
#endif /* !defined (H_C_CODE) */
182
 
183
/*
184
 * Local variables(smf):
185
 * eval: (include::add-path-entry "../os-interface" "../library")
186
 * eval: (include::add-path-entry "../transforms" "../output")
187
 * eval: (include::add-path-entry "../c-output" "../generated")
188
 * end:
189
**/