Changeset 85

Show
Ignore:
Timestamp:
07/21/07 10:38:03 (1 year ago)
Author:
dan.lewis
Message:

Completed 7.5.3 conformance (yay for keywords), began documenting decided ECMA conformance violations. These may be corrected later.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.9/source/methods.d

    r84 r85  
    4242        return UNDEFINED; 
    4343    char[] 
    44         source = arguments[0].toString(), 
    45         cbuffer = []; 
     44        source = arguments[0].toString(); 
    4645    char* 
    4746        p,  
     47        pStart, 
    4848        last = &source[$]; 
    49     size_t line; 
     49    size_t 
     50        line; 
    5051    /* 
    5152        this algorithm interprets (not compiles) source code provided to it, but 
     
    5455    for(p = &source[0]; ; p++) { 
    5556        switch(*p) { 
     57            case 0x00: 
     58            case 0x01: 
     59            case 0x02: 
    5660            case 0x03: 
    5761            case 0x04: 
     
    6771                    line++; 
    6872                continue; 
     73            // case 0x2028: 
     74            // case 0x2029: 
    6975            case 0x0A: 
    70             case 0x0C: 
    7176                line++; 
    72             case 0x00: 
    73             case 0x01: 
    74             case 0x02: 
    7577            case 0x09: 
    7678            case 0x0B: 
     79            case 0x0C: 
    7780            case 0x0E: 
    7881            case 0x0F: 
    7982            case 0x20: 
    80                 printf("%.*s ",cbuffer); 
    81                 cbuffer = []; 
     83            case 0xA0: 
    8284                continue; 
    8385            case '"': 
     
    251253            { 
    252254                // a letter 
    253                 if( (0x41 <= *p && *p <= 0x5A) 
    254                 || (0x61 <= *p && *p <= 0x7A) 
    255                 ) { 
    256                     cbuffer ~= *p; 
    257                     continue; 
     255                pStart = p; 
     256                while(p < last && ((0x41 <= *p && *p <= 0x5A) || (0x61 <= *p && *p <= 0x7A))){ 
     257                    p++; 
     258                } 
     259                char[] word = pStart[0..(p-pStart)]; 
     260                switch(word) { 
     261                    /// ECMA 7.5.2 
     262                    case TEXT_break:    printf("%.*s ","!"~word); continue; 
     263                    case TEXT_case: printf("%.*s ","!"~word); continue; 
     264                    case TEXT_catch:    printf("%.*s ","!"~word); continue; 
     265                    case TEXT_continue: printf("%.*s ","!"~word); continue; 
     266                    case TEXT_default:  printf("%.*s ","!"~word); continue; 
     267                    case TEXT_delete:   printf("%.*s ","!"~word); continue; 
     268                    case TEXT_do:       printf("%.*s ","!"~word); continue; 
     269                    case TEXT_else:     printf("%.*s ","!"~word); continue; 
     270                    case TEXT_finally:  printf("%.*s ","!"~word); continue; 
     271                    case TEXT_for:      printf("%.*s ","!"~word); continue; 
     272                    case TEXT_function: printf("%.*s ","!"~word); continue; 
     273                    case TEXT_goto:     printf("%.*s ","!"~word); continue; 
     274                    case TEXT_if:       printf("%.*s ","!"~word); continue; 
     275                    case TEXT_instanceof:   printf("%.*s ","!"~word); continue; 
     276                    case TEXT_in:       printf("%.*s ","!"~word); continue; 
     277                    case TEXT_new:      printf("%.*s ","!"~word); continue; 
     278                    case TEXT_return:   printf("%.*s ","!"~word); continue; 
     279                    case TEXT_switch:   printf("%.*s ","!"~word); continue; 
     280                    case TEXT_throw:    printf("%.*s ","!"~word); continue; 
     281                    case TEXT_try:      printf("%.*s ","!"~word); continue; 
     282                    case TEXT_typeof:   printf("%.*s ","!"~word); continue; 
     283                    case TEXT_var:      printf("%.*s ","!"~word); continue; 
     284                    case TEXT_void:     printf("%.*s ","!"~word); continue; 
     285                    case TEXT_while:    printf("%.*s ","!"~word); continue; 
     286                    case TEXT_with:     printf("%.*s ","!"~word); continue; 
     287                    default: 
     288                        // it's not a keyword, so it shall be treated as a key on some object (identifier) 
     289                        printf("%.*s ",word); 
     290                        continue; 
    258291                } 
    259292                 
     293                     
    260294                // a number 
    261295                if(0x30 <= *p && *p <= 0x39) { 
    262                     printf("number!"); 
     296                     
    263297                    continue; 
    264298                } 
     
    590624/** 
    591625    Standards: non-standard 
    592     Arguments:  
    593     Returns:  
     626    Arguments: none 
     627    Returns: Value string containing a source representation of the array. 
    594628    Synopsis: 
    595629*/ 
     
    609643/** 
    610644    Standards: ECMA 15.4.4.4 
    611     Arguments:  
    612     Returns:  
     645    Arguments: arguments[0..n] = arrays or strings to concatenate to this. 
     646    Returns: this after having concatenated the arguments. 
    613647    Synopsis: 
    614648*/ 
     
    626660/** 
    627661    Standards: ECMA 15.4.4.5 
    628     Arguments:  
    629     Returns:  
     662    Arguments: arguments[1] = string separator 
     663    Returns: string of each element of the array, separated by the string separator. 
    630664    Synopsis: 
    631665*/ 
     
    644678/** 
    645679    Standards: ECMA 15.4.4.6 
    646     Arguments:  
    647     Returns:  
     680    Arguments: none 
     681    Returns: the last element of the array after removing it from the array. 
    648682    Synopsis: 
    649683*/ 
     
    658692/** 
    659693    Standards: ECMA 15.4.4.7 
    660     Arguments:  
    661     Returns:  
     694    Arguments: arguments[0..n] = values to append onto the end of the array. 
     695    Returns: The original array, with the arguments appended to it. 
    662696    Synopsis: 
    663697*/ 
     
    669703/** 
    670704    Standards: ECMA 15.4.4.8 
    671     Arguments:  
    672     Returns:  
     705    Arguments: none 
     706    Returns: The original array, but with the elements in reverse. 
    673707    Synopsis: 
    674708*/ 
     
    680714/** 
    681715    Standards: ECMA 15.4.4.9 
    682     Arguments:  
    683     Returns:  
     716    Arguments: none 
     717    Returns: The first element of the array, after removing it from the array. 
    684718    Synopsis: 
    685719*/ 
     
    694728/** 
    695729    Standards: ECMA 15.4.4.10 
    696     Arguments:  
    697     Returns:  
     730    Arguments: arguments[0] = the start index to slice the array from.<br /> 
     731    arguments[1] = one higher than the last index - to slice the array to. 
     732    Returns: A slice of that array. 
    698733    Synopsis: 
    699734*/ 
     
    709744 
    710745/** 
     746    Bugs: Does not currently accept any arguments.  (just sorts by numeric value)  ECMA 262 dictates that this method accept a function argument. 
    711747    Standards: ECMA 15.4.4.11 
    712     Arguments:  
    713     Returns:  
     748    Arguments: none 
     749    Returns: this array, but sorted. 
    714750    Synopsis: 
    715751*/ 
     
    732768/** 
    733769    Standards: ECMA 15.4.4.13 
    734     Arguments:  
    735     Returns:  
     770    Arguments: arguments[0..n] = values to prepend onto the front of the array. 
     771    Returns: The original array, with the arguments prepended to it.  [0] now refers to the first argument prepended. 
    736772    Synopsis: 
    737773*/ 
  • branches/1.9/source/text.d

    r73 r85  
    1515 
    1616static const char[] 
     17 
     18///     Keywords 
     19TEXT_break = "break", 
     20TEXT_case = "case", 
     21TEXT_catch = "catch", 
     22TEXT_continue = "continue", 
     23TEXT_default = "default", 
     24TEXT_delete = "delete", 
     25TEXT_do = "do", 
     26TEXT_else = "else", 
     27TEXT_finally = "finally", 
     28TEXT_for = "for", 
     29TEXT_goto = "goto", 
     30TEXT_if = "if", 
     31TEXT_instanceof = "instanceof", 
     32TEXT_in = "in", 
     33TEXT_new = "new", 
     34TEXT_return = "return", 
     35TEXT_switch = "switch", 
     36TEXT_throw = "throw", 
     37TEXT_try = "try", 
     38TEXT_typeof = "typeof", 
     39TEXT_var = "var", 
     40TEXT_void = "void", 
     41TEXT_while = "while", 
     42TEXT_with = "with", 
    1743 
    1844///     Global