Changeset 128

Show
Ignore:
Timestamp:
11/05/07 07:57:23 (10 months ago)
Author:
Don Clugston
Message:

Add support for $. Fix opIndexAssign.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/blade/SyntaxTree.d

    r123 r128  
    2121*       unary operators & ! 
    2222*       && and || operators 
    23 *       Comparision operators and NCEG floating point operator
     23*       Comparision operators, NCEG floating point operators, is, !i
    2424*       ?: 
    25 *       $ not really supported: a[$-1] should be replaced by a[a.length-1] 
    2625*       cast 
    2726*       new, delete, anonymous classes 
     
    267266    AST!(text ~ "[" ~ AllText!(T) ~ "]") opIndex(T...)(T x){ return null; } 
    268267    AST!("(" ~ text ~ "(" ~ AllText!(T) ~ "))") opCall(T...)(T){ return null; } 
    269     AST!("(" ~ text ~ "[" ~ AllText!(T) ~ "]=" ~ U.text ~ ")") opIndexAssign(U, T...)(U,T){ return null; } 
     268    AST!("((" ~ text ~ "[" ~ AllText!(T) ~ "])=" ~ U.text ~ ")") opIndexAssign(U, T...)(U,T){ return null; } 
    270269 
    271270    // Avoid infinite recursion by templating these functions. 
     
    273272    preOp!("+") opPos(dummy=void)(){ return null; } 
    274273    preOp!("-") opNeg(dummy=void)(){ return null; } 
     274    preOp!("*") opStar(dummy=void)(){ return null; }  // D2.0 only 
    275275    postOp!("[]") opSlice(dummy=void)(){ return null; } 
    276276    postOp!("++") opPostInc(dummy=void)(){ return null; } 
     
    309309    char [] code = "typeof("; 
    310310        for(int i=0; i<expr.length; ++i) { 
    311             if (expr[i]>='A' && expr[i]<='Z') code ~= "(cast(AST!(`" ~ expr[i] ~"`))(null))"; 
     311            if (expr[i]>='A' && expr[i]<='Z' || expr[i]=='$') code ~= "(cast(AST!(`" ~ expr[i] ~"`))(null))"; 
    312312            else code ~= expr[i]; 
    313313        } 
     
    359359    assert(mixin(mixin_getPrecedence("D -= A+B *C"))=="D-=(A+(B*C))"); 
    360360    assert(mixin(mixin_getPrecedence("D -= ++A"))=="D-=(++A)"); 
    361     assert(mixin(mixin_getPrecedence("A[B,C/D]=E+F"))=="A[B,(C/D)]=(E+F)"); 
     361    assert(mixin(mixin_getPrecedence("A[B,$-C/D]=E+F"))=="(A[B,($-(C/D))])=(E+F)"); 
     362    assert(mixin(mixin_getPrecedence("A[B]=E+F"))=="(A[B])=(E+F)"); 
     363    assert(mixin(mixin_getPrecedence("A[$]=E+F"))=="(A[$])=(E+F)"); 
    362364    assert(mixin(mixin_getPrecedence("G-=A[B][C..B^D][D]*E+F"))=="G-=((A[B][C..(B^D)][D]*E)+F)"); 
    363365    assert(mixin(mixin_getPrecedence("E=A[B,C/D]*F"))=="E=(A[B,(C/D)]*F)");