Changeset 114

Show
Ignore:
Timestamp:
09/14/07 12:29:32 (1 year ago)
Author:
Don Clugston
Message:

Consistent treatment of precedence of multi-dimensional arrays.

Files:

Legend:

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

    r113 r114  
    9090/// Return true if text is a D keyword 
    9191bool isKeyword(char [] text) { 
    92     char [][] keywords = [ 
    93     "abstract", "alias", "align", "asm", "assert", "auto", "body", "bool", 
    94     "break", "byte", "case", "cast", "catch", "cdouble", "cent", "cfloat", 
    95     "char", "class", "const", "continue", "creal", "dchar", "debug", "default", 
    96     "delegate", "delete", "deprecated", "do", "double", "else", "enum", 
    97     "export", "extern", "false", "final", "finally", "float", "for", "foreach", 
    98     "foreach_reverse", "function", "goto", "idouble", "if", "ifloat", "import", 
    99     "in", "inout", "int", "interface", "invariant", "ireal", "is", "lazy",  
    100     "long", "macro", "mixin", "module", "new", "null", "out", "override", 
    101     "package", "pragma", "private", "protected", "public", "real", "ref", 
    102     "return", "scope", "short", "static", "struct", "super", "switch", 
    103     "synchronized", "template", "this", "throw", "__traits", "true", "try", 
    104     "typedef", "typeid", "typeof", "ubyte", "ucent", "uint", "ulong", "union", 
    105     "unittest", "ushort",  "version", "void",  
    106     "volatile", "wchar", "while", "with"]; 
     92    char [][] keywords = [ "abstract", "alias", "align", "asm", "assert",  
     93    "auto", "body", "bool", "break", "byte", "case", "cast", "catch", 
     94    "cdouble", "cent", "cfloat", "char", "class", "const", "continue", 
     95    "creal", "dchar", "debug", "default", "delegate", "delete", "deprecated", 
     96    "do", "double", "else", "enum", "export", "extern", "false", "final", 
     97    "finally", "float", "for", "foreach", "foreach_reverse", "function", 
     98    "goto", "idouble", "if", "ifloat", "import", "in", "inout", "int", 
     99    "interface", "invariant", "ireal", "is", "lazy", "long", "macro", "mixin", 
     100    "module", "new", "null", "out", "override", "package", "pragma", "private", 
     101    "protected", "public", "real", "ref", "return", "scope", "short", "static", 
     102    "struct", "super", "switch", "synchronized", "template", "this", "throw", 
     103    "__traits", "true", "try", "typedef", "typeid", "typeof", "ubyte", "ucent", 
     104    "uint", "ulong", "union", "unittest", "ushort",  "version", "void", 
     105    "volatile", "wchar", "while", "with" ]; 
    107106     
    108107    foreach(char [] s; keywords) { 
     
    252251    preOp!("--") opSubAssign(T:int=int)(int x){ return null; }   
    253252 
    254     AST!("(" ~ text ~ "[" ~ T.text ~ ".." ~ U.text ~"])") opSlice(T, U)(T x, U y){ return null; } 
    255     AST!("(" ~ text ~ "[" ~ AllText!(T) ~ "])") opIndex(T...)(T x){ return null; } 
     253    AST!(text ~ "[" ~ T.text ~ ".." ~ U.text ~"]") opSlice(T, U)(T x, U y){ return null; } 
     254    AST!(text ~ "[" ~ AllText!(T) ~ "]") opIndex(T...)(T x){ return null; } 
    256255    AST!("(" ~ text ~ "(" ~ AllText!(T) ~ "))") opCall(T...)(T){ return null; } 
    257256    AST!("(" ~ text ~ "[" ~ AllText!(T) ~ "]=" ~ U.text ~ ")") opIndexAssign(U, T...)(U,T){ return null; } 
     
    297296assert(mixin(mixin_getPrecedence("D -= ++A"))=="D-=(++A)"); 
    298297assert(mixin(mixin_getPrecedence("A[B,C/D]=E+F"))=="A[B,(C/D)]=(E+F)"); 
    299 assert(mixin(mixin_getPrecedence("E=A[B,C/D]*F"))=="E=((A[B,(C/D)])*F)"); 
     298assert(mixin(mixin_getPrecedence("G-=A[B][C..B^D][D]*E+F"))=="G-=((A[B][C..(B^D)][D]*E)+F)"); 
     299assert(mixin(mixin_getPrecedence("E=A[B,C/D]*F"))=="E=(A[B,(C/D)]*F)"); 
    300300assert(mixin(mixin_getPrecedence("(A+B)  in(C^D)"))=="(A+B)in(C^D)"); 
    301301assert(mixin(mixin_getPrecedence("A"))=="A");