Login  Register

Re: PetitParser - The Great Flatten Mystery

Posted by Lukas Renggli on Dec 04, 2010; 10:46am
URL: https://forum.world.st/PetitParser-The-Great-Flatten-Mystery-tp3072095p3072282.html

#flatten does not transform your result, but returns a copy of the
consumed range from the input collection. Check the method comment of
#flatten, the class comment of PPFlattenParser, and the tests.

Try with something along:

word := #word asParser plus flatten ==> [ :s | s capitalized ].
space := #space asParser ==> [ :s | nil ].
parser := (word separatedBy: space) ==> [ :s | s reject: [ :each |
each isNil ] ].
start := parser foldLeft: [ :a :b | a , b ]

Lukas

--
Lukas Renggli
www.lukas-renggli.ch
_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev