2 |
7u83 |
1 |
/*
|
|
|
2 |
Crown Copyright (c) 1997, 1998
|
|
|
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 |
#ifndef PARSE_INCLUDED
|
|
|
32 |
#define PARSE_INCLUDED
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
/*
|
|
|
36 |
TYPE REPRESENTING A PARSER STATE
|
|
|
37 |
|
|
|
38 |
This type is used to represent the information to be saved before the
|
|
|
39 |
separate compilation of any saved preprocessing tokens and restored
|
|
|
40 |
afterwards.
|
|
|
41 |
*/
|
|
|
42 |
|
|
|
43 |
typedef struct pstate_tag {
|
|
|
44 |
LOCATION loc ;
|
|
|
45 |
OPTIONS *opts ;
|
|
|
46 |
int flag [10] ;
|
|
|
47 |
DECL_SPEC dspec [2] ;
|
|
|
48 |
NAMESPACE nspace [2] ;
|
|
|
49 |
STACK ( NAMESPACE ) nstack [3] ;
|
|
|
50 |
} PARSE_STATE ;
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
/*
|
|
|
54 |
TOKEN EXPANSION STATES
|
|
|
55 |
|
|
|
56 |
These values are used as arguments to expand_token to indicate the
|
|
|
57 |
current parsing state.
|
|
|
58 |
*/
|
|
|
59 |
|
|
|
60 |
#define EXPAND_NORMAL 0
|
|
|
61 |
#define EXPAND_AHEAD 1
|
|
|
62 |
#define EXPAND_RESCAN 2
|
|
|
63 |
#define EXPAND_TEMPLATE 3
|
|
|
64 |
#define EXPAND_IDENTIFIER 4
|
|
|
65 |
#define EXPAND_COLON_COLON 5
|
|
|
66 |
#define EXPAND_CHECK_COLON 6
|
|
|
67 |
#define EXPAND_DESTRUCTOR 7
|
|
|
68 |
#define EXPAND_STRING 8
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
/*
|
|
|
72 |
TOKEN PARSER DECLARATIONS
|
|
|
73 |
|
|
|
74 |
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
|
|
|
76 |
level lexical analysis and preprocessing routine.
|
|
|
77 |
*/
|
|
|
78 |
|
|
|
79 |
extern void init_parser PROTO_S ( ( PPTOKEN * ) ) ;
|
|
|
80 |
extern int expand_token PROTO_S ( ( int ) ) ;
|
|
|
81 |
extern int expand_preproc PROTO_S ( ( int ) ) ;
|
|
|
82 |
extern void rescan_template PROTO_S ( ( NAMESPACE ) ) ;
|
|
|
83 |
extern PPTOKEN *patch_tokens PROTO_S ( ( int ) ) ;
|
|
|
84 |
extern PPTOKEN *restore_parser PROTO_S ( ( void ) ) ;
|
|
|
85 |
extern PPTOKEN *read_loc_tokens PROTO_S ( ( PPTOKEN * ) ) ;
|
|
|
86 |
extern void snip_tokens PROTO_S ( ( PPTOKEN *, PPTOKEN * ) ) ;
|
|
|
87 |
extern void save_state PROTO_S ( ( PARSE_STATE *, int ) ) ;
|
|
|
88 |
extern void restore_state PROTO_S ( ( PARSE_STATE * ) ) ;
|
|
|
89 |
extern int crt_state_depth ;
|
|
|
90 |
|
|
|
91 |
|
|
|
92 |
/*
|
|
|
93 |
CURRENT TOKEN INFORMATION
|
|
|
94 |
|
|
|
95 |
These variables are used to store information about the current lexical
|
|
|
96 |
token as read by expand_token. crt_lex_token gives the current token
|
|
|
97 |
number, with any additional information being stored in crt_token.
|
|
|
98 |
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.
|
|
|
100 |
*/
|
|
|
101 |
|
|
|
102 |
extern PPTOKEN *crt_token ;
|
|
|
103 |
extern NAMESPACE crt_lookup ;
|
|
|
104 |
extern int crt_lex_token ;
|
|
|
105 |
extern int saved_lex_token ;
|
|
|
106 |
extern int last_lex_token ;
|
|
|
107 |
extern int have_syntax_error ;
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
/*
|
|
|
111 |
PARSER MACROS
|
|
|
112 |
|
|
|
113 |
These macros are used by the SID parser to access the output of the
|
|
|
114 |
lexical analysis and preprocessing routines. CURRENT_TERMINAL gives
|
|
|
115 |
the value of the current lexical token. ADVANCE_LEXER reads the next
|
|
|
116 |
lexical token. RESCAN_LEXER rescans the current token. SAVE_LEXER
|
|
|
117 |
and RESTORE_LEXER are used in exception handling.
|
|
|
118 |
*/
|
|
|
119 |
|
|
|
120 |
#define CURRENT_TERMINAL crt_lex_token
|
|
|
121 |
#define RESTORE_LEXER crt_lex_token = saved_lex_token ;
|
|
|
122 |
#define next_token() expand_token ( EXPAND_AHEAD )
|
|
|
123 |
#define RESCAN_LEXER crt_lex_token = expand_token ( EXPAND_RESCAN )
|
|
|
124 |
|
|
|
125 |
#define ADVANCE_LEXER\
|
|
|
126 |
{\
|
|
|
127 |
last_lex_token = crt_lex_token ;\
|
|
|
128 |
crt_lex_token = expand_token ( EXPAND_NORMAL ) ;\
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
|
|
|
132 |
#define SAVE_LEXER( T )\
|
|
|
133 |
{\
|
|
|
134 |
saved_lex_token = crt_lex_token ;\
|
|
|
135 |
crt_lex_token = ( T ) ;\
|
|
|
136 |
}
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
#endif
|