Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: [REBOL parse] Parsing AEIOU and sometimes Y

From: santilli:gabriele:gm:ail at: 2-May-2007 12:18

2007/5/2, Anton Rolls <>:
> 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: ) HTH, Gabriele.