1 (* M2Reserved.def determines is a token is a reserved word.
3 Copyright (C) 2001-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 M2Reserved ;
28 Description: implements a procedure to determine if a symbol is a
29 Modula-2 reserved word and provides conversion between
30 toktype and the equivalent stringed, Name.
33 FROM NameKey IMPORT Name ;
35 EXPORT QUALIFIED IsReserved, tokToTok,
37 NulTok, PlusTok, MinusTok, TimesTok, DivideTok, BecomesTok,
38 AmbersandTok, PeriodTok, CommaTok, SemiColonTok, LParaTok,
39 LSBraTok, LCBraTok, UpArrowTok, SingleQuoteTok, EqualTok,
40 HashTok, LessTok, GreaterTok, LessGreaterTok, LessEqualTok,
41 GreaterEqualTok, PeriodPeriodTok, ColonTok, RParaTok,
42 RSBraTok, RCBraTok, BarTok, DoubleQuotesTok,
44 AndTok, ArrayTok, BeginTok, ByTok, CaseTok, ConstTok,
45 DefinitionTok, DivTok, DoTok, ElseTok, ElsifTok, EndTok,
47 ExitTok, ExportTok, FinallyTok, ForTok, FromTok, IfTok,
48 ImplementationTok, ImportTok, InTok, LoopTok, ModTok,
49 ModuleTok, NotTok, OfTok, OrTok,
50 PackedSetTok, PointerTok, ProcedureTok,
51 QualifiedTok, UnQualifiedTok, RecordTok, RetryTok,
53 ReturnTok, SetTok, ThenTok, ToTok, TypeTok, UntilTok, VarTok,
56 (* additional tokens which extend PIM Modula-2 slightly *)
57 EofTok, AsmTok, VolatileTok, DateTok, LineTok, FileTok,
58 AttributeTok, BuiltinTok, InlineTok,
62 toktype = (eoftok, plustok, minustok, timestok, dividetok,
63 becomestok, ambersandtok, periodtok, commatok,
64 semicolontok, lparatok, rparatok, lsbratok, rsbratok,
65 lcbratok, rcbratok, uparrowtok, singlequotetok,
66 equaltok, hashtok, lesstok, greatertok, lessgreatertok,
67 lessequaltok, greaterequaltok,
68 ldirectivetok, rdirectivetok,
70 colontok, doublequotestok, bartok, andtok,
71 arraytok, begintok, bytok, casetok, consttok,
72 definitiontok, divtok, dotok, elsetok, elsiftok,
73 endtok, excepttok, exittok, exporttok, finallytok,
74 fortok, fromtok, iftok, implementationtok,
75 importtok, intok, looptok, modtok,
76 moduletok, nottok, oftok, ortok,
77 packedsettok, pointertok, proceduretok,
78 qualifiedtok, unqualifiedtok,
79 recordtok, remtok, repeattok, retrytok, returntok,
81 totok, typetok, untiltok, vartok, whiletok, withtok,
82 asmtok, volatiletok, periodperiodperiodtok,
83 datetok, linetok, filetok,
84 attributetok, builtintok, inlinetok,
85 integertok, identtok, realtok, stringtok,
89 NulTok, PlusTok, MinusTok, TimesTok, DivideTok, BecomesTok,
90 AmbersandTok, PeriodTok, CommaTok, SemiColonTok, LParaTok,
91 LSBraTok, LCBraTok, UpArrowTok, SingleQuoteTok, EqualTok,
92 HashTok, LessTok, GreaterTok, LessGreaterTok, LessEqualTok,
93 GreaterEqualTok, LDirectiveTok, RDirectiveTok,
94 PeriodPeriodTok, ColonTok, RParaTok,
95 RSBraTok, RCBraTok, BarTok, DoubleQuotesTok,
97 AndTok, ArrayTok, BeginTok, ByTok, CaseTok, ConstTok,
98 DefinitionTok, DivTok, DoTok, ElseTok, ElsifTok, EndTok,
99 ExceptTok, ExitTok, ExportTok, FinallyTok, ForTok, FromTok,
100 IfTok, ImplementationTok, ImportTok, InTok, LoopTok, ModTok,
101 ModuleTok, NotTok, OfTok, OrTok,
102 PackedSetTok, PointerTok, ProcedureTok,
103 QualifiedTok, UnQualifiedTok, RecordTok, RemTok, RepeatTok,
104 RetryTok, ReturnTok, SetTok, ThenTok, ToTok, TypeTok,
105 UntilTok, VarTok, WhileTok, WithTok,
107 EofTok, AsmTok, VolatileTok,
108 DateTok, LineTok, FileTok,
109 AttributeTok, BuiltinTok, InlineTok: Name ;
113 IsReserved - returns TRUE if the symbol, Name, is a reserved word.
114 If TRUE it also sets tok to the appropriate enumerated
118 PROCEDURE IsReserved (n: Name; VAR tok: toktype) : BOOLEAN ;
122 tokToTok - returns a Tok given the enumerated variable, t.
125 PROCEDURE tokToTok (t: toktype) : Name ;