Previous Home Contents Next

Chapter 20: XAldor

20.1 The XAldor screen

20.2 Message list window

20.3 Message window

20.4 Source text window

20.5 Debugging example using XAldor

20.6 XAldor application defaults

XAldor is a graphical user interface which communicates with the Aldor compiler to provide more detailed debugging information when compiling Aldor programs.

Using XAldor provides several features which can be used to speed up the compile/edit/recompile development cycle:

This chapter describes the contents of the XAldor screen, shows how to use its controls and includes an example session of using XAldor to debug an Aldor program.



20.1 : The XAldor screen

The command XAldorcmd with no arguments brings up the initial XAldor screen, shown in section 20.1. At the top of the screen is a pair of text input fields. The first field allows keyboard input of the name of the file to be compiled. The second field provides a place to enter (and later modify) the command-line options used to compile the file. In the initial XAldor screen the file to be compiled is left blank and the default command-line option -M2 is used. Selecting either field using the mouse activates the field for keyboard input.

Beneath the two text fields is a row of buttons for controlling the behavior of XAldor:

Button Help
- describes the behavior of the buttons provided by XAldor. Its contents are displayed within the Message Window.
Options
- pops up a panel of toggle buttons which can be used to select whether an option is on or off. Items selected are displayed in the Options field when Okay is selected. See section 20.2
Compile
- recompiles the selected file with the given arguments.
Save
- saves the text from the Source Text Window to the file listed in its associated label. See section 20.4.
Quit
- exits from the XAldor session.

The main part of the XAldor screen in section 20.1 is composed of three panels, each of which contains a label, a smaller row of buttons, and a scrollable text window. From top to bottom, these panels are called:

See figure 20.4 for an example of using XAldor which illustrates typical contents of each window. A brief explanation of the contents of each window can be found in the following sections.



20.2 : Message list window

The Message List Window lists each compiler message as it is encountered and enumerates it as follows:

The name of the file being compiled is indicated in the label associated with the Message List Window.

Double clicking on a message item in this list selects that message as the current message, and updates the other windows to reflect the contents of that message. The following buttons appear in the Message List Window:

Msg
- displays the full contents of the current message in the Message Window.
NextMsg
- selects the next message in the list.
PrevMsg
- selects the previous message in the list.
No Notes
- indicates that there are no notes associated with this message.
By using the compiler option -Mnotes (which is implied by the option -M2), other compiler messages which are related to the current message can be examined, as demonstrated in
figure 20.5

If there are notes associated with the current message, the No Notes indicator will be replaced by an active See Notes button. Selecting this button replaces the contents of the Message List Window with the notes relating to the current message. In addition, the See Notes button is replaced by an active See Msgs button, which when selected will restore the contents of the Message List Window to the list of compiler messages.



20.3 : Message window

The Message Window displays compiler messages and information pertaining to the source code selected in the Source Text Window. Each position in the source text is associated with a particular node in the parse tree of the program. The Message Window provides information on the currently selected node in the parse tree using the following buttons:

Show
- displays the current node.
Meanings
- displays the list of possible meanings of the current node.
Use
- displays how the current node is used.
Semantics
- displays any extra semantic information for the current node.
Ugly/Nice
- Ugly displays the internal abstract syntax form of the current node; Nice pretty prints it. The name indicated on the button refers to the print mode option that is not currently shown.
See
section 20.4 for details on selecting code in the Source Text Window and for details on manipulating the current node.



20.4 : Source text window

The Source Text Window displays the source file which contains the current node, which is not necessarily the file being compiled. Highlighted text indicates the position of the current node in the source text. Initially the current node is set to the location of the current message (error, warning, remark, etc.) selected in the Message List Window. The Source Text Window panel buttons can be used to change the position of the current node. Dragging the mouse cursor over a text location repositions the current node to be the node nearest to the re-highlighted position which could be determined from the parse tree. Selecting Home or selecting a message from the Message List Window resets the current node to the location of the current (or newly selected) message. The following buttons appear in the Source Text Window panel.

Up
- highlight the parent of this node as the current node.
Down
- highlight the first child of this node as the current node.
Next
- highlight the next sibling of this node as the current node.
Prev
- highlight the previous sibling of this node as the current node.
Home
- return to the node associated with the current message.




20.5 : Debugging example using XAldor

This section demonstrates an example XAldor session which debugs the Aldor file badsieve.as, a program which generates prime numbers using a prime number sieve. The initial contents of the file badsieve.as are shown in figure 20.3

Figure 20.3: XAldor Debugging Example.

--
-- sieve.as: A prime number sieve to count primes <= n.
--
# include "aldor.as"

sieve(n: SingleInteger): SingleInteger == {
        import from Boolean;
        local n: SingleInteger;

        isprime: PrimitiveArray Boolean := new(n, true);

        np := 0;
        for p in 2..n | isprime p repeat {
                local np: SingleInteger;
                np := np + 1;
                for i in 2*p..n by p repeat isprime i := false;
        }
        np
}

