File: asistant-help.adb

package info (click to toggle)
asis 2005-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 6,424 kB
  • ctags: 27
  • sloc: ada: 73,883; makefile: 201
file content (276 lines) | stat: -rw-r--r-- 10,290 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
------------------------------------------------------------------------------
--                                                                          --
--             ASIS Tester And iNTerpreter (ASIStant) COMPONENTS            --
--                                                                          --
--                        A S I S T A N T . H E L P                         --
--                                                                          --
--                                 B o d y                                  --
--                                                                          --
--          Copyright (c) 1997-2000, Free Software Foundation, Inc.         --
--                                                                          --
-- ASIStant is free software; you can redistribute it and/or modify it      --
-- under terms of the  GNU General Public License  as published by the Free --
-- Software Foundation;  either version 2,  or  (at your option)  any later --
-- version. ASIStant is distributed  in the hope  that it will be useful,   --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MER-      --
-- CHANTABILITY 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 distributed with GNAT; see file COPYING. If   --
-- not, write to the Free Software Foundation, 59 Temple Place Suite 330,   --
-- Boston, MA 02111-1307, USA.                                              --
--                                                                          --
-- ASIStant is an evolution of ASIStint tool that was created by            --
-- Vasiliy Fofanov as part of a collaboration between Software Engineering  --
-- Laboratory of the Swiss Federal Institute of Technology in Lausanne,     --
-- Switzerland, and the Scientific Research Computer Center of the Moscow   --
-- University, Russia, supported by the Swiss National Science Foundation   --
-- grant #7SUPJ048247, "Development of ASIS for GNAT with industry quality" --
--                                                                          --
-- ASIStant is distributed as a part of the ASIS implementation for GNAT    --
-- (ASIS-for-GNAT) and is maintained by Ada Core Technologies Inc           --
-- (http ://www.gnat.com).                                                   --
------------------------------------------------------------------------------

with Asis;                       use Asis;
with Asis.Implementation;
with Asis.Extensions.Flat_Kinds; use Asis.Extensions.Flat_Kinds;

with ASIStant.Ambiguous_Mapping; use ASIStant.Ambiguous_Mapping;
with ASIStant.Call;              use ASIStant.Call;
with ASIStant.Common;            use ASIStant.Common;
with ASIStant.S_Parser;          use ASIStant.S_Parser;
with ASIStant.Table;             use ASIStant.Table;
with ASIStant.String_Handling;   use ASIStant.String_Handling;
with ASIStant.Text_IO;           use ASIStant.Text_IO;
with ASIStant.Help.Queries;

with ASIStant.FuncEnum;          use ASIStant.FuncEnum;

package body ASIStant.Help is

   -----------------------
   -- Local subprograms --
   -----------------------

   procedure Display_Query_Help (SW : Switch_Index);
   --  Displays help for a given ASIStant or ASIS query

   procedure Display_Syntax (SW : Switch_Index; SYNT : Func_Syntax);
   --  Displays the text representation of a given syntax structure

   -----------------------
   -- Display_Kind_Help --
   -----------------------

   procedure Display_Kind_Help (K : Flat_Element_Kinds) is
      use ASIStant.Help.Queries;
      Q : constant Query_List := Appropriate_Queries (K);
   begin

      ATIPut_Line (
         "Appropriate ASIS structural queries for " &
         To_Proper (Flat_Element_Kinds'Wide_Image (K)) & ":");

      if Q (1) = Invalid_Index then
         ATIPut_Line ("   None.");
      else
         for I in Q'Range loop
            exit when Q (I) = Invalid_Index;
            ATIPut_Line ("   " & To_Proper (Switch_Index'Wide_Image (Q (I))));
         end loop;
      end if;

   end Display_Kind_Help;

   -----------------------
   -- Display_Query_Help --
   -----------------------

   procedure Display_Query_Help (SW : Switch_Index) is
      T :  Func_Syntax;
      Amb : Amb_Index;
   begin

      ATIPut_Line (To_Proper (Switch_Index'Wide_Image (SW)) & " syntax:");

      for I in Switch_Info'Range loop

         if SW in Switch_Info (I).From .. Switch_Info (I).To then
            T := Switch_Info (I).Synt;
            exit;
         end if;

      end loop;

      begin
         Amb := Amb_Index'Value (Switch_Index'Image (SW));

         for i in 1 .. AI_LENGTH loop
            exit when Amb_Info (Amb, i).New_Index = Invalid_Index;
            Display_Syntax (SW, Amb_Info (Amb, i).Synt);
         end loop;

      exception
         when Constraint_Error => Display_Syntax (SW, T);
      end;

   end Display_Query_Help;

   --------------------
   -- Display_Syntax --
   --------------------

   procedure Display_Syntax (SW : Switch_Index; SYNT : Func_Syntax) is
   begin
      ATIPut ("   ");
      ATIPut (To_Proper (Switch_Index'Wide_Image (SW)));

      if SYNT (1) /= Par_Absent then
         ATIPut (" (");
      end if;

      for i in Parameter_Range loop
         exit when SYNT (i) = Par_Absent;
         if i /= 1 then
            ATIPut (", ");
         end if;

         ATIPut (Skip_Prefix (Func_Param'Wide_Image (SYNT (i))));
      end loop;

      if SYNT (1) /= Par_Absent then
         ATIPut (")");
      end if;

      if SYNT (0) /= Par_Absent then
         ATIPut (" return ");
         ATIPut (Skip_Prefix (Func_Param'Wide_Image (SYNT (0))));
      end if;

      ATINew_Line;
   end Display_Syntax;

   --------------
   -- ASISHelp --
   --------------

   procedure ASISHelp is
   begin
      Print_ASIStant_Header;
      ATINew_Line;
      ATIPut_Line ("ASIS and ASIStant Technical and Copyright Information :");
      ATINew_Line;
      ATIPut ("  Asis Version :              ");
      ATIPut_Line (Asis.Implementation.ASIS_Version);
      ATIPut ("  Asis Implementor Version :  ");
      ATIPut_Line (Asis.Implementation.ASIS_Implementor_Version);
      ATIPut ("  Asis Implementor :          ");
      ATIPut_Line (Asis.Implementation.ASIS_Implementor);
      ATIPut ("  Asis Implementor Info :     ");
      ATIPut_Line (Asis.Implementation.ASIS_Implementor_Information);
      ATINew_Line;
      ATIPut_Line ("  ASIStant author Info :      "
                 & "Vasiliy Fofanov, ASIS-for-GNAT team at ACT Inc.");
      ATIPut_Line (
         "                              Email : fofanov@act-europe.fr");
      ATIPut_Line ("  ASIStant status :");

      if Log then
         ATIPut_Line ("          Log enabled. Output Level : "
                      & Integer'Wide_Image (OutputLevel));
      else
         ATIPut_Line ("          Log disabled.");
      end if;

      if Script > 0 then
         ATIPut_Line ("          Script enabled (level " &
                      Integer'Wide_Image (Script) & ") and is in " &
                      Script_Mode'Wide_Image (ScriptMode) & " mode.");
      else
         ATIPut_Line ("          Script disabled.");
      end if;
   end ASISHelp;

   ----------
   -- Help --
   ----------

   procedure Help (NP : Node_Position) is

      N :  Node := CurStat.Tree (NP);

   begin

      if N.NValue = 0 then --  general help

         Print_ASIStant_Header;
         ATINew_Line;
         ATIPut_Line ("List of ASIStant utilities :");
         ATINew_Line;
         ATIPut_Line ("  HELP (<topic-name>)    "
                      & " Displays help for a specific <topic-name>");
         ATIPut_Line ("  IF (<bool-expr>,<expr1>[,<expr2>]) Executes <expr1> "
                      & "if <bool-expr> is true,");
         ATIPut_Line ("                                     otherwise, "
                      & "executes <expr2> if present");
         ATIPut_Line ("  INFO                    Displays ASIS and ASIStant "
                      & "technical info");
         ATIPut_Line ("  LOG [(""<filename>"")]    Opens file as a current "
                      & "log/closes current log");
         ATIPut_Line ("  LOGLEVEL (<level>)      Sets a logging level to "
                      & "integer <level>, 0..5");
         ATIPut_Line ("  PAUSE                   Pauses current script");
         ATIPut_Line ("  PRINT (<variable>)      Prints a value "
                      & "of a variable");
         ATIPut_Line ("  PRINTDETAIL (""{D|d}{T|t}"") Changes PRINT settings");
         ATIPut_Line ("  QUIT [(<exit-status>)]  Exits program returning "
                      & "<exit-status> or 0");
         ATIPut_Line ("  RUN [(""<filename>"")]    Launches script "
                      & "<filename>/resumes paused script");
         ATIPut_Line ("                          (IRUN = interactively)");
         ATIPut_Line ("  SET ( <ID>, <expr> )    Declares or changes "
                      & "variable <ID>");
         ATINew_Line;

         ATIPut_Line ("Please refer to ASIStant User's Guide for more "
                      & "information.");

      else --  specific help

         N := CurStat.Tree (N.NValue); --  receive parameter list
         N := CurStat.Tree (N.NValue); --  receive first element

         --  Determine type of requested help

         --  Is query help requested?
         declare
            sw : Switch_Index;
         begin
            sw := Switch_Index'Wide_Value (N.SValue.all);
            Display_Query_Help (sw);
            return;
         exception
            when others =>
               null; -- trap exception if query unknown
         end;

         --  Is Flat_Element_Kind help requested?
         declare
            K : Flat_Element_Kinds;
         begin
            K := Flat_Element_Kinds'Wide_Value (N.SValue.all);
            Display_Kind_Help (K);
            return;
         exception
            when others =>
               null; -- trap exception if Flat_Element_Kind unknown
         end;

         --  If we are here, the topic wasn't recognized
         Error (ERR_UNKNOWNQUERY, N.SValue.all);

      end if;

   end Help;

end ASIStant.Help;