Changeset 104

Show
Ignore:
Timestamp:
01/02/08 02:08:14 (11 months ago)
Author:
dan.lewis
Message:

The lexer now seemingly correctly consumes strings and comments.

Files:

Legend:

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

    r102 r104  
    5151            case '"': 
    5252            case '\'': 
    53                 // capture string 
     53                // BUG: *p == *pStart may trigger an always empty string? 
     54                pStart = p; 
     55                p++; 
     56                for(; *p != *pStart; p++) { 
     57                    if(*p == 0x03){ 
     58                        // terminate with an unterminated string error 
     59                        return; 
     60                    } 
     61                    if(*p == '\\'){ 
     62                        printf("ESCAPED"); 
     63                        // handle the escaped character 
     64                    } 
     65                } 
     66                // token = pStart[1..(p-pStart)] 
     67                printf("\n\"%.*s\"",pStart[1..(p-pStart)]); 
     68                continue; 
     69            case '=': 
     70                if(p[1] == '=') { 
     71                    // EMIT: cmp 
     72                    p++; 
     73                    continue; 
     74                } 
     75                // EMIT: mov 
    5476                continue; 
    5577            case '+': 
     
    94116                } 
    95117                if(p[1] == '/') { 
    96                     // consume to the end of line 
    97                     p++; 
     118                    for(; *p != '\n' && *p != '\r' && *p != 0x03; p++) { 
     119                    } 
    98120                    continue; 
    99121                } 
    100122                if(p[1] == '*') { 
    101                     // conume until '*' '/' 
    102                     p++; 
     123                    for(; *p != 0x03 && !(*p == '*' && p[1] == '/'); p++) { 
     124                    } 
    103125                    continue; 
    104126                } 
     
    220242                // a letter 
    221243                pStart = p; 
    222                 while(p < last && ((0x41 <= *p && *p <= 0x5A) || (0x61 <= *p && *p <= 0x7A)))
     244                while(p < last && ((0x41 <= *p && *p <= 0x5A) || (0x61 <= *p && *p <= 0x7A)))
    223245                    p++; 
    224246                } 
    225247                const(char)[] word = pStart[0..(p-pStart)]; 
     248                p--; 
    226249                switch(word) { 
    227250                    /// ECMA 7.5.2 
  • branches/1.9/test/hello.nut

    r85 r104  
    11 
    2 hello 
    3 I am here. 
     2i am// WHAT I AM //I AM 
     3here still. 
     4 
     5what it would be/* LIKE */without comments? 
     6 
     7whats="i eat strings."] 
     8 
     9'stringy!'