home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / snobol / vsnobol / smartvow.sno < prev    next >
Text File  |  1991-02-14  |  1KB  |  53 lines

  1. *    SMARTVOW.SNO
  2. *
  3. *    This is a smarter varient of the VOWELS.SNO program.  It will
  4. *    underline MULTIPLE occurrences of the target pattern.  See VOWELS.SNO
  5. *    for an explanation of the basic program.
  6. *
  7. *    Here, the pattern has been changed to two vowels separated by
  8. *    a consonent, as described in VOWELS.SNO.
  9. *
  10.  
  11.     &TRIM    =    1
  12.     &ANCHOR    =    1
  13.  
  14.     VOWEL    =    'AEIOUaeiou'
  15.  
  16. *    Define target pattern
  17. *
  18.     TARGET    =    ANY(VOWEL) NOTANY(VOWEL " ,.-") ANY(VOWEL)
  19.  
  20. *    Search pattern brackets the target with cursor operators.  I and J
  21. *    will be set to the subject positions on either side of the match.
  22. *    ARB is used to match (and later delete) the characters from the
  23. *    beginning of the string up to the TARGET.
  24. *
  25.     SEARCH    =    ARB @I TARGET @J
  26.  
  27. *    Read a line of input, fail upon end-of-file.
  28. *
  29. READ    LINE    =    INPUT                :F(END)
  30.  
  31. *    Save line for later display.  Initialize the underline string.
  32. *
  33.     SAVE    =    LINE
  34.     UNDER    =    ""
  35.  
  36. *    Search the line, removing everything up to and including
  37. *    the TARGET if found.  Fail if not found.
  38. *
  39. AGAIN    LINE    SEARCH    = ""                :F(DISPLAY)
  40.  
  41. *    Build up the underlining string.
  42. *
  43.     UNDER    =    UNDER DUPL(" ",I) DUPL("-",J - I) :(AGAIN)
  44.  
  45. *    When the pattern match fails, see if we've had any matches.
  46. *    The simplest test is to see if the underlining string is non-null.
  47. *    If so, display the saved line and the underlining.
  48. *
  49. DISPLAY    OUTPUT    =    DIFFER(UNDER) SAVE        :F(READ)
  50.     OUTPUT    =    UNDER                :(READ)
  51.  
  52. END
  53.