home *** CD-ROM | disk | FTP | other *** search
- Date: Fri 8 Mar 85 07:20:26-MST
- From: Rick Conn <RCONN@SIMTEL20.ARPA>
- Subject: Re: A Validated Ada Compiler for the IBM PC/XT!
- To: Stachour@HI-MULTICS.ARPA
-
- Paul,
-
- Your point is well-taken. For very large projects, especially
- when a good CM system or library management system is not available
- to keep the libraries in sync, offloading may not be feasible. However,
- I continue to feel that there are many situations in which offloading
- (at least during unit coding and testing) is quite feasible.
-
- I am just now completing involvement in a spelling checker
- program, which is a small- to medium-sized effort. The design was
- oriented around two major objects: the DOCUMENT to be checked and
- the DICTIONARY (there can be more than one) to check against. There
- are two packages which deal with these objects, DOCUMENT_HANDLER and
- DICTIONARY_MANAGER, and each package was assigned to one person to
- code and unit test. The specifications, which, of course, were subject
- to change, were planned during the design phase, and the development
- (including coding and unit testing) of the bodies was done in complete
- independence. Such development could easily have been offloaded to
- a PC if an Ada compiler existed for one. The only requirement for this
- would be that the MACHINE_DEPENDENCIES packages be duplicated on each
- PC. Each package was in complete control of its object; the
- DOCUMENT_HANDLER was given the name of a file containing a
- document and provided words and context information to its user.
- The user was never concerned with details of document structure or
- manipulation. To illustrate, MICRO:<ADA.EDUCATION> contains the
- spec to DOCUMENT_HANDLER as the file DH.ADA.
-
- Integration of these and other independently-written packages
- is now taking place with a high degree of success. I feel that this
- object-oriented mindset is key to this success, and Ada is instrumental
- in supporting it.
-
- Rick
- -------
- ---- DH.ADA ----
-
-
- --
- -- DOCUMENT_HANDLER by Richard Conn, TI Ada Technology Branch
- -- 27 Feb 85
- --
- with TEXT_IO,
- MACHINE_DEPENDENCIES,
- TOKEN_DEFINITION;
- package DOCUMENT_HANDLER is
- --------------------------------------------------------------------------
- -- Abstract : DOCUMENT_HANDLER provides input from a document, which
- -- is specified to OPEN_SOURCE by a pathname/filename.
- -- It returns a WORD from this document each time the routine
- -- GET_WORD is called. When there are no more WORDs in the
- -- document, the exception NO_MORE_WORDS is raised.
- --
- -- DOCUMENT_HANDLER can also create a second document, the
- -- destination, or output, document. This facility is
- -- enabled when the routine OPEN_DESTINATION is called,
- -- where the pathname/filename of the new document is the
- -- passed parameter. The destination document is a mirror
- -- of the source document, except that selected words can
- -- be replaced with other words via the RESTORE_WORD routine.
- -- RESTORE_WORD replaces the last word returned by GET_WORD
- -- with a new word.
- --
- -- The context, or lines surrounding the last word returned
- -- by GET_WORD, can be obtained from the CONTEXT_OF_LAST_
- -- GET_WORD routine. This routine returns LINES, which is
- -- an array of strings, and an INDEX, which is the offset
- -- to the first character of the last word returned by
- -- GET_WORD, and LENGTH, which is the number of characters
- -- in this word. The constant, TARGET_LINE_IN_CONTEXT,
- -- is the index of the line of the context which contains
- -- the indicated word.
- --
- --------------------------------------------------------------------------
-
- subtype TOKEN is TOKEN_DEFINITION.TOKEN_TYPE;
-
- MAX_LINE : constant POSITIVE :=
- MACHINE_DEPENDENCIES.FILE_LINE_LENGTH;
- NUMBER_OF_LINES_IN_CONTEXT : constant NATURAL := 3;
- TARGET_LINE_IN_CONTEXT : constant NATURAL := 2;
- type CONTEXT_ELEMENT is
- record
- LINE : STRING (1 .. MAX_LINE);
- LAST : NATURAL;
- end record;
- type CONTEXT is array (1 .. NUMBER_OF_LINES_IN_CONTEXT) of CONTEXT_ELEMENT;
-
- -- Note: Exceptions from TEXT_IO may also be raised
- RESTORE_FAILED : exception;
- NO_MORE_WORDS : exception;
- SOURCE_NOT_OPEN : exception;
-
- procedure OPEN_SOURCE (FILE_NAME : STRING);
- --------------------------------------------------------------------------
- -- Abstract : The source document from which future words are to be
- -- returned is opened for input. GET_WORD returns these
- -- words.
- --------------------------------------------------------------------------
- -- Parameters : FILE_NAME - Pathname/Filename of file containing
- -- document
- --------------------------------------------------------------------------
-
-
- procedure OPEN_DESTINATION (FILE_NAME : STRING);
- --------------------------------------------------------------------------
- -- Abstract : The destination document which is built of words from the
- -- source document and new, correctly-spelled words provided
- -- through RESTORE_WORD
- --------------------------------------------------------------------------
- -- Parameters : FILE_NAME - Pathname/Filename of file to contain
- -- the destination document
- --------------------------------------------------------------------------
-
-
- procedure CLOSE_SOURCE_AND_DESTINATION;
- --------------------------------------------------------------------------
- -- Abstract : Close both the source document and destination document
- -- files
- --------------------------------------------------------------------------
- -- Parameters : None
- --------------------------------------------------------------------------
-
-
- procedure GET_WORD (WORD : out TOKEN; WORD_IN_BOUNDS : out BOOLEAN);
- --------------------------------------------------------------------------
- -- Abstract : Return the next word from the Source Document
- --------------------------------------------------------------------------
- -- Parameters : WORD - the next word from the source document;
- -- this structure includes the word itself
- -- (as a string) and the word length
- -- WORD_IN_BOUNDS - TRUE if WORD is small enough to fit in
- -- a TOKEN; FALSE if WORD is larger than
- -- the maximum size of a TOKEN; if FALSE,
- -- the full word can be obtained from
- -- the procedure CONTEXT
- --------------------------------------------------------------------------
-
-
- procedure RESTORE_WORD (WORD : STRING);
- --------------------------------------------------------------------------
- -- Abstract : Replace the last word obtained from GET_WORD with the
- -- passed string (WORD); the replacement is done in the
- -- destination document only (the source document is not
- -- affected)
- --------------------------------------------------------------------------
- -- Parameters : WORD - the string containing the new word
- --------------------------------------------------------------------------
-
-
- procedure CONTEXT_OF_LAST_GET_WORD (LINES : out CONTEXT;
- INDEX : out NATURAL;
- LENGTH : out NATURAL);
- --------------------------------------------------------------------------
- -- Abstract : Return the lines surrounding and including the last word
- -- returned by GET_WORD; also return the INDEX and LENGTH
- -- of the last word returned by GET_WORD which indicate
- -- its position in the TARGET_LINE_IN_CONTEXT
- --------------------------------------------------------------------------
- -- Parameters : LINES - the context (lines) surrounding the last
- -- word
- -- INDEX - the offset to the first character of the
- -- last word in TARGET_LINE_IN_CONTEXT
- -- LENGTH - number of characters in the last word
- -- in TARGET_LINE_IN_CONTEXT
- --------------------------------------------------------------------------
-
- end DOCUMENT_HANDLER;
-