Can we have this Syntactic sugar.

Long Chang changedalone at gmail.com
Tue Nov 24 03:07:20 PST 2009


enum CompileTimeOption{

    ANCHORED ,
    AUTO_CALLOUT ,
    CASELESS ,
    ENDONLY  ,
    DOTALL  ,
    EXTENDED ,
    EXTRA   ,
    FIRSTLINE ,
    MULTILINE  ,
    NO_AUTO_CAPTURE  ,
    UNGREEDY ,
    UTF8 ,
    NO_UTF8_CHECK  ,
    DUPNAMES  ,
    NEWLINE_CR   ,
    NEWLINE_LF   ,
    NEWLINE_CRLF   ,
    NEWLINE_ANY   ,
}

public class RegExp
{
    enum {
        X, Y, Z
    }
    this(char[] pattern, int options = 0){}
    static RegExp opCall(char[] pattern, int option2){}
}

void main(){
    RegExp reg1    = new RegExp("^A.+", CompileTimeOption.UTF8 |
CompileTimeOption.MULTILINE | CompileTimeOption.DOTALL );
    // Syntactic sugar.
    RegExp reg2    = new RegExp("^A.+",
            CompileTimeOption.( UTF8 | MULTILINE | DOTALL )
        );
    const MyRegExpOption    = CompileTimeOption.( UTF8 | MULTILINE | DOTALL
);
    RegExp reg3    = RegExp( "^A.+",  .(X+Y*Z) );

    int X    = 33;

    RegExp reg4    = RegExp( "^A.+",  .( X+ .X /* the outer X */  ) );

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20091124/4f73ec2e/attachment.html>


More information about the Digitalmars-d mailing list