Package editor

Editor is a language for searching and restructuring text documents.

See:
          Description

Interface Summary
Document Document interface must be implemented by all Editor implementations wishing to share a common clipboard.
 

Class Summary
AbstractDocument This class provides a skeleton implementation of Document interface abstracting from pattern syntax and semantic and using listIterator method to iterate over document's characters, wrapped by java.lang.Character objects
EditorDocument A linked list based implementation of Document interface.
 

Package editor Description

Editor is a language for searching and restructuring text documents. It is based on a simple model of computation, which involves the basic operations of text editors. Each program can access a set of documents, considered simply as strings of symbols over a finite alphabet. Regions, i.e., contiguous substrings in documents can be selected using search and match instructions, and modified using cut, copy, paste, put and replace instructions.

All of these instructions refer to the concept of current selection: in fact, as it is common in text editors, "cut & paste" operations on a document implicitly refer to the currently selected region in the text. Each document doc=a1a2...an of length n there correspond numeric positions from 0 and n; the position just before a1 is position 0; the position just after an is position n. A region is a pair of positions (i,j) with 0<= i <= j <= n; i and j are called the left and right delimiter of the region, respectively. To each region (i, j) we can associate a substring of the document, namely ai+1... aj. Regions of the form (i, i) denote empty substrings.

In each document at any step of the computation there is a selected region. Initially, the selected region of each document is (0,0). It then changes as an effect of executing instructions. Whenever a search instruction is executed on a document and a pattern is specified, the leftmost shortest substring of the document matching the pattern is selected. Then, clipboard operations on that document implicitly refer to the currently selected region. Thus, to cut or copy a specific region from some document, the user has first to select the region using a matching instruction with the appropriate pattern. The current selection also serves as a placeholder; in the course of a computation, we keep track of the portions of documents already examined, and each matching starts from the current position in the document: if the current selection is (i,j), the current position coincides with j, that is, it corresponds to the right delimiter of the selected region. If the matching succeeds, the current selection and the current position are somehow affected. A clipboard is associated with each program; based on the clipboard and document's current selection, restructurings can be performed using cut, copy and paste instructions.

Author:
Valter Crescenzi, Alessandro Masci, Gianni Mecca
See Also:
AbstractDocument, EditorDocument