Files
PolyORB/compilers/iac/source_input.ads

88 lines
4.5 KiB
Ada
Raw Permalink Normal View History

* MANIFEST: Add Source_Input package. * compilers/common_files/locations.adb: Add assertion. * compilers/common_files/namet.adb: Fix bug: Hash function was crashing on the empty string. Add a new Hash function for type Name_Id, so we can instantiate Containers.Mapping packages with Key => Name_Id. * compilers/common_files/namet.ads: New Hash function. * compilers/common_files/output.ads: Add assertion. * compilers/iac/backend-be_corba_ada-generator.adb: Don't require comments to avoid spaces at beginning and end (it appears to already work). * compilers/iac/backend-be_corba_ada-idl_to_ada.adb: * compilers/iac/backend-be_corba_ada-idl_to_ada.ads: Pass through Include_Source flag. * compilers/iac/backend-be_corba_ada-nutils.ads: * compilers/iac/backend-be_corba_ada-nutils.adb: (Make_Comment_Header): Include the IDL source code at the top of the Stubs package spec. The IDL is not (yet) interspersed with the Ada. (New_Node): Attach a source location to nodes of the Stubs package. Previously, almost all of the nodes had No_Location. This is to support the interspersal. Misc cleanup. * compilers/iac/backend-be_corba_ada-stubs.adb: Set Current_Loc, so New_Node can know the source location. It's a shame to use a global variable here, but it seems better than changing huge numbers of calls to node-creation routines to pass it as a parameter. Pass Include_Source => True to enable inclusion in the Stubs package spec; all other package specs and bodies default to False. * compilers/iac/iac.adb: Use new Source_Input package, and new interface to Lexer. * compilers/iac/lexer.ads: * compilers/iac/lexer.adb: Use new Source_Input package, which requires changing the interface to Preprocess and Process. Do not repeatedly re-read files. * compilers/iac/mknodes.adb: Use new Source_Input package. Use Open_Source to open the file. * compilers/iac/parser.adb: Use new interface to Lexer. * compilers/iac/source_input.ads: * compilers/iac/source_input.adb: New package to support interspersed source. Also allows for some cleanup in the lexer and elsewhere. Fixes IA01-037. Subversion-branch: /trunk/polyorb Subversion-revision: 179194
2011-09-24 15:02:07 +00:00
------------------------------------------------------------------------------
-- --
-- POLYORB COMPONENTS --
-- --
-- S O U R C E _ I N P U T --
* MANIFEST: Add Source_Input package. * compilers/common_files/locations.adb: Add assertion. * compilers/common_files/namet.adb: Fix bug: Hash function was crashing on the empty string. Add a new Hash function for type Name_Id, so we can instantiate Containers.Mapping packages with Key => Name_Id. * compilers/common_files/namet.ads: New Hash function. * compilers/common_files/output.ads: Add assertion. * compilers/iac/backend-be_corba_ada-generator.adb: Don't require comments to avoid spaces at beginning and end (it appears to already work). * compilers/iac/backend-be_corba_ada-idl_to_ada.adb: * compilers/iac/backend-be_corba_ada-idl_to_ada.ads: Pass through Include_Source flag. * compilers/iac/backend-be_corba_ada-nutils.ads: * compilers/iac/backend-be_corba_ada-nutils.adb: (Make_Comment_Header): Include the IDL source code at the top of the Stubs package spec. The IDL is not (yet) interspersed with the Ada. (New_Node): Attach a source location to nodes of the Stubs package. Previously, almost all of the nodes had No_Location. This is to support the interspersal. Misc cleanup. * compilers/iac/backend-be_corba_ada-stubs.adb: Set Current_Loc, so New_Node can know the source location. It's a shame to use a global variable here, but it seems better than changing huge numbers of calls to node-creation routines to pass it as a parameter. Pass Include_Source => True to enable inclusion in the Stubs package spec; all other package specs and bodies default to False. * compilers/iac/iac.adb: Use new Source_Input package, and new interface to Lexer. * compilers/iac/lexer.ads: * compilers/iac/lexer.adb: Use new Source_Input package, which requires changing the interface to Preprocess and Process. Do not repeatedly re-read files. * compilers/iac/mknodes.adb: Use new Source_Input package. Use Open_Source to open the file. * compilers/iac/parser.adb: Use new interface to Lexer. * compilers/iac/source_input.ads: * compilers/iac/source_input.adb: New package to support interspersed source. Also allows for some cleanup in the lexer and elsewhere. Fixes IA01-037. Subversion-branch: /trunk/polyorb Subversion-revision: 179194
2011-09-24 15:02:07 +00:00
-- --
-- S p e c --
-- --
-- Copyright (C) 2011-2012, Free Software Foundation, Inc. --
* MANIFEST: Add Source_Input package. * compilers/common_files/locations.adb: Add assertion. * compilers/common_files/namet.adb: Fix bug: Hash function was crashing on the empty string. Add a new Hash function for type Name_Id, so we can instantiate Containers.Mapping packages with Key => Name_Id. * compilers/common_files/namet.ads: New Hash function. * compilers/common_files/output.ads: Add assertion. * compilers/iac/backend-be_corba_ada-generator.adb: Don't require comments to avoid spaces at beginning and end (it appears to already work). * compilers/iac/backend-be_corba_ada-idl_to_ada.adb: * compilers/iac/backend-be_corba_ada-idl_to_ada.ads: Pass through Include_Source flag. * compilers/iac/backend-be_corba_ada-nutils.ads: * compilers/iac/backend-be_corba_ada-nutils.adb: (Make_Comment_Header): Include the IDL source code at the top of the Stubs package spec. The IDL is not (yet) interspersed with the Ada. (New_Node): Attach a source location to nodes of the Stubs package. Previously, almost all of the nodes had No_Location. This is to support the interspersal. Misc cleanup. * compilers/iac/backend-be_corba_ada-stubs.adb: Set Current_Loc, so New_Node can know the source location. It's a shame to use a global variable here, but it seems better than changing huge numbers of calls to node-creation routines to pass it as a parameter. Pass Include_Source => True to enable inclusion in the Stubs package spec; all other package specs and bodies default to False. * compilers/iac/iac.adb: Use new Source_Input package, and new interface to Lexer. * compilers/iac/lexer.ads: * compilers/iac/lexer.adb: Use new Source_Input package, which requires changing the interface to Preprocess and Process. Do not repeatedly re-read files. * compilers/iac/mknodes.adb: Use new Source_Input package. Use Open_Source to open the file. * compilers/iac/parser.adb: Use new interface to Lexer. * compilers/iac/source_input.ads: * compilers/iac/source_input.adb: New package to support interspersed source. Also allows for some cleanup in the lexer and elsewhere. Fixes IA01-037. Subversion-branch: /trunk/polyorb Subversion-revision: 179194
2011-09-24 15:02:07 +00:00
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. This software is distributed in the hope that it will be useful, --
* MANIFEST: Add Source_Input package. * compilers/common_files/locations.adb: Add assertion. * compilers/common_files/namet.adb: Fix bug: Hash function was crashing on the empty string. Add a new Hash function for type Name_Id, so we can instantiate Containers.Mapping packages with Key => Name_Id. * compilers/common_files/namet.ads: New Hash function. * compilers/common_files/output.ads: Add assertion. * compilers/iac/backend-be_corba_ada-generator.adb: Don't require comments to avoid spaces at beginning and end (it appears to already work). * compilers/iac/backend-be_corba_ada-idl_to_ada.adb: * compilers/iac/backend-be_corba_ada-idl_to_ada.ads: Pass through Include_Source flag. * compilers/iac/backend-be_corba_ada-nutils.ads: * compilers/iac/backend-be_corba_ada-nutils.adb: (Make_Comment_Header): Include the IDL source code at the top of the Stubs package spec. The IDL is not (yet) interspersed with the Ada. (New_Node): Attach a source location to nodes of the Stubs package. Previously, almost all of the nodes had No_Location. This is to support the interspersal. Misc cleanup. * compilers/iac/backend-be_corba_ada-stubs.adb: Set Current_Loc, so New_Node can know the source location. It's a shame to use a global variable here, but it seems better than changing huge numbers of calls to node-creation routines to pass it as a parameter. Pass Include_Source => True to enable inclusion in the Stubs package spec; all other package specs and bodies default to False. * compilers/iac/iac.adb: Use new Source_Input package, and new interface to Lexer. * compilers/iac/lexer.ads: * compilers/iac/lexer.adb: Use new Source_Input package, which requires changing the interface to Preprocess and Process. Do not repeatedly re-read files. * compilers/iac/mknodes.adb: Use new Source_Input package. Use Open_Source to open the file. * compilers/iac/parser.adb: Use new interface to Lexer. * compilers/iac/source_input.ads: * compilers/iac/source_input.adb: New package to support interspersed source. Also allows for some cleanup in the lexer and elsewhere. Fixes IA01-037. Subversion-branch: /trunk/polyorb Subversion-revision: 179194
2011-09-24 15:02:07 +00:00
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. --
* MANIFEST: Add Source_Input package. * compilers/common_files/locations.adb: Add assertion. * compilers/common_files/namet.adb: Fix bug: Hash function was crashing on the empty string. Add a new Hash function for type Name_Id, so we can instantiate Containers.Mapping packages with Key => Name_Id. * compilers/common_files/namet.ads: New Hash function. * compilers/common_files/output.ads: Add assertion. * compilers/iac/backend-be_corba_ada-generator.adb: Don't require comments to avoid spaces at beginning and end (it appears to already work). * compilers/iac/backend-be_corba_ada-idl_to_ada.adb: * compilers/iac/backend-be_corba_ada-idl_to_ada.ads: Pass through Include_Source flag. * compilers/iac/backend-be_corba_ada-nutils.ads: * compilers/iac/backend-be_corba_ada-nutils.adb: (Make_Comment_Header): Include the IDL source code at the top of the Stubs package spec. The IDL is not (yet) interspersed with the Ada. (New_Node): Attach a source location to nodes of the Stubs package. Previously, almost all of the nodes had No_Location. This is to support the interspersal. Misc cleanup. * compilers/iac/backend-be_corba_ada-stubs.adb: Set Current_Loc, so New_Node can know the source location. It's a shame to use a global variable here, but it seems better than changing huge numbers of calls to node-creation routines to pass it as a parameter. Pass Include_Source => True to enable inclusion in the Stubs package spec; all other package specs and bodies default to False. * compilers/iac/iac.adb: Use new Source_Input package, and new interface to Lexer. * compilers/iac/lexer.ads: * compilers/iac/lexer.adb: Use new Source_Input package, which requires changing the interface to Preprocess and Process. Do not repeatedly re-read files. * compilers/iac/mknodes.adb: Use new Source_Input package. Use Open_Source to open the file. * compilers/iac/parser.adb: Use new interface to Lexer. * compilers/iac/source_input.ads: * compilers/iac/source_input.adb: New package to support interspersed source. Also allows for some cleanup in the lexer and elsewhere. Fixes IA01-037. Subversion-branch: /trunk/polyorb Subversion-revision: 179194
2011-09-24 15:02:07 +00:00
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
* MANIFEST: Add Source_Input package. * compilers/common_files/locations.adb: Add assertion. * compilers/common_files/namet.adb: Fix bug: Hash function was crashing on the empty string. Add a new Hash function for type Name_Id, so we can instantiate Containers.Mapping packages with Key => Name_Id. * compilers/common_files/namet.ads: New Hash function. * compilers/common_files/output.ads: Add assertion. * compilers/iac/backend-be_corba_ada-generator.adb: Don't require comments to avoid spaces at beginning and end (it appears to already work). * compilers/iac/backend-be_corba_ada-idl_to_ada.adb: * compilers/iac/backend-be_corba_ada-idl_to_ada.ads: Pass through Include_Source flag. * compilers/iac/backend-be_corba_ada-nutils.ads: * compilers/iac/backend-be_corba_ada-nutils.adb: (Make_Comment_Header): Include the IDL source code at the top of the Stubs package spec. The IDL is not (yet) interspersed with the Ada. (New_Node): Attach a source location to nodes of the Stubs package. Previously, almost all of the nodes had No_Location. This is to support the interspersal. Misc cleanup. * compilers/iac/backend-be_corba_ada-stubs.adb: Set Current_Loc, so New_Node can know the source location. It's a shame to use a global variable here, but it seems better than changing huge numbers of calls to node-creation routines to pass it as a parameter. Pass Include_Source => True to enable inclusion in the Stubs package spec; all other package specs and bodies default to False. * compilers/iac/iac.adb: Use new Source_Input package, and new interface to Lexer. * compilers/iac/lexer.ads: * compilers/iac/lexer.adb: Use new Source_Input package, which requires changing the interface to Preprocess and Process. Do not repeatedly re-read files. * compilers/iac/mknodes.adb: Use new Source_Input package. Use Open_Source to open the file. * compilers/iac/parser.adb: Use new interface to Lexer. * compilers/iac/source_input.ads: * compilers/iac/source_input.adb: New package to support interspersed source. Also allows for some cleanup in the lexer and elsewhere. Fixes IA01-037. Subversion-branch: /trunk/polyorb Subversion-revision: 179194
2011-09-24 15:02:07 +00:00
-- --
-- PolyORB is maintained by AdaCore --
-- (email: sales@adacore.com) --
-- --
------------------------------------------------------------------------------
-- This package contains routines for reading in the "source" files, including
-- the source file named on the command line, included and imported source
-- files, and the temp files used to store the preprocessor output (even
-- though those temp files are not true "source", strictly speaking).
--
-- When we read a source file, we read the entire contents into a buffer, and
-- it stays in memory for the entire run of IAC. The heap-allocated data
-- structures in this package are never reclaimed.
with Types; use Types;
package Source_Input is
pragma Elaborate_Body (Source_Input);
type Source_Kind is (True_Source, Preprocessed_Source);
type Source_File is limited
record
Name : Name_Id;
Buffer : Text_Buffer_Ptr;
-- Content of the file, followed by EOF
Kind : Source_Kind;
end record;
type Source_File_Ptr is access constant Source_File;
function Open_Source
(Name : Name_Id; Kind : Source_Kind) return Source_File_Ptr;
-- Read the named source file, and return the data in a Source_File.
-- Gives a fatal error if the file is not found.
function Named_File (Name : Name_Id) return Source_File_Ptr;
-- The named file must already have been created by Open_Source; this
-- returns it, and must be a True_Source. (???Currently not used; see
-- below.)
* MANIFEST: Add Source_Input package. * compilers/common_files/locations.adb: Add assertion. * compilers/common_files/namet.adb: Fix bug: Hash function was crashing on the empty string. Add a new Hash function for type Name_Id, so we can instantiate Containers.Mapping packages with Key => Name_Id. * compilers/common_files/namet.ads: New Hash function. * compilers/common_files/output.ads: Add assertion. * compilers/iac/backend-be_corba_ada-generator.adb: Don't require comments to avoid spaces at beginning and end (it appears to already work). * compilers/iac/backend-be_corba_ada-idl_to_ada.adb: * compilers/iac/backend-be_corba_ada-idl_to_ada.ads: Pass through Include_Source flag. * compilers/iac/backend-be_corba_ada-nutils.ads: * compilers/iac/backend-be_corba_ada-nutils.adb: (Make_Comment_Header): Include the IDL source code at the top of the Stubs package spec. The IDL is not (yet) interspersed with the Ada. (New_Node): Attach a source location to nodes of the Stubs package. Previously, almost all of the nodes had No_Location. This is to support the interspersal. Misc cleanup. * compilers/iac/backend-be_corba_ada-stubs.adb: Set Current_Loc, so New_Node can know the source location. It's a shame to use a global variable here, but it seems better than changing huge numbers of calls to node-creation routines to pass it as a parameter. Pass Include_Source => True to enable inclusion in the Stubs package spec; all other package specs and bodies default to False. * compilers/iac/iac.adb: Use new Source_Input package, and new interface to Lexer. * compilers/iac/lexer.ads: * compilers/iac/lexer.adb: Use new Source_Input package, which requires changing the interface to Preprocess and Process. Do not repeatedly re-read files. * compilers/iac/mknodes.adb: Use new Source_Input package. Use Open_Source to open the file. * compilers/iac/parser.adb: Use new interface to Lexer. * compilers/iac/source_input.ads: * compilers/iac/source_input.adb: New package to support interspersed source. Also allows for some cleanup in the lexer and elsewhere. Fixes IA01-037. Subversion-branch: /trunk/polyorb Subversion-revision: 179194
2011-09-24 15:02:07 +00:00
procedure Iterate_Source_Files
(Process : not null access procedure (Source : Source_File));
-- Iterates through all Source_Files, in the order they were created by
-- Open_Source.
procedure Iterate_Lines
(Source : Source_File;
Process : not null access procedure (Line : String));
-- Iterates through the lines of the source file, calling Process on each
-- line. Line terminators (LF, CR, CRLF) are not included in Line.
procedure Copy_To_Standard_Output (Source : Source_File);
-- Copy the file contents to standard output.
-- ???Part of the purpose of this package is to allow us to put the IDL
-- source code in the Ada stubs package spec. The IDL should be commented
-- out, and interspersed with the Ada, according to the source
-- locations. That feature is not yet complete. Currently, we put the
-- source at the top of the package (not interspersed). And we don't bother
-- with #include files. Named_File is intended to support the interspersal;
-- it is currently not used.
end Source_Input;