driveType separatedBy: ', ' asParse
(and see the implementation of #separatedBy: if this is not exactly
what you are looking for)
Lukas
On 11 November 2010 23:35, Sean P. DeNigris <sean(a)clipperadams.com> wrote:
I'm flopping around trying to flatten an array. I can't seem to get it...
input := '...
Optical Drive Type: CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-R, DVD-R DL,
DVD-RW, DVD+R, DVD+R DL, DVD+RW
Optical Media Type:...'
lineBreak := #cr asParser / #lf asParser.
driveTypeHeader := 'Optical Drive Type: ' asParser skipUntil.
driveType := (', ' asParser / lineBreak) negate plus flatten.
additionalDriveType := ', ' asParser, driveType ==> [ :nodes | nodes
second
].
driveTypeList := (driveType, additionalDriveType star).
parser := driveTypeHeader, driveTypeList, lineBreak ==> [ :nodes | nodes
second ].
parser parse: input.
Returns: "#('CD-ROM' #('CD-R' 'CD-RW' 'DVD-ROM'
'DVD-R' 'DVD-R DL' 'DVD-RW'
'DVD+R' 'DVD+R DL' 'DVD+RW'))"
Makes sense so far, but if I change the above to:
...
driveTypeList := (driveType, additionalDriveType star) flatten.
...
Returns: "'CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-R, DVD-R DL, DVD-RW, DVD+R,
DVD+R DL, DVD+RW'"
Instead of combining the arrays, it made one big string!?
How do I do this?
Thanks.
Sean
--
View this message in context:
http://forum.world.st/PetitParser-problem-flattening-a-collection-tp3038980…
Sent from the Moose mailing list archive at
Nabble.com.
_______________________________________________
Moose-dev mailing list
Moose-dev(a)iam.unibe.ch
https://www.iam.unibe.ch/mailman/listinfo/moose-dev