home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3001 / jarg2get.icn < prev    next >
Text File  |  1991-03-06  |  2KB  |  61 lines

  1. ############################################################################
  2. #
  3. #    Name:     1.1
  4. #
  5. #    Title:     jargon to gettext format converter
  6. #
  7. #    Author:     Richard L. Goerwitz
  8. #
  9. #    Version: jarg2get.icn
  10. #
  11. ############################################################################
  12. #  
  13. #  Converts jargon.ascii (stdin) to a format suitable for use by gettext.
  14. #  Writes to stdout.  Jargon.ascii was posted recently (c. March 1, 1991)
  15. #  to alt.sources.
  16. #
  17. ############################################################################
  18.  
  19. procedure main()
  20.  
  21.     local line, KEY, key_set, no, yes
  22.  
  23.     blank_count := 0
  24.     key_set := set()
  25.     no := &ucase || "-/"; yes := &lcase || "  "
  26.     # Isn't goal-directed evaluation nice?
  27.     (match("= A =", !&input), "" == !&input)
  28.  
  29.     # Read stdin, looking for entries.  Entries can be distinguished
  30.     # a) by a preceding blank line, and b) by the presence of charac-
  31.     # ters beginning immediately at the margin, and c) by the presence
  32.     # of a colon plus a space on the line.
  33.     while line := trim(read(), '\t \xFF\r') do {
  34.  
  35.     if "" == line then {
  36.         if (blank_count +:= 1) > 2 |
  37.         match("Hacker Folklore", line)
  38.         then exit(0)
  39.         maybe := 1; write()
  40.     }
  41.     else {
  42.         line ? {
  43.         if \maybe &
  44.            KEY :=
  45.                trim(map(tab(any(&letters)) || tab(find(": ")),no,yes))
  46.         then {
  47.             if not member(key_set, KEY)
  48.             then write("::", KEY)
  49.             insert(key_set, KEY)
  50.         }
  51.         write(line)
  52.         }
  53.         maybe := &null
  54.         blank_count := 0
  55.     }
  56.     }
  57.  
  58.     stop("jarg2get:  aborting (are you sure you have the correct file?)")
  59.  
  60. end
  61.