What do you think of this PetitParser example? Is there a better way to do
this?
Parse a string like '{"login", "bash"}' (an Applescript list)
into a
collection of items (i.e. #("login" "bash))...
| delimiter item contents listParser result listClose |
delimiter := ', ' asParser.
listClose := $} asParser.
item := (delimiter / listClose) negate plus flatten.
contents := (item separatedBy: delimiter) ==> [ :nodes | nodes reject: [ :n
| n = ', ' ] ].
listParser := ${ asParser, contents optional, listClose ==> #second.
result := listParser parse: returnString.
^ result isNil
ifTrue: [ OrderedCollection new ]
ifFalse: [ result collect: [ :e | self processAtom: e ] ].
Thanks.
Sean
--
View this message in context:
http://forum.world.st/PetitParser-Example-tp4420008p4420008.html
Sent from the Moose mailing list archive at
Nabble.com.