[m-dev.] regular expressions

Michael Day mcda at cat.cs.mu.OZ.AU
Fri Dec 17 23:03:24 AEDT 1999


> letter --> 'a' .. 'z' ; 'A' .. 'Z'.
> digit --> '0' .. '9'.
> c_identifier --> letter, repeat0((letter ; digit ; ['_'])).

I must admit, being able to write code in that style would probably make
me drool all over the keyboard. But, I can't help wondering... while
that's a nice example, it is perhaps a little too simplistic, given that
the definition of letter is locale dependent and is based on the ctype
functions rather than a mere character range. That would lead to a rather
ugly switch forest or table of some kind. The repeat0/repeat1 predicates
look nice. I suppose it would be asking too much for them to be defined as
postfix * and + operators, respectively :) One last question, how can a
program convert from canonical regular expression format into this
compiled representation? I mean it's great for constant regexps, but what
about reading one from the user or a file... would higher order code be
any use for that?

Michael


--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list