| lparss |
|
Table of contents
Procedure
LPARSS ( Parse a list of items; return a set. )
SUBROUTINE LPARSS ( LIST, DELIMS, SET )
Abstract
Parse a list of items delimited by multiple delimiters,
placing the resulting items into a set.
Required_Reading
CELLS
SETS
Keywords
CHARACTER
PARSING
SETS
Declarations
IMPLICIT NONE
INTEGER LBCELL
PARAMETER ( LBCELL = -5 )
CHARACTER*(*) LIST
CHARACTER*(*) DELIMS
CHARACTER*(*) SET ( LBCELL:* )
Brief_I/O
VARIABLE I/O DESCRIPTION
-------- --- --------------------------------------------------
LIST I List of items delimited by DELIMS on input.
DELIMS I Single characters which delimit items.
SET O Items in the list, validated, left justified.
Detailed_Input
LIST is a list of items delimited by any one of the characters
in the string DELIMS. Consecutive delimiters, and
delimiters at the beginning and end of the list, are
considered to delimit blank items. A blank list is
considered to contain a single, blank item. Leading and
trailing blanks in list are ignored.
DELIMS contains the individual characters which delimit the
items in the list. These may be any ASCII characters,
including blanks.
However, by definition, consecutive blanks are NOT
considered to be consecutive delimiters. Nor are a blank
and any other delimiter considered to be consecutive
delimiters. In addition, leading and trailing blanks are
ignored.
Detailed_Output
SET is a SPICE set containing the items in the list, left
justified. Any item in the list too long to fit into an
element of SET is truncated on the right.
The strings in SET will be sorted in increasing order,
and duplicates will be removed. Trailing blanks are
ignored in string comparisons.
The size of the set must be initialized prior to calling
LPARSS.
Parameters
None.
Exceptions
1) If the size of the set is not large enough to accommodate all
of the items in the set, an error is signaled by a routine in
the call tree of this routine.
2) If the string length of SET is too short to accommodate an
item, the item will be truncated on the right.
3) If the string length of SET is too short to permit encoding of
integers via the SPICELIB routine ENCHAR, an error is signaled
by a routine in the call tree of this routine.
Files
None.
Particulars
None.
Examples
The following examples illustrate the operation of LPARSS.
1) Let
LIST = 'A number of words separated by
spaces.'
DELIMS = ' ,.'
SIZE (SET) = 20
Then
CARDC (SET) = 8
SET (1) = ' '
SET (2) = 'A'
SET (3) = 'by'
SET (4) = 'number'
SET (5) = 'of'
SET (6) = 'separated'
SET (7) = 'spaces'
SET (8) = 'words'
2) Let
LIST = ' 1986-187// 13:15:12.184 '
DELIMS = ' ,/-:'
SIZE (SET) = 20
Then
CARDC (SET) = 6
SET (1) = ' '
SET (2) = '12.184'
SET (3) = '13'
SET (4) = '15'
SET (5) = '187'
SET (6) = '1986'
3) Let LIST = ' ,This, is, ,an,, example, '
DELIMS = ' ,'
SIZE (SET) = 20
Then
CARDC (SET) = 5
SET (1) = ' '
SET (2) = 'This'
SET (3) = 'an'
SET (4) = 'example'
SET (5) = 'is'
4) Let LIST = 'Mary had a little lamb, little lamb
whose fleece was white as snow.'
DELIMS = ' ,.'
SIZE (SET) = 6
An error would be signaled because the set is not
large enough to accommodate all of the items in the
list.
5) Let LIST = '1 2 3 4 5 6 7 8 9 10.'
DELIMS = ' .'
SIZE (SET) = 10
An error would be signaled because the set is not
large enough to accommodate all of the items in the
list. Note that delimiters at the end (or beginning)
of list are considered to delimit blank items.
6) Let LIST = '1 2 3 4 5 6 7 8 9 10.'
DELIMS = '.'
SIZE (SET) = 10
Then
CARDC (SET) = 2
SET (1) = ' '
SET (2) = '1 2 3 4 5 6 7 8 9 10'
Restrictions
None.
Literature_References
None.
Author_and_Institution
N.J. Bachman (JPL)
J. Diaz del Rio (ODC Space)
H.A. Neilan (JPL)
W.L. Taber (JPL)
I.M. Underwood (JPL)
Version
SPICELIB Version 1.2.0, 24-AUG-2021 (JDR)
Added IMPLICIT NONE statement.
Edited the header to comply with NAIF standard. Improved
documentation of arguments LIST, DELIM and SET.
Updated entries #2 and #3 in $Exceptions section: changed
wrong argument name, and indicated that the routine used
for encoding is part of SPICELIB.
SPICELIB Version 1.1.0, 26-OCT-2005 (NJB)
Bug fix: code was modified to avoid out-of-range
substring bound conditions.
SPICELIB Version 1.0.1, 10-MAR-1992 (WLT)
Comment section for permuted index source lines was added
following the header.
SPICELIB Version 1.0.0, 31-JAN-1990 (HAN) (IMU)
|
Fri Dec 31 18:36:32 2021