Sather Home Page

Section 8.17.3.7:
RUNES_CURSOR

class RUNES_CURSOR < $TEXT_CURSOR{RUNE,RUNES}

Inheritance map

$TEXT_CURSOR

Formal Types

types

SAME = RUNES_CURSOR ;
RUNES_CURSOR = token ;

This class models a pointer referring to the successive elements of a list/string. It provides a convenient mechanism to convert rune string representations of other objects into objects of the appropriate classes. If the expected object representation was not found then the cursor error state is set appropriately.


External specifications

The following reader routines inherited from $TEXT_CURSOR{RUNE,RUNES} correspond to the visible components of the internal state of a cursor object.


The following features are required to be implemented for this class in accordance with the specifications given in $TEXT_CURSOR{RUNE,RUNES} from which this class inherits :-


The following four reader routines are required to be implemented in accordance with the specifications given in the class $CURSOR{RUNE,RUNES} from which this class inherits :-


The following features are required to be implemented for this class in accordance with the specifications given in $CURSOR{RUNE,RUNES} from which this class inherits :-


create

This routine creates a new string cursor associated with the string argument, ready to scan from the beginning. There is no error condition and the default skip element is a space rune.

create (
str : RUNES
) : SAME
Formal Signature
create(str : RUNES) res : SAME
Pre-condition

Since the argument is not optional the pre-condition is vacuously true.

Post-condition
post buffer = str
      and index(res) = 0
      and line_no(res) = 0
      and comment_start(res) = RUNES.create(LIBCHARS.Space(RUNES.index_lib(str)))
      and is_done(res) = (index(res) >= len str)
      and not has_ind(res)

This routine creates and initialises a new cursor to have the buffer given as parameter and to be ready to scan from the beginning, having a space rune as skip element.


split

This feature provides a comparable functionality to the split! iter in the class STR. The resultant list of strings omits the 'split' character ch.

split (
ch : RUNE
) : FLIST{RUNES}
Formal Signature
split(self : SAME, ch : RUNE) res : FLIST{RUNES}
Pre-condition

Since neither of the arguments is optional the pre-condition is vacuously true.

Post-condition
post let loc_sub : seq of RUNES be st
         [forall idx1,idx2 | idx1 in set inds loc_sub
            and idx2 in set inds tl loc_sub
            and idx2 = idx1 + 1 &
         loc_sub(idx1) ^ loc_sub(idx2)] = buffer in
            forall idx | idx in set inds tl loc_sub &
               hd loc_sub(idx) = ch
               and forall str_ch | str_ch in set dom tl loc_sub(idx) &
                  str_ch <> ch
               and res(idx) = tl loc_sub(idx)

This routine splits the buffer string into a list of strings separated at each occurrence of ch.


current_loc_str

This feature is provided to enable a program involved in parsing text to display a line of text in a fixed width font underneath which appears this line with the cursor_char indicating the character to which the program needs to refer. It may not be appropriate to use this if the script concerned uses combining encodings for which no fixed width font is available.

current_loc_str (
cursor_char : RUNE
) : RUNES
Formal Signature
current_loc_str(self : SAME, cursor_char : RUNE) res : RUNES
Pre-condition
pre RUNE.is_print(cursor_char)
Post-condition
post let lmark = CODE_STR.tgt_str(LIBCHARS.Line_Mark(RUNES.index_lib(buffer))),
         space_idx = len res - 1,
         loc_idx = index + 1 in
            forall idx | idx in set inds buffer((loc_idx - space_idx), ..., index) &
                  not RUNES.contains(lmark,buffer(idx))
                  and ((index - space_idx) = 0
                     or RUNES.contains(lmark,buffer(index - space_idx - 1)))
                  and ((index = len buffer)
                     or RUNES.contains(lmark,buffer(index)))
            and (res(len res) = cursor_ch)

This routine returns a rune string which is space-filled up to the position of the cursor on the current line to which the given cursor_ch is then appended.


Language Index Library Index Text Index
Comments or enquiries should be made toKeith Hopper.
Page last modified: Monday, 26 March 2001.
Produced with Amaya