| 1 |
(* Scan.def Provides a primitive symbol fetching from input. |
| 2 |
|
| 3 |
Copyright (C) 2001-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 |
Under Section 7 of GPL version 3, you are granted additional |
| 19 |
permissions described in the GCC Runtime Library Exception, version |
| 20 |
3.1, as published by the Free Software Foundation. |
| 21 |
|
| 22 |
You should have received a copy of the GNU General Public License and |
| 23 |
a copy of the GCC Runtime Library Exception along with this program; |
| 24 |
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
| 25 |
<http://www.gnu.org/licenses/>. *) |
| 26 |
|
| 27 |
DEFINITION MODULE Scan ; |
| 28 |
|
| 29 |
(* Provides a primitive symbol fetching from input. |
| 30 |
Symbols are delimited by spaces and tabs. |
| 31 |
Limitation only allows one source file at |
| 32 |
a time to deliver symbols. *) |
| 33 |
|
| 34 |
|
| 35 |
EXPORT QUALIFIED GetNextSymbol, WriteError, |
| 36 |
OpenSource, CloseSource, |
| 37 |
TerminateOnError, DefineComments ; |
| 38 |
|
| 39 |
|
| 40 |
(* OpenSource - opens a source file for reading. *) |
| 41 |
|
| 42 |
PROCEDURE OpenSource (a: ARRAY OF CHAR) : BOOLEAN ; |
| 43 |
|
| 44 |
|
| 45 |
(* CloseSource - closes the current source file from reading. *) |
| 46 |
|
| 47 |
PROCEDURE CloseSource ; |
| 48 |
|
| 49 |
|
| 50 |
(* GetNextSymbol gets the next source symbol and returns it in a. *) |
| 51 |
|
| 52 |
PROCEDURE GetNextSymbol (VAR a: ARRAY OF CHAR) ; |
| 53 |
|
| 54 |
|
| 55 |
(* WriteError writes a message, a, under the source line, which *) |
| 56 |
(* attempts to pinpoint the Symbol at fault. *) |
| 57 |
|
| 58 |
PROCEDURE WriteError (a: ARRAY OF CHAR) ; |
| 59 |
|
| 60 |
|
| 61 |
(* |
| 62 |
TerminateOnError - exits with status 1 if we call WriteError. |
| 63 |
*) |
| 64 |
|
| 65 |
PROCEDURE TerminateOnError ; |
| 66 |
|
| 67 |
|
| 68 |
(* |
| 69 |
DefineComments - defines the start of comments within the source |
| 70 |
file. |
| 71 |
|
| 72 |
The characters in Start define the comment start |
| 73 |
and characters in End define the end. |
| 74 |
The BOOLEAN eoln determine whether the comment |
| 75 |
is terminated by end of line. If eoln is TRUE |
| 76 |
then End is ignored. |
| 77 |
|
| 78 |
If this procedure is never called then no comments |
| 79 |
are allowed. |
| 80 |
*) |
| 81 |
|
| 82 |
PROCEDURE DefineComments (Start, End: ARRAY OF CHAR; eoln: BOOLEAN) ; |
| 83 |
|
| 84 |
|
| 85 |
END Scan. |