| 1 |
(* cflex.def provides a Modula-2 definition module for C lexical analysis. |
| 2 |
|
| 3 |
Copyright (C) 2003-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 |
DEFINITION MODULE cflex ; |
| 23 |
|
| 24 |
(* |
| 25 |
Title : clex |
| 26 |
Author : Gaius Mulley |
| 27 |
System : GNU Modula-2 |
| 28 |
Date : Thu Jan 23 12:39:36 2003 |
| 29 |
Revision : $Version$ |
| 30 |
Description: provides a Modula-2 definition module for C lexical analysis. |
| 31 |
*) |
| 32 |
|
| 33 |
FROM SYSTEM IMPORT ADDRESS ; |
| 34 |
EXPORT QUALIFIED GetToken, AdvanceToken, CError, OpenSource, CloseSource, GetLineNo, |
| 35 |
ParsingOn, SetSearchPath, AddTypeDef ; |
| 36 |
|
| 37 |
|
| 38 |
(* |
| 39 |
CloseSource - provided for semantic sugar |
| 40 |
*) |
| 41 |
|
| 42 |
PROCEDURE CloseSource ; |
| 43 |
|
| 44 |
|
| 45 |
(* |
| 46 |
OpenSource - returns TRUE if file, s, can be opened and |
| 47 |
all tokens are taken from this file. |
| 48 |
*) |
| 49 |
|
| 50 |
PROCEDURE OpenSource (s: ADDRESS) : BOOLEAN ; |
| 51 |
|
| 52 |
|
| 53 |
(* |
| 54 |
GetToken - returns the ADDRESS of the next token. |
| 55 |
*) |
| 56 |
|
| 57 |
PROCEDURE GetToken () : ADDRESS ; |
| 58 |
|
| 59 |
|
| 60 |
(* |
| 61 |
AdvanceToken - move onto the next token. |
| 62 |
*) |
| 63 |
|
| 64 |
PROCEDURE AdvanceToken ; |
| 65 |
|
| 66 |
|
| 67 |
(* |
| 68 |
GetLineNo - returns the current line number. |
| 69 |
*) |
| 70 |
|
| 71 |
PROCEDURE GetLineNo () : CARDINAL ; |
| 72 |
|
| 73 |
|
| 74 |
(* |
| 75 |
CError - displays the error message, s, after the code line and pointer |
| 76 |
to the erroneous token. |
| 77 |
*) |
| 78 |
|
| 79 |
PROCEDURE CError (s: ADDRESS) ; |
| 80 |
|
| 81 |
|
| 82 |
(* |
| 83 |
ParsingOn - if t is FALSE then the lexical analysis will |
| 84 |
consume all lines except when a line is one of |
| 85 |
'#endif' or '#else' or '#if' or '#ifdef' |
| 86 |
*) |
| 87 |
|
| 88 |
PROCEDURE ParsingOn (t: BOOLEAN) ; |
| 89 |
|
| 90 |
|
| 91 |
(* |
| 92 |
SetSearchPath - reassigns the search path to newPath. |
| 93 |
*) |
| 94 |
|
| 95 |
PROCEDURE SetSearchPath (newPath: ADDRESS) ; |
| 96 |
|
| 97 |
|
| 98 |
(* |
| 99 |
AddTypeDef - adds the string, a, to the list of typedefs. |
| 100 |
*) |
| 101 |
|
| 102 |
PROCEDURE AddTypeDef (a: ADDRESS) ; |
| 103 |
|
| 104 |
|
| 105 |
END cflex. |