------------------------------------------------------------------ -------------- ------------------------------------------------------------------------------ -- Cheddar is a GNU GPL real time scheduling analysis tool. -- This program provides services to automatically check performances -- of real time architectures. -- -- Copyright (C) 2002-2015, by Frank Singhoff, Alain Plantec, Jerome Legrand -- -- The Cheddar project was started in 2002 by -- Frank Singhoff, Lab-STICC UMR 6285 laboratory, Université de Bretagne --Occidentale -- -- Since 2008, Ellidiss technologies also contributes to the development of -- Cheddar and provides industrial support. -- -- The full list of contributors and sponsors are given into AUTHORS.txt and --SPONSORS.txt -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- -- -- Contact : cheddar@listes.univ-brest.fr -- ------------------------------------------------------------------------------ -- Last update : -- $Rev: 1249 $ -- $Date: 2014-08-28 07:02:15 +0200 (Fri, 28 Aug 2014) $ -- $Author: singhoff $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with Translate; use Translate; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with unbounded_strings; use unbounded_strings; with GNAT.Command_Line; use GNAT.Command_Line; with GNAT.OS_Lib; use GNAT.OS_Lib; with Ada.IO_Exceptions; use Ada.IO_Exceptions; with GNAT.Current_Exception; use GNAT.Current_Exception; with Parser; use Parser; with scheduler_io; use scheduler_io; with Text_IO; use Text_IO; with Version; use Version; with Framework_Config; use Framework_Config; with Expressions; use Expressions; use Expressions.Variables_Type_Package; with io_tools; use io_tools; with Call_Framework; use Call_Framework; with section_Set; use section_Set; use section_Set.package_Generic_section_Set; with Systems; use Systems; procedure Scc is Sc_File, File_Name : Unbounded_String; procedure Usage is begin Put_Line( "scc is a compiler that checks if a user-defined code file is correct or not.") ; New_Line; Put_Line( "Check Cheddar home page for details : http://beru.univ-brest.fr/~singhoff/cheddar " ); New_Line; New_Line; Put_Line ("Usage : scc [switch] sc-file-to-check"); Put_Line (" switch can be :"); Put_Line (" -x optionnal XML architecture Cheddar file "); Put_Line (" XML Cheddar architecture file is sometimes required"); Put_Line( " (e.g. when SC files contain user-defined task parameters)"); Put_Line (" -u get this help"); Put_Line (" -v verbose mode "); New_Line; end Usage; -- Optionnal XML Cheddar architecture sys : System; Xml_File : Boolean := False; Xml_File_Name : Unbounded_String; Project_File_Dir_List : unbounded_string_list; -- Is the sc command should run in verbose mode ? -- Verbose : Boolean := False; begin Copyright ("scc"); -- Get arguments -- loop case Getopt ("u v x:") is when ASCII.NUL => exit; when 'v' => Verbose := True; when 'u' => Usage; OS_Exit (0); when 'x' => Xml_File := True; Xml_File_Name := To_Unbounded_String (Parameter); when others => Usage; OS_Exit (0); end case; end loop; loop declare S : constant String := Get_Argument (Do_Expansion => True); begin exit when S'Length = 0; File_Name := File_Name & S; end; end loop; if (File_Name = empty_string) then Usage; OS_Exit (0); end if; Call_Framework.initialize (False); -- Parse the file -- if Verbose then Put ("Parsing the file "); Put (To_String (File_Name) & " ...."); end if; New_Line; New_Line; New_Line; New_Line; -- Do we need to read XML architecture file first ? -- if Xml_File then Initialize (sys); Read_From_Xml_File (sys, Project_File_Dir_List, Xml_File_Name); end if; Sc_File := read_sequential_file (File_Name); -- Start parser -- Open_Input (Sc_File); Parser.First_File (File_Name); Create_Parametric_Variables (Parser.Variables_Table, sys.Tasks); Parser.Yyparse; -- Display syntax tree and compiling information -- if Verbose then put (Root_Statement_Pointer); Put (Variables_Table); end if; New_Line; New_Line; New_Line; Put_Line ("Syntax of the file " & To_String (File_Name) & " is ok "); New_Line; exception when Expressions.Syntax_Error => begin New_Line; New_Line; Put_Line (To_String (Lb_Syntax_Error (Current_Language) & Lb_Colon & To_Unbounded_String (Exception_Message))); New_Line; end; when GNAT.Command_Line.Invalid_Switch => begin Put_Line ("scc.adb : invalid Switch " & Full_Switch); Usage; end; when GNAT.Command_Line.Invalid_Parameter => Put_Line ("scc.adb : missing parameter for switch " & Full_Switch); when Ada.IO_Exceptions.Name_Error => Put_Line ("scc.adb : Can not open project files, Name_Error"); when Ada.IO_Exceptions.Status_Error => Put_Line ("scc.adb : Can not open project files, Status_Error"); when Ada.IO_Exceptions.Mode_Error => Put_Line ("scc.adb : Can not open project files, Mode_Error"); when Ada.IO_Exceptions.Use_Error => Put_Line ("scc.adb : Can not open project files, Use_Error"); when Ada.IO_Exceptions.Device_Error => Put_Line ("scc.adb : Can not open project files, Device_Error"); when Ada.IO_Exceptions.End_Error => Put_Line ("scc.adb : Can not open project files, End_Error"); when Ada.IO_Exceptions.Data_Error => Put_Line ("scc.adb : Can not open project files, Data_Error"); when Ada.IO_Exceptions.Layout_Error => Put_Line ("scc.adb : Can not open project files, Layout_Error"); when others => Put_Line ("This is an internal sc bug ... sorry"); Put_Line ("Exception name : " & Exception_Name); Put_Line ("Exception message : " & Exception_Message); Put_Line ("Please, send a bug report to cheddar@listes.univ-brest.fr"); Put_Line ("Do not forget to join the XML/SC Cheddar files with your bug report") ; end Scc;