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

[REBOL] Re: parse again

From: rebol:techscribe at: 29-Dec-2000 0:59

Hi Graham, Parsing is very simple. It takes a minimal effort. And you always know exactly what you are doing. If you are writing parse rules and any of these statements do not make sense, then you have uncovered a conceptual bug. For block parsing you should consult with Chapter 22 (REBOL Dialecting). A simple solution to your problem using block parsing would be: test: [9:00 am Get up 9:30 am Eat breakfast 10:00 am Read email] sp: does [prin " "] rule: [set t time! (prin t sp) set ampm word! (prin ampm sp) some [ set activity word! (prin activity sp) ] (prin newline)]
>> parse test [some rule]
9:00 am Get up 9:30 am Eat breakfast 10:00 am read email  Doing it with a string is not much more difficult: digits: charset "0123456789" test: {9:00 am Get up 9:30 am Eat breakfast 10:00 am read email} rule: [ (print "") begin: 1 2 digits ":" 2 digits end: (prin copy/part begin end) | here: skip (prin here/1) ]
>> parse/all test [some rule]
9:00 am Get up 9:30 am Eat breakfast 10:00 am read email Hope that helps, Elan Graham Chiu wrote: