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

[REBOL] 'Parse is peculiar!

From: shannon:ains:au at: 14-Dec-2000 17:05

Hi REBOL Community, The REBOL philosophy goes "Simple things should be simple". Well I have to say that the 'parse function is an exception! I've had to use it extensively for parsing log files but it has literally taken me months to do simple things - compared to a few weeks for the rest of the core set. Normally I go over the manual entry extensively looking for clues as to what is going wrong, this time i'm really stuck. Look at this: REBOL/View 28-Nov-2000 Copyright 2000 REBOL Technologies. All rights reserved.
>> digits: charset "0123456789"
== make bitset! #{000000000000FF0300000... [snip] ...000}
>> line1: {Lets find "Julie<1234>"} >> parse line1 [thru {"} copy name [thru {<} 4 digits {>} (print name)] to end]
Julie<1234> == true but what if I don't want to include the <xxxx> in 'name?
>> parse line1 [thru {"} copy name [to {<} 4 digits {>} (print name)] to end]
-------------------------------------| Note the 'thru changed to 'to == false That doesn't make sense. Now the second problem:
>> line2: {Lets find "J<o>hn<1234>"} >> parse line2 [thru {"} copy name [thru {<} 4 digits {>} (print name)] to end]
== false So there's the second problem, parse seems to get stuck on '<o>'. I would assume the sub rule should only match a string containing '<xxxx>' and x is a digit. Please don't ask me to use 'find or to change the data structure, or to parse the results twice. I want to understand why 'parse doesn't return the results I expect. Finally the follow line causes the rebol console to hang:
>>parse line2 [thru {"} copy name [some [to {<}]] to end]
and once again I can't get my head around it. Clearly the manual needs more detail on 'parse. SpliFF