1 (* bnflex.def provides a simple lexical package for pg.
3 Copyright (C) 2001-2023 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 bnflex ;
28 Date : Mon Sep 13 08:53:02 1999
29 Last edit : Mon Sep 13 08:53:02 1999
30 Description: provides a simple lexical package for pg.
33 FROM NameKey IMPORT Name ;
34 EXPORT QUALIFIED IsSym, SymIs, TokenType, GetCurrentTokenType, GetCurrentToken,
35 GetChar, PutChar, OpenSource, CloseSource,
36 SkipUntilWhite, SkipWhite, SkipUntilEoln, AdvanceToken, IsReserved, PushBackToken,
40 TokenType = (identtok, literaltok, codetok, lbecomestok, rbecomestok, bartok, lsparatok, rsparatok,
41 lcparatok, rcparatok, lparatok, rparatok, errortok, tfunctok, symfunctok,
42 squotetok, dquotetok, moduletok, begintok, rulestok, endtok, lesstok, gretok,
43 tokentok, specialtok, firsttok, followtok, BNFtok, FNBtok, declarationtok,
48 OpenSource - Attempts to open the source file, a.
49 The success of the operation is returned.
52 PROCEDURE OpenSource (a: ARRAY OF CHAR) : BOOLEAN ;
56 CloseSource - Closes the current open file.
59 PROCEDURE CloseSource ;
63 GetChar - returns the current character on the input stream.
66 PROCEDURE GetChar () : CHAR ;
70 PutChar - pushes a character onto the push back stack, it also
71 returns the character which has been pushed.
74 PROCEDURE PutChar (ch: CHAR) : CHAR ;
78 SymIs - if t is equal to the current token the next token is read
79 and true is returned, otherwise false is returned.
82 PROCEDURE SymIs (t: TokenType) : BOOLEAN ;
86 IsSym - returns the result of the comparison between the current token
90 PROCEDURE IsSym (t: TokenType) : BOOLEAN ;
94 GetCurrentTokenType - returns the type of current token.
97 PROCEDURE GetCurrentTokenType () : TokenType ;
101 GetCurrentToken - returns the NameKey of the current token.
104 PROCEDURE GetCurrentToken () : Name ;
108 SkipUntilWhite - skips all characters until white space is seen.
111 PROCEDURE SkipUntilWhite ;
115 SkipWhite - skips all white space.
118 PROCEDURE SkipWhite ;
122 SkipUntilEoln - skips until a lf is seen. It consumes the lf.
125 PROCEDURE SkipUntilEoln ;
129 AdvanceToken - advances to the next token.
132 PROCEDURE AdvanceToken ;
136 IsReserved - returns TRUE if the name is a reserved word.
139 PROCEDURE IsReserved (name: Name) : BOOLEAN ;
143 PushBackToken - pushes a token back onto input.
146 PROCEDURE PushBackToken (t: Name) ;
150 SetDebugging - sets the debugging flag.
153 PROCEDURE SetDebugging (flag: BOOLEAN) ;