[REBOL] Re: Parsing for fun and profit
From: learned::talentsinc::net at: 24-Sep-2001 16:31
Ok, I'll buy that, how about in the final section of the file, where I have
a 1 to n (where N < 100) row table of 5 values each.
123 234 345 46 56469u0
111 234 234 25 8798jh9
I this case, I'd love to end up with a two dimensional array
of [n 5], but I haven't figured out how to swing that one yet.
Seems like it should be easy, but I have my brain wrapped around
--On Monday, September 24, 2001 11:17 PM +0200 Ladislav Mecir
> Hi Gary,
> I think, that the "double parsing" may be convenient in some cases. If you
> really know, that the whitespace characters serve only as "delimiters"
> through the whole text, then there is a possibility to "swap" the order of
> operation and write the parse rules more efficiently like this:
> preparsed: parse data none
> parse preparsed [
> thru "REV:" copy vRev to "Processor"
> thru "Board" copy vBoard to "Rev"
> etc. In the case the whitespace could have a different "meaning"
> somewhere, I would suggest to use a different approach, i.e. to use only
> single parse.
> ----- Original Message -----
> From: G. Edw. Learned <[learned--talentsinc--net]>
> To: <[rebol-list--rebol--com]>
> Sent: Monday, September 24, 2001 8:43 PM
> Subject: [REBOL] Parsing for fun and profit
>> I've been working with the parsing routines for a little utility project
>> I've inherited, and while I'm coming up with some brute force solutions,
>> I'd love to hear any suggestions for streamlineing the code. The data I
>> am inputing has assorted formats embedded within the text files I have to
>> read. I've included an example below:
>> SYS SER #: 123 VER: 4 REV: 7a
>> SER: 3.2
>> Slot 1 Slot 2 Slot 3 Slot 4
>> Board 123 123 123 123
>> Rev 2.3 2.3 2.3 3.4
>> Drive Information:
>> Slot Manuf Type Rev Serial #
>> ---- -------- ---------------- ---- ------------
>> A0 MYXPTL XXX786768XX 1.2 8687163816SA
>> A1 MYXPTL XXX786768XX 1.2 8687163817SA
>> What I have been doing is double parsing to get the information. For
>> example, to get the REV off the first line, the parse is:
>> thru "REV:" copy vREV to "Processor"
>> vREV: parse vREV none
>> the purpose of the second parse being to get rid of whitespace.
>> In the case of the table information, for example, Board, I am doing the
>> thru "Board" copy vBoard to "Rev"
>> vBoard: parce vBoard none
>> the second parse in this case serves to return each 'slot' as a
>> seperatly addressable data block (i.e. vBoard/1).
>> I haven't started parsing the last section yet, which would have
>> 5 pieces of information for each drive found.
>> Are there easier ways to get to where I'm going, or am I on the
>> right track in trying to "think REBOL"?
>> G. Edw. Learned - [learned--talentsinc--net]
>> (Never apply a Star Trek Solution to a Babylon Five Problem)
>> To unsubscribe from this list, please send an email to
>> [rebol-request--rebol--com] with "unsubscribe" in the
>> subject, without the quotes.
> To unsubscribe from this list, please send an email to
> [rebol-request--rebol--com] with "unsubscribe" in the
> subject, without the quotes.
G. Edw. Learned - [learned--talentsinc--net]
(Never apply a Star Trek Solution to a Babylon Five Problem)