[REBOL] Re: [REBOL parse] Parsing AEIOU and sometimes Y
From: edoconnor::gmail::com at: 2-May-2007 11:41
Ok, my head is starting to hurt. Thanks for the suggestions everyone.
First, a small correction from my original email:
>> parse "yay" rule ; y = consonant ; y = consonant
I believe all of the solutions provided successfully handle the
case. I admit that I became a bit dizzy trying to work
To recap, the ultimate goal is to count V C pairs/groups, where V
equals an arbitrary number of vowels, and C equals an arbitrary number
of consonants, i.e.,
simple-VC-rule: [some vowel some consonant (m: m + 1)]
For "banana" m=2, for "elephant" m=3, for "schmaltz" m=1, for "beauty" m=1.
Given the need to count the VC pattern within words, my updated
Y: charset "yY"
vowel: charset "aeiouAEIOU"
consonant: exclude charset [#"a" - #"z" #"A" - #"Z"] union vowel Y
yvow: [consonant Y]
ycon: [vowel Y]
C: [consonant | Y]
VC: [some [yvow | vowel] some [ycon | consonant] (m: m + 1)]
V: [yvow | vowel]
rule: [any C VC any V]
m: 0 parse "toy" rule print m ; m=1
m: 0 parse "crazy" rule print m ; m=1
m: 0 parse "crybaby" rule print m ; m=2
m: 0 parse "yay" rule rule print m ; m=1
I'm not able to trigger (m: m + 1) and record a match for the pattern
VC like I'm able to for 'simple-VC-rule above. It would be very
helpful for me to understand this better, because it serves as a
hidden line of demarcation beyond which 'parse solutions become
dramatically more complex.
Thanks again for your co-exploration. This is purely an exercise and
I'm not looking for anyone to solve this for me. From time to time I
uncover little rabbit holes in my understanding 'parse and other areas
of REBOL. I think it would be really helpful to understand some of
these murky areas, and to refine ways of explaining these concepts to
Thanks for your time.