2007/5/2, Anton Rolls <[EMAIL PROTECTED]>:

> Hi Ed,
>
> Here's my go at it:
[...]

Looks like a state machine to me.

vowel: charset "aoeuiAOEUI"
y: charset "yY"
consonant: exclude charset [#"b" - #"x" #"z" #"B" - #"X" #"Z"] vowel

start: [consonant after-cons | vowel after-vow | y after-y | end]
after-cons: [consonant after-cons | vowel after-vow | y after-cy | end]
after-vow: [consonant after-cons | vowel after-vow | y after-vy | end]
after-y: [vowel (print "y = consonant") after-vow | consonant (print
"???") after-cons | end (print "???")]
after-cy: [consonant (print "y = vowel") after-cons | vowel (print "y
= semivowel?") after-vow | end (print "y = vowel")]
after-vy: [consonant (print "y = semivowel?") after-cons | vowel
(print "y = consonant") after-vow | end (print "y = vowel")]

Note, since this implementation in recursive, it is not usable to
parse long text. It is easy to make it non-recursive though, although
it may be a bit less readable.

(Another approach for better readability may be to use a FSM
interpreter like mine: http://www.colellachiara.com/soft/MD3/fsm.html
)

HTH,
    Gabriele.
-- 
To unsubscribe from the list, just send an email to 
lists at rebol.com with unsubscribe as the subject.

Reply via email to