home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 December
/
simtel1292_SIMTEL_1292_Walnut_Creek.iso
/
msdos
/
turbopas
/
t_ref.arc
/
T-REFCH1.DOC
< prev
next >
Wrap
Text File
|
1987-01-15
|
13KB
|
331 lines
Chapter I - About T-Ref
T-Ref is actually two programs combined into a single package. First, it
is a Source Lister for Borland's Turbo Pascal programs (versions 2.0 or 3.0).
Of course, T-Ref's sophistication for listing the source files is far beyond
just printing the source code. For example, along with the source listing,
you can specify a line-by-line print-out of the lexical levels and the block
levels, the active procedure or function of that line, and the line numbers
along with the listing. Chapter II of this document describes in detail how
to create a source listing to match your specific needs.
The second part of T-Ref is the Cross Reference List, which was speci-
fically designed to cross reference Borland's Turbo Pascal programs. It will
give a complete cross reference of all identifiers declared within a program
or a partial listing (on requested basic types). The listing gives each
identifier's name, its type, the code line declared on, all lines referencing
the names, and the scope (the procedure or function name and level in which
the identifier was declared within). Chapter III describes fully how to get
and interpret a cross reference listing.
These two parts were designed to work in tandom: a few key strokes will
give you either a source listing, a cross reference listing, or both. Output
can be routed to a specified output file or to the operating system's list
device.
T-Ref is a parsing program, or simply a parser. A parser (the actual
heart of a compiler) performs associations between a program's source code and
the language's grammar. This is to say that T-Ref understands the language
structure (or syntax) of Turbo Pascal. It "scans" the input file for ident-
ifiers (first for their declarations and then for their uses) and stores the
references made to them. However, T-Ref has one limitation in dealing with an
input program: it is not designed to recover gracefully from syntax errors
found in the program and continue "scanning" the source. Therefore, during
the scanning process, if T-Ref comes across a symbol that does not agree
with any of the expected symbols legal for Pascal as defined by Borland's
Turbo Pascal syntax, the parsing process will stop, a cross reference listing
of the program parsed up to the time of the error is printed (if the cross
reference lister is activated), the output file will be closed (if it is not
being routed to the printer), and an error message will be displayed on the
screen describing the error discovered. (Turbo does not recover from errors
encountered either!) It is for this reason that you should always follow
******************************************************************************
T-Ref Rule #1:
Do not use T-Ref on any program that has not been successfully compiled
first by Turbo Pascal.
******************************************************************************
This brings us to what T-Ref WILL parse. T-Ref can successfully parse
any complete Turbo Pascal program or declaration part of a program. The
declaration part of a program may include a sequence of one or more of the
following: label declarations, constant declarations, type declarations,
variable declarations, procedure declarations, and function declarations.
(Like Turbo Pascal, there is no restrictions on order or frequency of each
type of declaration.) Therefore, it is possible to parser a set of library
1
procedures and functions placed in a separate file (accessed from the main
program through the include file compiler directive) without having to parse
any of the possibly many main programs that may use that library.
If you are familiar with Turbo Pascal as well as with Standard Pascal,
you are probably aware that Borland has modified their syntax to provide more
flexibility to Turbo users. The extensions Turbo has placed on Pascal as a
language include, but are not necessarily limited to the following:
String Types and String Expressions
Scalar Type Byte
Embedded Control Characters within Strings
Include File Compiler Directives
Optional Program Heading
Unrestrictive Ordering of Declaration Parts
Special Expression Operators (i.e., SHL)
Inline Statement
Else Clause Expansion to the Case Statement
Retype Facility
Identifier Labels
Typed Constants
Text Files
Untyped Files
I/O Checking
Untyped Formal Variable Parameters
Overlay System
Absolute Variables
External Subprograms
A cross reference program designed to handle Standard Pascal will not success-
fully handle most of these extensions if the parsing technique is implemented.
However, each of these extensions are handled by T-Ref.
The Main Screen:
Almost all interactions you will make with the program will be done
through the main screen which appears when T-Ref begins execution (see Figure
1 below). The main screen is divided into four major areas: the file I/O
fields, the source lister fields, the cross reference lister fields, and the
message area (see Figure 2 below).
A. File I/O Fields:
The File I/O fields are used to specify the common directory and sub-
directories names ("Active Directory"), the name of the file where the program
to be listed resides ("Active Input File"), and the name of the output file
where the resulting listing is to be sent ("Active Output File"). The "Active
Directory" field, when used, refers to the directory common to the input file,
the output file, and all include files referenced within the input file (the
program). The exception to this case is when a file name begins with the "\"
symbol. This is interpreted to mean 'The specified file name includes the
directory and possible subdirectories for the file's location.' For example,
in the following:
Active Directory: \UTILS
Active Input File: WINDOWS.PAS
Active Output File: \PRINTER\WINDOWS.PRT
2
+============================================================================+
| T-Ref - Professional Turbo Cross Referencing Program |
+----------------------------------------------------------------------------+
| Active Directory: |
| Active Input File: |
| Active Output File: |
+====================================+=======================================+
| Source Listing: On | Cross Reference: On |
+------------------------------------+---------------------------------------+
| Reserve Words: Upper | Labels: PrgDf All |
| Identifiers: Lower | Constants: PrgDf All |
| Line Numbers: On | Types: PrgDf All |
| Lexical Levels: On | Variables: PrgDf All |
| Block Levels: On | Procedures: PrgDf All |
| Active Procedures: On | Functions: PrgDf All |
| Header: On | Header: On |
| Page Numbering: On | Page Numbering: On |
| Include Files: Yes | Include Files: Yes |
+====================================+=======================================+
| |
| Begin Parsing? No |
| |
+============================================================================+
| Primary Key Options ==> <F1> <Home> <End> <Esc> _ |
+============================================================================+
Figure 1. Main Screen
+-------------------------------------------------------+
| File I/O |
| Area |
+---------------------------+---------------------------+
| | |
| | |
| Source Lister | Cross Reference |
| Area | Lister Area |
| | |
| | |
| | |
| | |
+---------------------------+---------------------------+
| Message |
| Area |
+-------------------------------------------------------+
Figure 2. Screen Areas
3
the input file would be '\UTILS\WINDOWS.PAS', but the output file is
'\PRINTER\WINDOWS.PRT'. If, given these same fields, an include file compiler
directive found within WINDOWS.PAS was '{$I SET.LIB}', then T-Ref would expect
to find the file under '\UTILS\SET.LIB'. The 'Active Directory' field may
also be headed by a disk drive to be used rather than the default drive.
The input file and output file may also reference subdirectories within
the directory (and subdirectories) specified by the directory field. For
example:
Active Directory: C:\UTILS
Active Input File: SPECPRGS\WINDOWS.PAS
Active Output File: \PRINTER\WINDOWS.PRT
would reference the input file 'C:\UTILS\SPECPRGS\WINDOWS.PAS' and the output
file '\PRINTER\WINDOWS.PRT' (on the default drive). It is important to notice
the difference between this and the following:
Active Directory: C:\UTILS\SPECPRGS
Active Input File: WINDOWS.PAS
Active Output File: \PRINTER\WINDOWS.PRT
is only in the referencing of any include files located within the source
program (input file).
Finally, if a file name extension (file type) is not given in the input
file field or the output file field, '.PAS' and '.PRT' are respectively
assumed. Therefore, the previous example could be shortened to the following:
Active Directory: C:\UTILS\SPECPRGS
Active Input File: WINDOWS
Active Output File: \PRINTER\WINDOWS
To send the output to the printer, just blank the 'Active Output File' field.
Position the block cursor at that field and strike the RETURN key. The field
will be replaced with "---> Printer" to signify the direction of output.
B. Message Area:
The message area is used by the program to return information about the
progress of the parsing. As each line of the input file is parsed, a line
counter is updated to show the progress. If an error is found in the syntax
of the input program, the message describing the error is printed within this
area. The message area is also used to display the Include File being parsed
(if any) and the number of identifiers cross referenced at the completion of
the parsing.
The other two areas, the source lister and cross reference lister, are
covered completely in chapters II and III respectively.
The Pop-Up Help Windows:
There are only two keys to activate the program's help windows: the F1
and the F2 function keys. The F1 key simply provides a synopsis of what
function keys (F1 - F10) are used by the program. The F2 key, on the other
hand, is the help key for the fields displayed on the main screen. Through
the use of 'Context Sensitive' help functions, when the F2 key is struck, the
help window that appears on the screen will provide information specifically
4
related to the field selected by the block cursor. As you will see, this
simplifies the learning process dramatically.
The other pop-up windows are used to create a 2 to 5 line header for the
source listing and the cross reference listing (F3 and F4 respectively), to
set the input column length (F5), to set the number of lines per page (F6),
and to save the existing field settings (F10). More will be covered on these
function keys in Chapter IV.
5