[REBOL] Parsing for fun and profit
From: learned:talentsinc at: 24-Sep-2001 13:43
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
Processor
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
following:
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"?
Thanks
Gary
---
G. Edw. Learned - [learned--talentsinc--net]
(Never apply a Star Trek Solution to a Babylon Five Problem)