1 (* mcLexBuf.def provides a buffer for the all the tokens created by m2.lex.
3 Copyright (C) 2015-2022 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 This file is part of GNU Modula-2.
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)
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.
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/>. *)
22 DEFINITION MODULE mcLexBuf ;
25 FROM SYSTEM IMPORT ADDRESS ;
26 FROM mcReserved IMPORT toktype ;
27 FROM DynamicStrings IMPORT String ;
28 FROM mcComment IMPORT commentDesc ;
32 currenttoken : toktype ;
33 currentstring : ADDRESS ;
34 currentcolumn : CARDINAL ;
35 currentinteger: INTEGER ;
37 currentcomment: commentDesc ;
41 getProcedureComment - returns the procedure comment if it exists,
45 PROCEDURE getProcedureComment () : commentDesc ;
49 getBodyComment - returns the body comment if it exists,
53 PROCEDURE getBodyComment () : commentDesc ;
57 getAfterComment - returns the after comment if it exists,
61 PROCEDURE getAfterComment () : commentDesc ;
65 openSource - Attempts to open the source file, s.
66 The success of the operation is returned.
69 PROCEDURE openSource (s: String) : BOOLEAN ;
73 closeSource - closes the current open file.
76 PROCEDURE closeSource ;
80 reInitialize - re-initialize the all the data structures.
83 PROCEDURE reInitialize ;
87 resetForNewPass - reset the buffer pointers to the beginning ready for
91 PROCEDURE resetForNewPass ;
95 getToken - gets the next token into currenttoken.
102 insertToken - inserts a symbol, token, infront of the current token
103 ready for the next pass.
106 PROCEDURE insertToken (token: toktype) ;
110 insertTokenAndRewind - inserts a symbol, token, infront of the current token
111 and then moves the token stream back onto the inserted token.
114 PROCEDURE insertTokenAndRewind (token: toktype) ;
118 getPreviousTokenLineNo - returns the line number of the previous token.
121 PROCEDURE getPreviousTokenLineNo () : CARDINAL ;
125 getLineNo - returns the current line number where the symbol occurs in
129 PROCEDURE getLineNo () : CARDINAL ;
133 getTokenNo - returns the current token number.
136 PROCEDURE getTokenNo () : CARDINAL ;
140 tokenToLineNo - returns the line number of the current file for the
141 TokenNo. The depth refers to the include depth.
142 A depth of 0 is the current file, depth of 1 is the file
143 which included the current file. Zero is returned if the
144 depth exceeds the file nesting level.
147 PROCEDURE tokenToLineNo (tokenNo: CARDINAL; depth: CARDINAL) : CARDINAL ;
151 getColumnNo - returns the current column where the symbol occurs in
155 PROCEDURE getColumnNo () : CARDINAL ;
159 tokenToColumnNo - returns the column number of the current file for the
160 TokenNo. The depth refers to the include depth.
161 A depth of 0 is the current file, depth of 1 is the file
162 which included the current file. Zero is returned if the
163 depth exceeds the file nesting level.
166 PROCEDURE tokenToColumnNo (tokenNo: CARDINAL; depth: CARDINAL) : CARDINAL ;
170 findFileNameFromToken - returns the complete FileName for the appropriate
171 source file yields the token number, TokenNo.
172 The, Depth, indicates the include level: 0..n
173 Level 0 is the current. NIL is returned if n+1
177 PROCEDURE findFileNameFromToken (tokenNo: CARDINAL; depth: CARDINAL) : String ;
181 getFileName - returns a String defining the current file.
184 PROCEDURE getFileName () : String ;
187 (* ***********************************************************************
189 * These functions allow m2.lex to deliver tokens into the buffer
191 ************************************************************************* *)
194 addTok - adds a token to the buffer.
197 PROCEDURE addTok (t: toktype) ;
201 addTokCharStar - adds a token to the buffer and an additional string, s.
202 A copy of string, s, is made.
205 PROCEDURE addTokCharStar (t: toktype; s: ADDRESS) ;
209 addTokInteger - adds a token and an integer to the buffer.
212 PROCEDURE addTokInteger (t: toktype; i: INTEGER) ;
216 addTokComment - adds a token to the buffer and a comment descriptor, com.
219 PROCEDURE addTokComment (t: toktype; com: commentDesc) ;
223 setFile - sets the current filename to, filename.
226 PROCEDURE setFile (filename: ADDRESS) ;
230 pushFile - indicates that, filename, has just been included.
233 PROCEDURE pushFile (filename: ADDRESS) ;
237 popFile - indicates that we are returning to, filename, having finished
241 PROCEDURE popFile (filename: ADDRESS) ;