PR libstdc++/3584
[official-gcc.git] / gcc / f / lex.h
blob04dfbed426d3333c51800efc72e252e5bf1ea7fe
1 /* lex.h -- Public #include File (module.h template V1.0)
2 Copyright (C) 1995 Free Software Foundation, Inc.
3 Contributed by James Craig Burley.
5 This file is part of GNU Fortran.
7 GNU Fortran is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GNU Fortran is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Fortran; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA.
22 Owning Modules:
23 lex.c
25 Modifications:
26 22-Aug-89 JCB 1.1
27 Change for new ffewhere interface.
30 /* Allow multiple inclusion to work. */
32 #ifndef GCC_F_LEX_H
33 #define GCC_F_LEX_H
35 /* Simple definitions and enumerations. */
37 typedef enum
39 FFELEX_typeNONE,
40 FFELEX_typeCOMMENT,
41 FFELEX_typeEOS,
42 FFELEX_typeEOF,
43 FFELEX_typeERROR,
44 FFELEX_typeRAW,
45 FFELEX_typeQUOTE,
46 FFELEX_typeDOLLAR,
47 FFELEX_typeHASH,
48 FFELEX_typePERCENT,
49 FFELEX_typeAMPERSAND,
50 FFELEX_typeAPOSTROPHE,
51 FFELEX_typeOPEN_PAREN,
52 FFELEX_typeCLOSE_PAREN,
53 FFELEX_typeASTERISK,
54 FFELEX_typePLUS,
55 FFELEX_typeMINUS,
56 FFELEX_typePERIOD,
57 FFELEX_typeSLASH,
58 FFELEX_typeNUMBER, /* Grep: [0-9][0-9]*. */
59 FFELEX_typeOPEN_ANGLE,
60 FFELEX_typeEQUALS,
61 FFELEX_typeCLOSE_ANGLE,
62 FFELEX_typeNAME, /* Grep: [A-Za-z][A-Za-z0-9_]*. */
63 FFELEX_typeCOMMA,
64 FFELEX_typePOWER, /* "**". */
65 FFELEX_typeCONCAT, /* "//". */
66 FFELEX_typeDEBUG,
67 FFELEX_typeNAMES, /* Same as FFELEX_typeNAME in initial
68 context. */
69 FFELEX_typeHOLLERITH, /* <text> part of <nn>H<text>. */
70 FFELEX_typeCHARACTER, /* <text> part of '<text>' or "<text>". */
71 FFELEX_typeCOLON,
72 FFELEX_typeSEMICOLON,
73 FFELEX_typeUNDERSCORE,
74 FFELEX_typeQUESTION,
75 FFELEX_typeOPEN_ARRAY, /* "(/". */
76 FFELEX_typeCLOSE_ARRAY, /* "/)". */
77 FFELEX_typeCOLONCOLON, /* "::". */
78 FFELEX_typeREL_LE, /* "<=". */
79 FFELEX_typeREL_NE, /* "<>". */
80 FFELEX_typeREL_EQ, /* "==". */
81 FFELEX_typePOINTS, /* "=>". */
82 FFELEX_typeREL_GE, /* ">=". */
83 FFELEX_type
84 } ffelexType;
86 /* Typedefs. */
88 typedef struct _lextoken_ *ffelexToken;
89 typedef void *lex_sigh_;
90 typedef lex_sigh_ (*lex_sigh__) (ffelexToken);
91 typedef lex_sigh__ (*ffelexHandler) (ffelexToken);
93 /* Include files needed by this one. */
95 #include "top.h"
96 #include "where.h"
98 /* Structure definitions. */
100 struct _lextoken_
102 long int id_; /* DEBUG ONLY. */
103 ffeTokenLength size;
104 ffeTokenLength length;
105 unsigned short uses;
106 char *text;
107 ffelexType type;
108 ffewhereLine where_line;
109 ffewhereColumn where_col;
110 ffewhereLine currentnames_line; /* For tracking NAMES tokens. */
111 ffewhereColumn currentnames_col; /* For tracking NAMES tokens. */
112 ffewhereTrack wheretrack; /* For tracking NAMES tokens. */
115 /* Global objects accessed by users of this module. */
118 /* Declare functions with prototypes. */
120 void ffelex_display_token (ffelexToken t);
121 bool ffelex_expecting_character (void);
122 ffelexHandler ffelex_file_fixed (ffewhereFile wf, FILE *f);
123 ffelexHandler ffelex_file_free (ffewhereFile wf, FILE *f);
124 void ffelex_hash_kludge (FILE *f);
125 void ffelex_init_1 (void);
126 bool ffelex_is_names_expected (void);
127 char *ffelex_line (void);
128 ffewhereColumnNumber ffelex_line_length (void);
129 ffewhereLineNumber ffelex_line_number (void);
130 void ffelex_set_expecting_hollerith (long length, char which,
131 ffewhereLine line,
132 ffewhereColumn column);
133 void ffelex_set_handler (ffelexHandler first);
134 void ffelex_set_hexnum (bool on);
135 void ffelex_set_include (ffewhereFile wf, bool free_form, FILE *fi);
136 void ffelex_set_names (bool on);
137 void ffelex_set_names_pure (bool on);
138 ffelexHandler ffelex_splice_tokens (ffelexHandler first, ffelexToken master,
139 ffeTokenLength start);
140 ffelexHandler ffelex_swallow_tokens (ffelexToken t, ffelexHandler handler);
141 ffelexToken ffelex_token_dollar_from_names (ffelexToken t,
142 ffeTokenLength start);
143 void ffelex_token_kill (ffelexToken t);
144 ffelexToken ffelex_token_name_from_names (ffelexToken t,
145 ffeTokenLength start,
146 ffeTokenLength len);
147 ffelexToken ffelex_token_names_from_names (ffelexToken t,
148 ffeTokenLength start,
149 ffeTokenLength len);
150 ffelexToken ffelex_token_new (void);
151 ffelexToken ffelex_token_new_character (const char *s, ffewhereLine l,
152 ffewhereColumn c);
153 ffelexToken ffelex_token_new_eof (void);
154 ffelexToken ffelex_token_new_name (const char *s, ffewhereLine l,
155 ffewhereColumn c);
156 ffelexToken ffelex_token_new_names (const char *s, ffewhereLine l,
157 ffewhereColumn c);
158 ffelexToken ffelex_token_new_number (const char *s, ffewhereLine l,
159 ffewhereColumn c);
160 ffelexToken ffelex_token_new_simple_ (ffelexType type, ffewhereLine l,
161 ffewhereColumn c);
162 ffelexToken ffelex_token_number_from_names (ffelexToken t,
163 ffeTokenLength start);
164 ffelexToken ffelex_token_uscore_from_names (ffelexToken t,
165 ffeTokenLength start);
166 ffelexToken ffelex_token_use (ffelexToken t);
168 /* Define macros. */
170 #define ffelex_init_0()
171 #define ffelex_init_2()
172 #define ffelex_init_3()
173 #define ffelex_init_4()
174 #define ffelex_is_firstnamechar(c) ISIDST (c)
175 #define ffelex_terminate_0()
176 #define ffelex_terminate_1()
177 #define ffelex_terminate_2()
178 #define ffelex_terminate_3()
179 #define ffelex_terminate_4()
180 #define ffelex_token_length(t) ((t)->length)
181 #define ffelex_token_new_eos(l,c) \
182 ffelex_token_new_simple_ (FFELEX_typeEOS, (l), (c))
183 #define ffelex_token_new_period(l,c) \
184 ffelex_token_new_simple_ (FFELEX_typePERIOD, (l), (c))
185 #define ffelex_token_strcmp(t1,t2) strcmp ((t1)->text, (t2)->text)
186 #define ffelex_token_text(t) ((t)->text)
187 #define ffelex_token_type(t) ((t)->type)
188 #define ffelex_token_where_column(t) ((t)->where_col)
189 #define ffelex_token_where_filename(t) \
190 ffewhere_line_filename ((t)->where_line)
191 #define ffelex_token_where_filelinenum(t) \
192 ffewhere_line_filelinenum((t)->where_line)
193 #define ffelex_token_where_line(t) ((t)->where_line)
194 #define ffelex_token_where_line_number(t) \
195 ffewhere_line_number ((t)->where_line)
196 #define ffelex_token_wheretrack(t) ((t)->wheretrack)
198 /* End of #include file. */
200 #endif /* ! GCC_F_LEX_H */