------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Cheddar is a GNU GPL real-time scheduling analysis tool. -- This program provides services to automatically check schedulability and -- other performance criteria of real-time architecture models. -- -- Copyright (C) 2002-2023, Frank Singhoff, Alain Plantec, Jerome Legrand, -- Hai Nam Tran, Stephane Rubini -- -- The Cheddar project was started in 2002 by -- Frank Singhoff, Lab-STICC UMR 6285, Université de Bretagne Occidentale -- -- Cheddar has been published in the "Agence de Protection des Programmes/France" in 2008. -- Since 2008, Ellidiss technologies also contributes to the development of -- Cheddar and provides industrial support. -- -- The full list of contributors and sponsors can be found in README.md -- -- 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$ -- $Date$ -- $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/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;