# Section 8.16.1.8:
$TEXT_CURSOR

###### abstract class $TEXT_CURSOR{ELT, STP} < $CURSOR{ELT, STP}

#### Formal Definitions

This abstract class defines a state component which is a set of all instantiations of objects of any class sub-typing from this class in addition to the vdm model types used wherever this class name is used. Note that SAME has to be an instantiated class, not an abstract one.

types
SAME = object_type ;
$TEXT_CURSOR_ELT_STP = set of object_type
state
multi : $TEXT_CURSOR_ELT_STP
inv multi_types ==
forall obj in set multi_types & sub_type($TEXT_CURSOR_ELT_STP,obj)

NOTE | See the important note about vdm state in the notes on vdm-sl usage in this specification.

This abstract class defines the features required by a text cursor in addition to those inherited from $CURSOR, introducing features which permit the extraction and skipping of text components, lines, etc.

reset_line( val : CARD ) ; -- This routine resets the value of the current line in the buffer to -- the given value. Control of this value is not defined by the scanner.
is_line_mark : BOOL ; -- This predicate returns true if and only if the cursor is positioned at -- a line mark. The cursor is not moved.
set_comment_start( char : ELT ) ; -- This routine sets the start of comment token to be the single given -- character value.
set_comment_start( str : STP ) ; -- This routine sets the start of commen token to be the given character -- string.
set_comment_end( char : ELT ) ; -- This routine sets the end of comment token to be the given value.
set_comment_end( str : STP ) ; -- This routine sets the end of comment token to be the given string.
skip_comment : BOOL ; -- This routine returns true if and only if a comment starts at -- the current index position and has been skipped. If the end of comment -- token has not been set or is void then the comment is deemed to extend to -- the current line end.
skip_space ; -- This routine skips space elements - in so doing treating any comments -- as single space elements. Note that those string elements which are -- considered to be a space are otherwise culturally defined.
skip_space : SAME ; -- This routine skips space elements - in so doing treating any comments -- as single space elements. Note that those string elements which are -- considered to be a space are otherwise culturally defined. Self is -- returned.
skip_over_line ; -- This routine skips items in the buffer up to and beyond the next line -- mark in the string.
skip_word ; -- This routine skips characters up to, but not including, the next -- space element.
skip_word : SAME ; -- This routine skips characters up to, but not including, the next -- space element before returning self.
skip_to( str : STP ) ; -- This routine skips up to, but not including, the first element of -- the next copy of str found in the string.
skip_to( str : STP ) : SAME ; -- This routine skips up to, but not including, the first element of -- the next copy of str found in the string before returning self.
skip_over( str : STP ) ; -- This routine advances the cursor to find the string str. It -- positions the cursor to indicate the string element beyond the last -- element of str or at the end of the string if this is found during -- the string scan.
skip_over( str : STP ) : SAME ; -- This routine advances the cursor to find the string str. It -- positions the cursor to indicate the string element beyond the last -- element of str or at the end of the string if this is found during -- the string scan, before returning self.
get_char : ELT ; -- This routine returns the character at the current index position and -- then advances the index by one character. It is a synonym for get_item.
get_line_mark : STP ; -- This routine skips items in the buffer up to the next line_mark which -- is returned.
get_word : STP ; -- This routine skips space up to the next non-space character and then -- retrieves the remaining string up to the end of the string or up to a space -- character whichever is detected first.
get_word( max_size : CARD ) : STP ; -- This routine skips any leading space and then retrieves a word up to -- max_size long or until the end of the string has been reached or a space -- is detected.
get_upto_char( ch : ELT ) : STP ; -- This routine retrieves the string up to the next occurrence of ch -- or until the string is finished.
get_upto( count : CARD ) : STP ; -- This routine returns the string starting at the current element -- until either the given count is reached or the end of the string, -- whichever occurs first.
get_upto( predicate : ROUT{ELT} : BOOL ) : STP ; -- This routine retrieves the string up to the next character for which -- the given predicate returns false or until the string is finished.
get_str : STP ; -- This routine returns the string starting at the current position up to -- and including the next end of line mark.
get_upto_cut( cut_set : STP ) : STP ; -- This routine retrieves the string from the current position upto, but -- not including any character appearing in the cut_set (which is considered -- as a set of characters.
get_over_cut( cut_set : STP ) : STP ; -- This routine retrieves the string from the current position upto and -- including any character appearing in the cut_set (which is considered as -- a set of characters.
current_line : STP ; -- This routine returns the string which is the entire current line in -- the source string.
line!( once escape : ELT, -- may be void! out line_num : CARD ) : SAME ; -- This iter assembles one or more source lines into a logical line, -- omitting comment lines and stripping unwanted line marks at the end -- as necessary. The iter then returns a new string cursor indexed at -- the first non-space element of the line found - or quits!

| Language Index |  | Library Index |  | String Index

Comments or enquiries should be made to Keith Hopper . Page last modified: Monday, 22 May 2000. |