litany(): () == {
        import IntegerNumberSystem from Integer;
        import from Segment SingleInteger;

        for i in 1..6 repeat {
                n  := 10^i;
                print << "There are " << sieve n << " primes <= " << n
        }
}

Upon executing the command XAldorcmd -M2 badsieve.as and selecting the Compile button, the screen shown in figure 20.4 is displayed. Two error messages are listed in the Message List Window, and the contents of the first error message are reflected in the Message Window. The identifier n is highlighted in the Source Text Window indicating that the error has been encountered at this location in the source code.

By selecting the NextMsg button the contents of all screens are updated to reflect information relating to the second error message. In this case, the second error message has related notes, and so the No Notes button has been replaced by the See Notes button, as shown in figure 20.5.

Now it is known from the first error message that there is a single identifier n of type SingleInteger which is being used as both a parameter and a local variable. The second error message shows a variable np which has been declared locally after it has already been assigned a value. So the file badsieve.as can be edited by placing the cursor into the source text window, removing the redeclaration of n at line 8, and removing the declaration of np at line 14. These changes can be saved into the file badsieve.as with the Save button.

After recompiling the file using the Compile button, the compiler again encounters errors, as can be seen in figure 20.6. In this case the first message is caused by an identifier 1, whose meaning (as shown by selecting Meanings) is a value of type Integer which has been imported from the domain Integer.

Using the buttons for the Source Text Window, the neighboring nodes of the current node can be traversed to give additional information about the context in which the identifier 1 is being used. Traversing up the node tree using the Up button highlights additional text. The Use button indicates that the identifier 1 is being used in the context of an iterator. See figure 20.7.

The Home button returns to the node 1, where the current error message was encountered. Traversing the node path again using the Prev button and showing the meaning of this node using the Meanings button indicates that the segment creation operation (..) used by the iteration uses requires arguments of type SingleInteger, as can be seen in figure 20.8. Since it has already been shown that the node 1 is of type Integer, the type conflict which was reported by the error message has been located.

As it happens, all of the error messages which were reported by this compilation depend upon this type conflict being resolved. Additional information about the abstract syntax tree of a program is provided by the Show button in the Ugly mode. The node traversal buttons Up, Down, Next, and Prev can be used to examine the print function call, for example, as shown in detail in figure 20.9.

By editing the file badsieve.as to change the statement import IntegerNumberSystem from Integer; to the statement import from SingleInteger;, the file now compiles cleanly and the message No compiler messages! is returned from the Aldor compiler.

See figure 20.10.



20.6 : XAldor application defaults

An example application defaults file for ALDOR is shown in figure 20.11. Changing this file will modify fonts and colors for XAldor. hXasharpDefaultsFigureExample X Defaults for XALDOR.xaldor.def

Figure 20.11: Exaqmple X Defaults for XAldor.

######################################################################
# XAldor defaults:
#     This can be included in .Xdefaults, or it can be placed alone in
#     in $HOME/lib/app-defaults/XAldor using the environment variable
#     XUSERFILESEARCHPATH=$HOME/lib/app-defaults/%N
######################################################################
XAldor.Geometry:                 680x900
XAldor*Sound:                    True
XAldor*debug*cursor:             left_ptr
XAldor*fontList:                 Rom14.500
XAldor*menuButtons*fontList:     8x13B
XAldor*errorTitle*fontList:      Rom14.500
XAldor*errorButtons*fontList:    8x13B
XAldor*debugTitle*fontList:      Rom14.500
XAldor*debugButtons*fontList:    8x13B
XAldor*viewTitle*fontList:       Rom14.500
XAldor*viewButtons*fontList:     8x13B
XAldor*foreground:               ivory
XAldor*background:               midnight blue
XAldor*menuButtons*foreground:   yellow1
XAldor*menuButtons*background:   navy blue
XAldor*error*background:         medium blue
XAldor*error*foreground:         ivory
XAldor*errorTitle*foreground:    black
XAldor*errorTitle*background:    grey
XAldor*errorButtons*foreground:  yellow1
XAldor*errorButtons*background:  navy blue
XAldor*debug*background:         medium blue
XAldor*debug*foreground:         ivory
XAldor*debugTitle*foreground:    red3
XAldor*debugTitle*background:    grey
XAldor*debugButtons*foreground:  yellow1
XAldor*debugButtons*background:  navy blue
XAldor*view*background:          medium blue
XAldor*view*foreground:          ivory
XAldor*viewTitle*foreground:     black
XAldor*viewTitle*background:     grey
XAldor*viewButtons*foreground:   yellow1
XAldor*viewButtons*background:   navy blue

Previous Home Contents Next