Debian Codegraph @

gcc/m2/mc/mcLexBuf.h

raw
1 /* mcLexBuf.h provides a C interface to the mcLexBuf module.
2
3 Copyright (C) 2015-2025 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <[email protected]>.
5
6 This file is part of GNU Modula-2.
7
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
12
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GNU Modula-2; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
21
22 #ifndef mcLexBufH
23 #define mcLexBufH
24
25
26 #include "mcReserved.h"
27
28 extern mcReserved_toktype mcLexBuf_currenttoken;
29 extern void *mcLexBuf_currentstring;
30 extern unsigned int mcLexBuf_currentcolumn;
31 extern int mcLexBuf_currentinteger;
32 extern void *mcLexBuf_currentcomment;
33
34
35 /*
36 openSource - Attempts to open the source file, s.
37 The success of the operation is returned.
38 */
39
40 extern unsigned int mcLexBuf_openSource (void *s);
41
42
43 /*
44 closeSource - closes the current open file.
45 */
46
47 extern void mcLexBuf_closeSource(void);
48
49
50 /*
51 reInitialize - re-initialize the all the data structures.
52 */
53
54 extern void mcLexBuf_reInitialize(void);
55
56
57 /*
58 resetForNewPass - reset the buffer pointers to the beginning ready for
59 a new pass
60 */
61
62 extern void mcLexBuf_resetForNewPass(void);
63
64
65 /*
66 getToken - gets the next token into currenttoken.
67 */
68
69 extern void mcLexBuf_getToken(void);
70
71
72 /*
73 insertToken - inserts a symbol, token, infront of the current token
74 ready for the next pass.
75 */
76
77 extern void mcLexBuf_insertToken(mcReserved_toktype token);
78
79
80 /*
81 insertTokenAndRewind - inserts a symbol, token, infront of the current token
82 and then moves the token stream back onto the inserted token.
83 */
84
85 extern void mcLexBuf_insertTokenAndRewind(mcReserved_toktype token);
86
87
88 /*
89 getPreviousTokenLineNo - returns the line number of the previous token.
90 */
91
92 extern unsigned int mcLexBuf_getPreviousTokenLineNo(void);
93
94
95 /*
96 getLineNo - returns the current line number where the symbol occurs in
97 the source file.
98 */
99
100 extern unsigned int mcLexBuf_getLineNo(void);
101
102
103 /*
104 getTokenNo - returns the current token number.
105 */
106
107 extern unsigned int mcLexBuf_getTokenNo(void);
108
109
110 /*
111 tokenToLineNo - returns the line number of the current file for the
112 TokenNo. The depth refers to the include depth.
113 A depth of 0 is the current file, depth of 1 is the file
114 which included the current file. Zero is returned if the
115 depth exceeds the file nesting level.
116 */
117
118 extern unsigned int mcLexBuf_tokenToLineNo(unsigned int TokenNo,
119 unsigned int depth);
120
121
122 /*
123 getColumnNo - returns the current column where the symbol occurs in
124 the source file.
125 */
126
127 extern unsigned int mcLexBuf_getColumnNo(void);
128
129
130 /*
131 tokenToColumnNo - returns the column number of the current file for the
132 TokenNo. The depth refers to the include depth.
133 A depth of 0 is the current file, depth of 1 is the file
134 which included the current file. Zero is returned if the
135 depth exceeds the file nesting level.
136 */
137
138 extern unsigned int mcLexBuf_tokenToColumnNo(unsigned int TokenNo,
139 unsigned int depth);
140
141
142 /*
143 tokenToLocation - returns the location_t corresponding to, TokenNo.
144 */
145
146 extern int mcLexBuf_tokenToLocation(unsigned int TokenNo);
147
148
149 /*
150 findFileNameFromToken - returns the complete FileName for the appropriate
151 source file yields the token number, TokenNo.
152 The, Depth, indicates the include level: 0..n
153 Level 0 is the current. NIL is returned if n+1
154 is requested.
155 */
156
157 extern void *mcLexBuf_findFileNameFromToken(unsigned int TokenNo,
158 unsigned int depth);
159
160
161 /*
162 getFileName - returns a String defining the current file.
163 */
164
165 extern void *mcLexBuf_getFileName(void);
166
167
168 /* ***********************************************************************
169 *
170 * These functions allow m2.lex to deliver tokens into the buffer
171 *
172 ************************************************************************* */
173
174 /*
175 addTok - adds a token to the buffer.
176 */
177
178 extern void mcLexBuf_addTok(mcReserved_toktype t);
179
180
181 /*
182 addTokCharStar - adds a token to the buffer and an additional string, s.
183 A copy of string, s, is made.
184 */
185
186 extern void mcLexBuf_addTokCharStar (mcReserved_toktype t, void *s);
187
188
189 /*
190 addTokInteger - adds a token and an integer to the buffer.
191 */
192
193 extern void mcLexBuf_addTokInteger (mcReserved_toktype t, int i);
194
195
196 /*
197 addTokComment - adds a token to the buffer and a comment descriptor, com.
198 */
199
200 extern void mcLexBuf_addTokComment (mcReserved_toktype t, void *com);
201
202
203 /*
204 setFile - sets the current filename to, filename.
205 */
206
207 extern void mcLexBuf_setFile(void *filename);
208
209
210 /*
211 pushFile - indicates that, filename, has just been included.
212 */
213
214 extern void mcLexBuf_pushFile(void *filename);
215
216
217 /*
218 popFile - indicates that we are returning to, filename, having finished
219 an include.
220 */
221
222 extern void mcLexBuf_popFile(void *filename);
223
224 #endif