Subversion Repositories tendra.SVN

Rev

Rev 5 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5 Rev 6
Line -... Line 1...
-
 
1
/*
-
 
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
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997, 1998
32
    		 Crown Copyright (c) 1997, 1998
3
    
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
        (1) Its Recipients shall ensure that this Notice is
43
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
44
        reproduced upon any copies or amended versions of it;
15
    
45
 
16
        (2) Any amended version of it shall be clearly marked to
46
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
47
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
48
        for the relevant amendment or amendments;
19
    
49
 
20
        (3) Its onward transfer from a recipient to another
50
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
51
        party shall be deemed to be that party's acceptance of
22
        these conditions;
52
        these conditions;
23
    
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
Line 39... Line 69...
39
    separate compilation of any saved preprocessing tokens and restored
69
    separate compilation of any saved preprocessing tokens and restored
40
    afterwards.
70
    afterwards.
41
*/
71
*/
42
 
72
 
43
typedef struct pstate_tag {
73
typedef struct pstate_tag {
44
    LOCATION loc ;
74
	LOCATION loc;
45
    OPTIONS *opts ;
75
	OPTIONS *opts;
46
    int flag [10] ;
76
	int flag[10];
47
    DECL_SPEC dspec [2] ;
77
	DECL_SPEC dspec[2];
48
    NAMESPACE nspace [2] ;
78
	NAMESPACE nspace[2];
49
    STACK ( NAMESPACE ) nstack [3] ;
79
	STACK(NAMESPACE)nstack[3];
50
} PARSE_STATE ;
80
} PARSE_STATE;
51
 
81
 
52
 
82
 
53
/*
83
/*
54
    TOKEN EXPANSION STATES
84
    TOKEN EXPANSION STATES
55
 
85
 
Line 74... Line 104...
74
    The routines in this module are concerned with reading the next lexical
104
    The routines in this module are concerned with reading the next lexical
75
    token from the input file.  They include expand_token which is the top
105
    token from the input file.  They include expand_token which is the top
76
    level lexical analysis and preprocessing routine.
106
    level lexical analysis and preprocessing routine.
77
*/
107
*/
78
 
108
 
79
extern void init_parser PROTO_S ( ( PPTOKEN * ) ) ;
109
extern void init_parser(PPTOKEN *);
80
extern int expand_token PROTO_S ( ( int ) ) ;
110
extern int expand_token(int);
81
extern int expand_preproc PROTO_S ( ( int ) ) ;
111
extern int expand_preproc(int);
82
extern void rescan_template PROTO_S ( ( NAMESPACE ) ) ;
112
extern void rescan_template(NAMESPACE);
83
extern PPTOKEN *patch_tokens PROTO_S ( ( int ) ) ;
113
extern PPTOKEN *patch_tokens(int);
84
extern PPTOKEN *restore_parser PROTO_S ( ( void ) ) ;
114
extern PPTOKEN *restore_parser(void);
85
extern PPTOKEN *read_loc_tokens PROTO_S ( ( PPTOKEN * ) ) ;
115
extern PPTOKEN *read_loc_tokens(PPTOKEN *);
86
extern void snip_tokens PROTO_S ( ( PPTOKEN *, PPTOKEN * ) ) ;
116
extern void snip_tokens(PPTOKEN *, PPTOKEN *);
87
extern void save_state PROTO_S ( ( PARSE_STATE *, int ) ) ;
117
extern void save_state(PARSE_STATE *, int);
88
extern void restore_state PROTO_S ( ( PARSE_STATE * ) ) ;
118
extern void restore_state(PARSE_STATE *);
89
extern int crt_state_depth ;
119
extern int crt_state_depth;
90
 
120
 
91
 
121
 
92
/*
122
/*
93
    CURRENT TOKEN INFORMATION
123
    CURRENT TOKEN INFORMATION
94
 
124
 
Line 97... Line 127...
97
    number, with any additional information being stored in crt_token.
127
    number, with any additional information being stored in crt_token.
98
    last_lex_token gives the previous value of crt_lex_token.  Finally
128
    last_lex_token gives the previous value of crt_lex_token.  Finally
99
    saved_lex_token is used as a temporary store in exception handling.
129
    saved_lex_token is used as a temporary store in exception handling.
100
*/
130
*/
101
 
131
 
102
extern PPTOKEN *crt_token ;
132
extern PPTOKEN *crt_token;
103
extern NAMESPACE crt_lookup ;
133
extern NAMESPACE crt_lookup;
104
extern int crt_lex_token ;
134
extern int crt_lex_token;
105
extern int saved_lex_token ;
135
extern int saved_lex_token;
106
extern int last_lex_token ;
136
extern int last_lex_token;
107
extern int have_syntax_error ;
137
extern int have_syntax_error;
108
 
138
 
109
 
139
 
110
/*
140
/*
111
    PARSER MACROS
141
    PARSER MACROS
112
 
142
 
Line 116... Line 146...
116
    lexical token.  RESCAN_LEXER rescans the current token.  SAVE_LEXER
146
    lexical token.  RESCAN_LEXER rescans the current token.  SAVE_LEXER
117
    and RESTORE_LEXER are used in exception handling.
147
    and RESTORE_LEXER are used in exception handling.
118
*/
148
*/
119
 
149
 
120
#define CURRENT_TERMINAL	crt_lex_token
150
#define CURRENT_TERMINAL	crt_lex_token
121
#define RESTORE_LEXER		crt_lex_token = saved_lex_token ;
151
#define RESTORE_LEXER		crt_lex_token = saved_lex_token;
122
#define next_token()		expand_token ( EXPAND_AHEAD )
152
#define next_token()		expand_token(EXPAND_AHEAD)
123
#define RESCAN_LEXER		crt_lex_token = expand_token ( EXPAND_RESCAN )
153
#define RESCAN_LEXER		crt_lex_token = expand_token(EXPAND_RESCAN)
124
 
154
 
125
#define ADVANCE_LEXER\
155
#define ADVANCE_LEXER					\
126
    {\
156
    {							\
127
	last_lex_token = crt_lex_token ;\
157
	last_lex_token = crt_lex_token;			\
128
	crt_lex_token = expand_token ( EXPAND_NORMAL ) ;\
158
	crt_lex_token = expand_token(EXPAND_NORMAL);	\
129
    }
159
    }
130
 
160
 
131
 
161
 
132
#define SAVE_LEXER( T )\
162
#define SAVE_LEXER(T)				\
133
    {\
163
    {						\
134
	saved_lex_token = crt_lex_token ;\
164
	saved_lex_token = crt_lex_token;	\
135
	crt_lex_token = ( T ) ;\
165
	crt_lex_token = (T);			\
136
    }
166
    }
137
 
167
 
138
 
168
 
139
#endif
169
#endif