[REBOL] Re: [REBOL parse] Parsing AEIOU and sometimes Y
From: lmecir:mbox:vol:cz at: 3-May-2007 8:48
OK, Ed, a commented version:
> That's really great Ladislav.
>
> The only thing that saddens me somewhat is that I would probably never
> arrive at a solution like this on my own (the same goes for the other
> solutions offered, of course).
>
> For those new to 'parse, would you be so kind as to step through your
> code and explain it? If you prefer, you can send your comments to me
> directly and I will work with you to produce a short explanation that
> may be appropriate for newbies.
>
> >From here, I'll complete the algorithm, create a tag-cloud indexer and
> see if I can call an old favor from Oldes to generate a Flash
> interface.
>
> Best regards and thanks to all,
> Ed
>
; vowel variants
vowel-after-consonant: charset "aeiouAEIOU"
vowel-otherwise: charset "aeiouyAEIOUY"
; consonant variants
consonant-after-consonant: exclude charset [
#"a" - #"z" #"A" - #"Z"
] vowel-otherwise
consonant-otherwise: union consonant-after-consonant charset "yY"
; adjusting the Vowel and Consonant rules to the Otherwise state
otherwise: first [
(
; vowel detection does not change state
vowel: vowel-otherwise
; consonant detection changes state to After-consonant
consonant: [consonant-otherwise after-consonant]
)
]
; adjusting the Vowel and Consonant rules to the After-consonant state
after-consonant: first [
(
; vowel detection provokes transition to the Otherwise state
vowel: [vowel-after-consonant otherwise]
; consonant detection does not change state
consonant: consonant-after-consonant
)
]
rule: [
; initialization
(
; zeroing the counter
m: 0
)
; setting the state to Otherwise
otherwise
; initialization end
any consonant
any [some vowel some consonant (m: m + 1)]
any vowel
]
-L