1-- GHDL driver - main part. 2-- Copyright (C) 2002, 2003, 2004, 2005 Tristan Gingold 3-- 4-- This program is free software: you can redistribute it and/or modify 5-- it under the terms of the GNU General Public License as published by 6-- the Free Software Foundation, either version 2 of the License, or 7-- (at your option) any later version. 8-- 9-- This program is distributed in the hope that it will be useful, 10-- but WITHOUT ANY WARRANTY; without even the implied warranty of 11-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12-- GNU General Public License for more details. 13-- 14-- You should have received a copy of the GNU General Public License 15-- along with this program. If not, see <gnu.org/licenses>. 16with GNAT.OS_Lib; use GNAT.OS_Lib; 17with Options; use Options; 18 19package Ghdlmain is 20 type Command_Type; 21 22 type Command_Acc is access all Command_Type'Class; 23 24 type Command_Type is abstract tagged record 25 Next : Command_Acc; 26 end record; 27 28 -- Return TRUE iff CMD handle action ACTION. 29 function Decode_Command (Cmd : Command_Type; Name : String) return Boolean 30 is abstract; 31 32 -- Initialize the command, before decoding actions. 33 procedure Init (Cmd : in out Command_Type); 34 35 procedure Decode_Option (Cmd : in out Command_Type; 36 Option : String; 37 Arg : String; 38 Res : out Option_State); 39 40 -- Get a one-line help for the command. 41 -- If the first character is '!', the string is not displayed by --help 42 -- (for internal commands). 43 function Get_Short_Help (Cmd : Command_Type) return String 44 is abstract; 45 46 -- Disp detailled help. 47 procedure Disp_Long_Help (Cmd : Command_Type); 48 49 -- Perform the action. 50 procedure Perform_Action (Cmd : in out Command_Type; Args : Argument_List) 51 is abstract; 52 53 -- A command that accepts command and help strings. 54 type Command_Str_Type is abstract new Command_Type with record 55 Cmd_Str : String_Access; 56 Help_Str : String_Access; 57 end record; 58 function Decode_Command (Cmd : Command_Str_Type; Name : String) 59 return Boolean; 60 function Get_Short_Help (Cmd : Command_Str_Type) return String; 61 62 -- A command that display a string. 63 type String_Func is access function return String; 64 type Command_Str_Disp is new Command_Str_Type with record 65 Disp : String_Func; 66 end record; 67 procedure Perform_Action (Cmd : in out Command_Str_Disp; 68 Args : Argument_List); 69 70 -- Register a command. 71 procedure Register_Command (Cmd : Command_Acc); 72 73 -- Disp MSG on the standard output with the command name. 74 procedure Error (Msg : String); 75 procedure Warning (Msg : String); 76 77 -- Return the index of C in STR, or 0 if not found. 78 function Index (Str : String; C : Character) return Natural; 79 80 -- Action failed. 81 Compile_Error : exception; 82 83 -- Exec failed: either the program was not found, or failed. 84 Exec_Error : exception; 85 86 -- Decode options from ARGS for command CMD after initializing CMD. 87 -- Return the index of the first non-option argument. 88 procedure Decode_Command_Options (Cmd : in out Command_Type'Class; 89 Args : Argument_List; 90 First_Arg : out Natural); 91 92 procedure Main; 93 94 -- Additionnal one-line message displayed by the --version command, 95 -- if defined. 96 -- Used to customize. 97 type String_Cst_Acc is access constant String; 98 Version_String : String_Cst_Acc := null; 99 100 -- On windows, convert PATH to a unix path, so that a unix shell will 101 -- convert it correctly to a windows path. 102 -- Return PATH on non-windows platforms. 103 function Convert_Path_To_Unix (Path : String) return String; 104 105 -- Registers all commands in this package. 106 procedure Register_Commands; 107end Ghdlmain; 108