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

Parse, spaces and ()s

 [1/3] from: davidv:angliaed at: 31-Aug-2000 11:27


Newby question... Can anyone tell me what is going on here? The following output is produced by the script below one ( two three ) four ( five ( six seven ) eight ) Why do "two" and "three" appear as one string (same with "six" and "seven") and not split up at the space between them like everything else is - obviously the () have something to do with this - but I can't find an explanation anywhere. Also, what mods would I need to make to force it to split these particular strings at the whitespace? REBOL [] blk: [] brkt-chars: charset ["()"] brkt: [some brkt-chars] word-chars: charset [#"a" - #"z" #"A" - #"Z" #"0" - #"9"] word: [some word-chars] word-def: [word] brkt-def: [brkt] get-word: [copy value word-def (insert tail blk trim value)] get-brkt: [copy value brkt-def (insert tail blk trim value)] rule-block: [get-word | get-brkt | skip] str: "one (two three) four (five (six seven) eight)" parse str [some rule-block] foreach item blk [print item] Thanks in anticipation (I've only been playing with REBOL for about a week so forgive my ignorance if this should really be obvious). David

 [2/3] from: splair:uswest at: 31-Aug-2000 10:12


Actually, the ()'s are not causing the results you're getting. For rule-based parsing, spaces are ignored unless you use the /ALL refinement. To get the results you want try: parse/all str [some rule-block] [davidv--angliaed--co--uk] wrote:

 [3/3] from: davidv::angliaed::co::uk at: 1-Sep-2000 8:24


Cheers, I'll give it a go. ----- Original Message ----- From: <[splair--uswest--net]> To: <[list--rebol--com]> Sent: Thursday, August 31, 2000 6:12 PM Subject: [REBOL] Parse, spaces and ()s Re: Actually, the ()'s are not causing the results you're getting. For rule-based parsing, spaces are ignored unless you use the /ALL refinement. To get the results you want try: parse/all str [some rule-block] [davidv--angliaed--co--uk] wrote: