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 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505
|
<HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- Created on May, 22 2008 by texi2html 1.64-gnat-1 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de>
Send bugs and suggestions to <texi2html@mathematik.uni-kl.de>
-->
<HEAD>
<TITLE>ASIS-for-GNAT User's Guide: ASIS Interpreter asistant</TITLE>
<META NAME="description" CONTENT="ASIS-for-GNAT User's Guide: ASIS Interpreter asistant">
<META NAME="keywords" CONTENT="ASIS-for-GNAT User's Guide: ASIS Interpreter asistant">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META NAME="Generator" CONTENT="texi2html 1.64-gnat-1">
</HEAD>
<BODY LANG="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<A NAME="SEC38"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_5.html#SEC37"> < </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_6.html#SEC39"> > </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_7.html#SEC44"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug.html#SEC_Top"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_7.html#SEC44"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_15.html#SEC56">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H1> 5. ASIS Interpreter <CODE>asistant</CODE> </H1>
<!--docid::SEC38::-->
<P>
This chapter describes <CODE>asistant</CODE>, an interactive interface to ASIS queries.
<A NAME="IDX136"></A>
</P><P>
<BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="asis_ug_6.html#SEC39">5.1 <CODE>asistant</CODE> Introduction</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="asis_ug_6.html#SEC40">5.2 <CODE>asistant</CODE> commands</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="asis_ug_6.html#SEC41">5.3 <CODE>asistant</CODE> variables</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="asis_ug_6.html#SEC42">5.4 Browsing an ASIS tree</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="asis_ug_6.html#SEC43">5.5 Example</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
</TABLE></BLOCKQUOTE>
<P>
<A NAME="asistant introduction"></A>
<HR SIZE="6">
<A NAME="SEC39"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_6.html#SEC38"> < </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_6.html#SEC40"> > </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_6.html#SEC38"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_6.html#SEC38"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_7.html#SEC44"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_15.html#SEC56">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 5.1 <CODE>asistant</CODE> Introduction </H2>
<!--docid::SEC39::-->
<P>
The <CODE>asistant</CODE> tool allows you
to use ASIS without building your own ASIS applications. It
provides a simple command language that allows you to define variables of ASIS
types and to assign them values by calling ASIS queries.
</P><P>
This tool may be very useful while you are learning ASIS:
it lets you try different ASIS queries and see the results immediately.
It does not crash when there is an error in calling an ASIS query
(such as passing an inappropriate <CODE>Element</CODE>); instead <CODE>asistant</CODE> reports an
error and lets you try again.
</P><P>
You can also use <CODE>asistant</CODE> as a debug and "ASIS visualization" tool in
an ASIS application project. If you have problems
finding out which query should be used in a given situation, or why a given
query does not work correctly with a given piece of Ada code, you may use
<CODE>asistant</CODE> to reconstruct the situation that causes the problems,
and then experiment with ASIS queries.
</P><P>
Though primarily an interactive tool, <CODE>asistant</CODE> also can interpret
sequences of commands written to a file (called a "script file"
<A NAME="IDX137"></A>
below). The <CODE>asistant</CODE> tool can also store in a file the log of an interactive
session that can then be reused as a script file.
</P><P>
The full documentation of <CODE>asistant</CODE> may be found in the
<CITE><CODE>asistant</CODE> Users' Guide</CITE> (file <TT>`asistant.ug'</TT> in the <CODE>asistant</CODE> source directory).
Here is a brief overview of <CODE>asistant</CODE> usage.
</P><P>
The executable for <CODE>asistant</CODE> is created in the <CODE>asistant</CODE>
source directory as a part of the standard procedure of installing
ASIS-for-GNAT as an Ada library (or it is placed in the <TT>`GNATPRO/bin'</TT>
directory when installing ASIS from the binary distribution). Put this
executable somewhere on your path<A NAME="DOCF4" HREF="asis_ug_fot.html#FOOT4">(4)</A>,
and then type
"<CODE>asistant</CODE>" to call <CODE>asistant</CODE> in an interactive mode. As a result,
the program will output brief information about itself and then the
<CODE>asistant</CODE> prompt "<CODE>></CODE>" will appear:
<A NAME="IDX138"></A>
</P><P>
<TABLE><tr><td> </td><td class=smallexample><FONT SIZE=+0><pre>ASIStant - ASIS Tester And iNTerpreter, v1.2
(C) 1997-2002, Free Software Foundation, Inc.
Asis Version: ASIS 2.0.R
>
</FONT></pre></td></tr></table></P><P>
Now you can input <CODE>asistant</CODE> commands (<CODE>asistant</CODE> supports
in its command language the same form of comments as Ada, and names in
<CODE>asistant</CODE> are not case-sensitive):
</P><P>
<TABLE><tr><td> </td><td class=smallexample><FONT SIZE=+0><pre>>Initialize ("") -- the ASIS Initialize query is called with an
-- empty string as a parameter
>set (Cont) -- the non-initialized variable Cont of the ASIS
-- Context type is created
>Associate (Cont, "", "") -- the ASIS Associate query with two empty
-- strings as parameters is called for Cont
>Open (Cont) -- the ASIS Open query is called for Cont
>set (C_U, Compilation_Unit_Body ("Test", Cont)) -- the variable C_U
-- of the ASIS Compilation_Unit type is created and initialized as
-- the result of the call to the ASIS query Compilation_Unit_Body.
-- As a result, C_U will represent a compilation unit named "Test"
-- and contained in the ASIS Context named Cont
>set (Unit, Unit_Declaration (C_U)) -- the variable Unit of the ASIS
-- Element type is created and initialized as the result of calling
-- the ASIS Unit_Declaration query
>print (Unit) -- as a result of this command, some information about
-- the current value of Unit will be printed (a user can set
-- the desired level of detail of this information):
A_PROCEDURE_BODY_DECLARATION at ( 1 : 1 )-( 9 : 9 )
-- suppose now, that we do make an error - we call an ASIS query for
-- an inappropriate element:
>set (Elem, Assignment_Expression (Unit))
-- ASIS will raise an exception, asistant will output the ASIS debug
-- information:
Exception is raised by ASIS query ASSIGNMENT_EXPRESSION.
Status : VALUE_ERROR
Diagnosis :
Inappropriate Element Kind in Asis.Statements.Assignment_Expression
-- it does not change any of the existing variables and it prompts
-- a user again:
> ...
</FONT></pre></td></tr></table></P><P>
<A NAME="asistant commands"></A>
<HR SIZE="6">
<A NAME="SEC40"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_6.html#SEC39"> < </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_6.html#SEC41"> > </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_6.html#SEC41"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_6.html#SEC38"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_7.html#SEC44"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_15.html#SEC56">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 5.2 <CODE>asistant</CODE> commands </H2>
<!--docid::SEC40::-->
<P>
The list of <CODE>asistant</CODE> commands given in this section is incomplete;
its purpose is only to give a general idea of <CODE>asistant</CODE>'s capabilities.
Standard metalanguage is assumed (i.e., "<CODE>[</CODE><EM>construct</EM><CODE>]</CODE>"
denotes an optional instance of "<EM>construct</EM>").
</P><P>
<DL COMPACT>
<DT><CODE>Help [(name)]</CODE>
<DD><A NAME="IDX139"></A>
Outputs the profile of the ASIS query "<CODE>name</CODE>"; when called with no argument,
generates general <CODE>asistant</CODE> help information.
<P>
<DT><CODE>Set (name)</CODE>
<DD><A NAME="IDX140"></A>
Creates a (non-initialized) variable "<CODE>name</CODE>" of the ASIS <CODE>Context</CODE> type.
<P>
<DT><CODE>Set (name, expr)</CODE>
<DD>Evaluates the expression "<CODE>expr</CODE>" (it may be any legal <CODE>asistant</CODE>
expression; a call to some ASIS query is the most common case in practice)
and creates the variable "<CODE>name</CODE>" of the type and with the value of
"<CODE>expr</CODE>".
<P>
<DT><CODE>Print (expr)</CODE>
<DD><A NAME="IDX141"></A>
Evaluates the expression "<CODE>expr</CODE>" and outputs its value (some information may be
omitted depending on the level specified by the <CODE>PrintDetail</CODE> command).
<P>
<DT><CODE>Run (<TT>`filename'</TT>)</CODE>
<DD><A NAME="IDX142"></A>
Launches the script from a file <TT>`filename'</TT>, reading further commands from it.
<A NAME="IDX143"></A>
<P>
<DT><CODE>Pause</CODE>
<DD><A NAME="IDX144"></A>
Pauses the current script and turns <CODE>asistant</CODE> into interactive mode.
<P>
<DT><CODE>Run</CODE>
<DD>Resumes a previously <CODE>Pause</CODE>d script.
<P>
<DT><CODE>Browse</CODE>
<DD><A NAME="IDX145"></A>
Switches <CODE>asistant</CODE> into step-by-step ASIS tree browsing.
<P>
<DT><CODE>Log (<TT>`filename'</TT>)</CODE>
<DD><A NAME="IDX146"></A>
Opens the file <TT>`filename'</TT> for session logging.
<P>
<DT><CODE>Log</CODE>
<DD>Closes the current log file.
<P>
<DT><CODE>PrintDetail</CODE>
<DD><A NAME="IDX147"></A>
Toggles whether the <CODE>Print</CODE> command outputs additional information.
<P>
<DT><CODE>Quit [(exit-status)]</CODE>
<DD><A NAME="IDX148"></A>
Quits <CODE>asistant</CODE>.
</DL>
<P>
<A NAME="asistant variables"></A>
<HR SIZE="6">
<A NAME="SEC41"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_6.html#SEC40"> < </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_6.html#SEC42"> > </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_6.html#SEC42"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_6.html#SEC38"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_7.html#SEC44"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_15.html#SEC56">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 5.3 <CODE>asistant</CODE> variables </H2>
<!--docid::SEC41::-->
<P>
The <CODE>asistant</CODE> tool lets you define variables with Ada-style (simple) names.
Variables can be of
any ASIS type and of conventional <CODE>Integer</CODE>, <CODE>Boolean</CODE> and <CODE>String</CODE> type.
All the variables are created and assigned dynamically by the <CODE>Set</CODE>
command; there are no predefined variables.
</P><P>
There is no type checking in <CODE>asistant</CODE>: each call to a <CODE>Set</CODE>
command may be considered as creating the first argument from scratch and
initializing it by the value provided by the second argument.
</P><P>
<A NAME="Browsing an ASIS tree"></A>
<HR SIZE="6">
<A NAME="SEC42"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_6.html#SEC41"> < </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_6.html#SEC43"> > </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_6.html#SEC43"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_6.html#SEC38"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_7.html#SEC44"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_15.html#SEC56">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 5.4 Browsing an ASIS tree </H2>
<!--docid::SEC42::-->
<P>
You perform ASIS tree browsing by invoking the <CODE>asistant</CODE> service function
<CODE>Browse</CODE>. This will disable the <CODE>asistant</CODE> command interpreter
and activate the Browser command interpreter. The Browser <CODE>Q</CODE> command
switches back into the <CODE>asistant</CODE> environment by enabling the <CODE>asistant</CODE>
command interpreter and disabling the Browser interpreter.
</P><P>
<CODE>Browse</CODE> has a single parameter of <CODE>Element</CODE> type, which establishes
where the ASIS tree browsing will begin.
<CODE>Browse</CODE> returns a
result of type <CODE>Element</CODE>, namely the <CODE>Element</CODE> at which the tree browsing was
stopped. Thus, if you type:
</P><P>
<TABLE><tr><td> </td><td class=smallexample><FONT SIZE=+0><pre>> set (e0, Browse (e1))
</FONT></pre></td></tr></table></P><P>
you will start ASIS tree browsing from <CODE>e1</CODE>; when you finish
browsing, <CODE>e0</CODE> will represent the last <CODE>Element</CODE> visited during the
browsing.
</P><P>
If you type:
</P><P>
<TABLE><tr><td> </td><td class=smallexample><FONT SIZE=+0><pre>> Browse (e1)
</FONT></pre></td></tr></table></P><P>
you will be able to browse the ASIS tree, but the last <CODE>Element</CODE> of the
browsing will be discarded.
</P><P>
Browser displays the ASIS <CODE>Element</CODE> it currently points at and expects one of
the following commands:
</P><P>
<DL COMPACT>
<DT><CODE>U</CODE>
<DD>Go one step up the ASIS tree (equivalent to calling the ASIS
<CODE>Enclosing_Element</CODE> query);
<A NAME="IDX149"></A>
<P>
<DT><CODE>D</CODE>
<DD>Go one step down the ASIS tree, to the left-most component of the current <CODE>Element</CODE>
<P>
<DT><CODE>N</CODE>
<DD>Go to the right sibling (to the next <CODE>Element</CODE> in the ASIS tree hierarchy)
<P>
<DT><CODE>P</CODE>
<DD>Go to the left sibling (to the previous <CODE>Element</CODE> in the ASIS tree hierarchy)
<P>
<DT><CODE>\k1k2</CODE>
<DD>where <CODE>k1</CODE> is either <CODE>D</CODE> or <CODE>d</CODE>, and
<CODE>k2</CODE> is either <CODE>T</CODE> or <CODE>t</CODE>.
Change the form of displaying the current <CODE>Element</CODE>: <CODE>D</CODE> turns ON displaying the
debug image, <CODE>d</CODE> turns it OFF. <CODE>T</CODE> turns ON displaying the text image, <CODE>t</CODE>
turns it OFF.
<P>
<DT><CODE><SPACE><query></CODE>
<DD>Call the <query> for the current <CODE>Element</CODE>.
<P>
<DT><CODE>Q</CODE>
<DD>Go back to the <CODE>asistant</CODE> environment; the Browser command interpreter is
disabled and the <CODE>asistant</CODE> command interpreter is enabled with the
current <CODE>Element</CODE> returned as a result of the call to <CODE>Browse</CODE>.
</DL>
<P>
Browser immediately interprets the keystroke and displays the new current
<CODE>Element</CODE>. If the message <CODE>"Cannot go in this direction."</CODE> appears, this
means that traversal in this direction from current node is impossible (that
is, the current node is either a terminal <CODE>Element</CODE> and it is not possible to go
down, or it is the leftmost or the rightmost component of some <CODE>Element</CODE>, and
it is not possible to go left or right, or it is the top <CODE>Element</CODE> in its
enclosing unit structure and it is not possible to go up).
</P><P>
It is possible to issue some ordinary ASIS queries from inside the Browser
(for example, semantic queries). These queries should accept one parameter of
type <CODE>Element</CODE> and return <CODE>Element</CODE> as a result.
</P><P>
When you press <CODE><SPACE></CODE>, you are asked to enter the query name. If the
query is legal, the current <CODE>Element</CODE> is replaced by the result of the call to
the given query with the current <CODE>Element</CODE> as a parameter.
</P><P>
<A NAME="Example"></A>
<HR SIZE="6">
<A NAME="SEC43"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_6.html#SEC42"> < </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_7.html#SEC44"> > </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_6.html#SEC38"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_6.html#SEC38"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_7.html#SEC44"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_15.html#SEC56">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 5.5 Example </H2>
<!--docid::SEC43::-->
<P>
Suppose we have an ASIS <CODE>Compilation_Unit</CODE> <CODE>Demo</CODE> in the source file <TT>`demo.adb'</TT>:
</P><P>
<TABLE><tr><td> </td><td class=smallexample><FONT SIZE=+0><pre>procedure Demo is
function F (I : Integer) return Integer;
function F (I : Integer) return Integer is
begin
return (I + 1);
end F;
N : Integer;
begin
N := F (3);
end Demo;
</FONT></pre></td></tr></table></P><P>
Suppose also that the tree for this source is created in the current directory.
Below is a sequence of <CODE>asistant</CODE> commands which does process this
unit. Explanation is provided via <CODE>asistant</CODE> comments.
</P><P>
<TABLE><tr><td> </td><td class=smallexample><FONT SIZE=+0><pre>initialize ("")
-- Create and open a Context comprising all the tree files
-- in the current directory:
Set (Cont)
Associate (Cont, "", "")
Open (Cont)
-- Get a Compilation_Unit (body) named "Demo" from this Context:
Set (CU, Compilation_Unit_Body ("Demo", Cont))
-- Go into the unit structure and get to the expression
-- in the right part of the assignment statements in the unit body:
Set (Unit, Unit_Declaration (CU))
Set (Stmts, Body_Statements (Unit, False))
Set (Stmt, Stmts (1))
Set (Expr, Assignment_Expression (Stmt))
-- Output the debug image and the text image of this expression:
Print (Expr)
Print (Element_Image (Expr))
-- This expression is of A_Function_Call kind, so it's possible to ask
-- for the declaration of the called function:
Set (Corr_Called_Fun, Corresponding_Called_Function (Expr))
-- Print the debug and the text image of the declaration of the called
-- function:
Print (Corr_Called_Fun)
Print (Element_Image (Corr_Called_Fun))
-- Close the asistant session:
Quit
</FONT></pre></td></tr></table></P><P>
<A NAME="ASIS Application Templates"></A>
<HR SIZE="6">
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_6.html#SEC38"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_7.html#SEC44"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_15.html#SEC56">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="asis_ug_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<BR>
<FONT SIZE="-1">
This document was generated
by <I>Mail Server</I> on <I>May, 22 2008</I>
using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html/"><I>texi2html</I></A>
</BODY>
</HTML>
|