Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] parse or Re:(7)

From: rchristiansen:pop:isdfa:sei-it at: 21-Sep-2000 13:11

Joel- Thanks for the parsing routine. There are still a few things about it that I need to look at a few more times for me to understand it perfectly, but I was able to make a re-usable function out of your routine. (I also changed some of the 'words because I like my scripts to read like "plain English.") The function follows... REBOL [] parse-paragraphs: func [ "Parse a document into a block of paragraphs." document [string!] "the document to be parsed" ][ paragraph-block: copy [] current-paragraph: copy "" stopper: charset {.?!:} non-stopper: complement stopper fragment: copy "" sent: [ copy fragment [any non-stopper stopper] (append current-paragraph fragment) [{^/} (append paragraph-block current-paragraph current- paragraph: copy "") |{"^/} (append paragraph-block append current-paragraph {"} current-paragraph: copy "") | none ] ] paragraph: [ (paragraph-block: copy [] current-paragraph: copy "") any sent end (if 0 < length? current-paragraph [append paragraph-block current-paragraph]) ] parse/all document paragraph paragraph-block ]