| 1 |
281 |
jeremybenn |
------------------------------------------------------------------------------
|
| 2 |
|
|
-- --
|
| 3 |
|
|
-- GNAT COMPILER COMPONENTS --
|
| 4 |
|
|
-- --
|
| 5 |
|
|
-- S C N --
|
| 6 |
|
|
-- --
|
| 7 |
|
|
-- S p e c --
|
| 8 |
|
|
-- --
|
| 9 |
|
|
-- Copyright (C) 1992-2008, Free Software Foundation, Inc. --
|
| 10 |
|
|
-- --
|
| 11 |
|
|
-- GNAT is free software; you can redistribute it and/or modify it under --
|
| 12 |
|
|
-- terms of the GNU General Public License as published by the Free Soft- --
|
| 13 |
|
|
-- ware Foundation; either version 3, or (at your option) any later ver- --
|
| 14 |
|
|
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
|
| 15 |
|
|
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
|
| 16 |
|
|
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
|
| 17 |
|
|
-- for more details. You should have received a copy of the GNU General --
|
| 18 |
|
|
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
|
| 19 |
|
|
-- http://www.gnu.org/licenses for a complete copy of the license. --
|
| 20 |
|
|
-- --
|
| 21 |
|
|
-- GNAT was originally developed by the GNAT team at New York University. --
|
| 22 |
|
|
-- Extensive contributions were provided by Ada Core Technologies Inc. --
|
| 23 |
|
|
-- --
|
| 24 |
|
|
------------------------------------------------------------------------------
|
| 25 |
|
|
|
| 26 |
|
|
-- This package contains the lexical analyzer routines. This is used by the
|
| 27 |
|
|
-- compiler for scanning Ada source files.
|
| 28 |
|
|
|
| 29 |
|
|
with Casing; use Casing;
|
| 30 |
|
|
with Errout; use Errout;
|
| 31 |
|
|
with Scng;
|
| 32 |
|
|
with Style; use Style;
|
| 33 |
|
|
with Types; use Types;
|
| 34 |
|
|
|
| 35 |
|
|
package Scn is
|
| 36 |
|
|
|
| 37 |
|
|
procedure Initialize_Scanner
|
| 38 |
|
|
(Unit : Unit_Number_Type;
|
| 39 |
|
|
Index : Source_File_Index);
|
| 40 |
|
|
-- Initialize lexical scanner for scanning a new file. The caller has
|
| 41 |
|
|
-- completed the construction of the Units.Table entry for the specified
|
| 42 |
|
|
-- Unit and Index references the corresponding source file. A special
|
| 43 |
|
|
-- case is when Unit = No_Unit_Number, and Index corresponds to the
|
| 44 |
|
|
-- source index for reading the configuration pragma file.
|
| 45 |
|
|
|
| 46 |
|
|
function Determine_Token_Casing return Casing_Type;
|
| 47 |
|
|
-- Determines the casing style of the current token, which is
|
| 48 |
|
|
-- either a keyword or an identifier. See also package Casing.
|
| 49 |
|
|
|
| 50 |
|
|
procedure Obsolescent_Check (S : Source_Ptr);
|
| 51 |
|
|
-- Called to handle pragma restrictions check for usage of obsolescent
|
| 52 |
|
|
-- character replacements during the scan.
|
| 53 |
|
|
|
| 54 |
|
|
procedure Set_Obsolescent_Check (Value : Boolean);
|
| 55 |
|
|
-- Activate or not obsolescent check
|
| 56 |
|
|
|
| 57 |
|
|
procedure Post_Scan;
|
| 58 |
|
|
pragma Inline (Post_Scan);
|
| 59 |
|
|
-- Create nodes for tokens: Char_Literal, Identifier, Real_Literal,
|
| 60 |
|
|
-- Integer_Literal, String_Literal and Operator_Symbol.
|
| 61 |
|
|
|
| 62 |
|
|
procedure Scan_Reserved_Identifier (Force_Msg : Boolean);
|
| 63 |
|
|
-- This procedure is called to convert the current token, which the caller
|
| 64 |
|
|
-- has checked is for a reserved word, to an equivalent identifier. This is
|
| 65 |
|
|
-- of course only used in error situations where the parser can detect that
|
| 66 |
|
|
-- a reserved word is being used as an identifier. An appropriate error
|
| 67 |
|
|
-- message, pointing to the token, is also issued if either this is the
|
| 68 |
|
|
-- first occurrence of misuse of this identifier, or if Force_Msg is True.
|
| 69 |
|
|
|
| 70 |
|
|
-------------
|
| 71 |
|
|
-- Scanner --
|
| 72 |
|
|
-------------
|
| 73 |
|
|
|
| 74 |
|
|
-- The scanner used by the compiler is an instantiation of the
|
| 75 |
|
|
-- generic package Scng with routines appropriate to the compiler
|
| 76 |
|
|
|
| 77 |
|
|
package Scanner is new Scng
|
| 78 |
|
|
(Post_Scan => Post_Scan,
|
| 79 |
|
|
Error_Msg => Error_Msg,
|
| 80 |
|
|
Error_Msg_S => Error_Msg_S,
|
| 81 |
|
|
Error_Msg_SC => Error_Msg_SC,
|
| 82 |
|
|
Error_Msg_SP => Error_Msg_SP,
|
| 83 |
|
|
Obsolescent_Check => Obsolescent_Check,
|
| 84 |
|
|
Style => Style.Style_Inst);
|
| 85 |
|
|
|
| 86 |
|
|
procedure Scan renames Scanner.Scan;
|
| 87 |
|
|
-- Scan scans out the next token, and advances the scan state accordingly
|
| 88 |
|
|
-- (see package Scans for details). If the scan encounters an illegal
|
| 89 |
|
|
-- token, then an error message is issued pointing to the bad character,
|
| 90 |
|
|
-- and Scan returns a reasonable substitute token of some kind.
|
| 91 |
|
|
|
| 92 |
|
|
end Scn;
|