www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Can we have this Syntactic sugar.

--0016e647195a27b4f504791bf261
Content-Type: text/plain; charset=GB2312
Content-Transfer-Encoding: quoted-printable

enum CompileTimeOption{

    ANCHORED =A3=AC
    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 =3D 0){}
    static RegExp opCall(char[] pattern, int option2){}
}

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

    int X    =3D 33;

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

}

--0016e647195a27b4f504791bf261
Content-Type: text/html; charset=GB2312
Content-Transfer-Encoding: quoted-printable

<br><br>enum CompileTimeOption{<br><br>&nbsp;&nbsp;&nbsp; ANCHORED =A3=AC<b=
r>&nbsp;&nbsp;&nbsp; AUTO_CALLOUT ,<br>&nbsp;&nbsp;&nbsp; CASELESS ,<br>&nb=
sp;&nbsp;&nbsp; ENDONLY&nbsp; ,<br>&nbsp;&nbsp;&nbsp; DOTALL&nbsp; ,<br>&nb=
sp;&nbsp;&nbsp; EXTENDED ,<br>&nbsp;&nbsp;&nbsp; EXTRA&nbsp;&nbsp; ,<br>&nb=
sp;&nbsp;&nbsp; FIRSTLINE ,<br>&nbsp;&nbsp;&nbsp; MULTILINE&nbsp; ,<br>&nbs=
p;&nbsp;&nbsp; NO_AUTO_CAPTURE&nbsp; ,<br>
&nbsp;&nbsp;&nbsp; UNGREEDY ,<br>&nbsp;&nbsp;&nbsp; UTF8 ,<br>&nbsp;&nbsp;&=
nbsp; NO_UTF8_CHECK&nbsp; ,<br>&nbsp;&nbsp;&nbsp; DUPNAMES&nbsp; ,<br>&nbsp=
;&nbsp;&nbsp; NEWLINE_CR&nbsp;&nbsp; ,<br>&nbsp;&nbsp;&nbsp; NEWLINE_LF&nbs=
p;&nbsp; ,<br>&nbsp;&nbsp;&nbsp; NEWLINE_CRLF&nbsp;&nbsp; ,<br>&nbsp;&nbsp;=
&nbsp; NEWLINE_ANY&nbsp;&nbsp; ,<br>}<br><br>public class RegExp<br>{<br>&n=
bsp;&nbsp;&nbsp; enum {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; X, Y, Z<br=

=3D 0){}<br>&nbsp;&nbsp;&nbsp; static RegExp opCall(char[] pattern, int op= tion2){}<br>}<br><br>void main(){<br>&nbsp;&nbsp;&nbsp; RegExp reg1&nbsp;&n= bsp;&nbsp; =3D new RegExp(&quot;^A.+&quot;, CompileTimeOption.UTF8 | Compil= eTimeOption.MULTILINE | CompileTimeOption.DOTALL );<br> &nbsp;&nbsp;&nbsp; // Syntactic sugar.<br>&nbsp;&nbsp;&nbsp; RegExp reg2&nb= sp;&nbsp;&nbsp; =3D new RegExp(&quot;^A.+&quot;, <br>&nbsp;&nbsp;&nbsp; &nb= sp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; CompileTimeOption.( UTF8 | MULTILINE | D= OTALL )<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; );<br>&nbsp;&nbsp;&nbsp; c= onst MyRegExpOption&nbsp;&nbsp;&nbsp; =3D CompileTimeOption.( UTF8 | MULTIL= INE | DOTALL );<br> &nbsp;&nbsp;&nbsp; RegExp reg3&nbsp;&nbsp;&nbsp; =3D RegExp( &quot;^A.+&quo= t;,&nbsp; .(X+Y*Z) );<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; int X&nb= sp;&nbsp;&nbsp; =3D 33;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; RegExp= reg4&nbsp;&nbsp;&nbsp; =3D RegExp( &quot;^A.+&quot;,&nbsp; .( X+ .X /* the= outer X */&nbsp; ) );<br>&nbsp;&nbsp;&nbsp; <br>}<br> --0016e647195a27b4f504791bf261--
Nov 24 2009