Using quasi-parsers to parse spece delimited data

Bill Frantz <[email protected]> Thu, 30 Oct 2014 15:16:45 -0700
Newsgroups gmane.comp.lang.e.general
Message-ID <r422Ps-1075i-9C1949D0A5B448C4911134E6FC186E13@Williams-MacBook-Pro.local>
I recently had to process a bunch of records of the form:

QSO: 14000 PH 2014-10-05 1650 K6EI        254 KING       
KE6JNO       80 UT

to produce another format of the same data. I used a quasi-parser:

   if (l2 =~ `@qso @frequency @mode @date @time @ourcall @ourseq 
@ourqth @call @seq @qth`) {

to break the record into data items.

The problem is that this quasi-parser treats multiple 
consecutive blanks as multiple delimiters. I kluged a solution 
to the problem with:

     var l1 := line
     var l2 := ""
     while (l1 =~ `@word @rest`) {
         l2 := l2 + " " + word
         l1 := rest.trim()
     }
     l2 := l2.trim()
     l2 := l2 + " " + l1.trim();

The question is, is there a better way?

Cheers - - Bill

---------------------------------------------------------------------------
Bill Frantz        | Re: Computer reliability, performance, and security:
408-356-8506       | The guy who *is* wearing a parachute is 
*not* the
www.pwpconsult.com | first to reach the ground.  - Terence Kelly