EiffelRE2 is an Eiffel library that serves as an interface for Google's RE2 regular expression evaluator. The library is void safe.

At the time of posting, RE2 was available only on Unix/Linux. When a Windows implementation becomes available EiffelRE2 will be enhanced to include it.

The library includes two Eiffel classes. Class "RE2" is the general purpose implementation and provides Eiffel features for RE2's main functionality.

"RE2_ATTRIBUTELESS" is an attributeless class that can serve as the ancestor of classes that might need elementary regular expression evaluation in preconditions of creation procedures. For example, suppose a DECIMAL class, representing decimal numbers (one or more digits, followed by a decimal point, followed by zero or more digits), needed a "make_from_string" creation procedure. Class DECIMAL could inherit from RE2_ATTRIBUTELESS, and implement "make_from_string" as

make_from_string (s: STRING)
    require
        s_is_decimal: full_match(s,"\d+\.\d*")

Clients of DECIMAL could either inherit from RE2_ATTRIBUTELESS or declare a local variable of its type for checking string "s" before creating a DECIMAL object based on "s".

Many thanks to Roger Osmond for his excellent advice on designing the wrapper.

 

Last edit: David W. Jenkins 2011-06-17