Changeset 145

Show
Ignore:
Timestamp:
01/22/08 07:07:24 (10 months ago)
Author:
dan.lewis
Message:

Implemented "automatic semicolon insertion" and fix for "3cm" being acceptable to the parser as two separate statements.

Files:

Legend:

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

    r144 r145  
    3535            11.12 page 58 
    3636 
    37     BUG: 7.9.1 
    38     see also (interesting) 7.9.2 on page 22/23 
    39     If a TOKEN NEWLINE } sequence is found, it may be transformed to TOKEN SEMI NEWLINE } if the former is invalid. 
    40      
    4137    BUG: 12.1 
    4238    How do we differentiate a code block { } from an object literal at the beginning of a statement? 
    43      
    44     BUG: 
    45     The start of one expression can be *immediately* after the end of the last. 
    46     Exerpt: NOTE 
    47     For example: "3in" is an error and not the two input elements 3 and in. 
    4839 
    4940    BUG:    11.5, 11.6, 11.7, 11.8, 11.9, 11.10, 11.11, 11.13 page 48 
     
    7465    value; 
    7566 
    76 uint line = 1
     67uint line = 1, lineMark
    7768char last = 0x00; 
    7869const_char* c; 
     
    8475    Value[] buffer; 
    8576    c = &source.toString()[0]; 
    86     const_char* cMark = void; 
    8777    context = cc; 
     78    const_char* cMark; 
    8879     
    8980    debug 
     
    133124    assert(c[0] != ')', TEXT._unmatched_parenthesis); 
    134125    parseExpression(); 
    135      
    136126    /* Empty Statement 12.3 page 63 */ 
    137127    if(c[0] == ';') 
    138128        c++; 
     129    /* Statement Termination, aka Automatic Semicolon insertion 7.9.1, 7.9.2 on page 22/23 */ 
     130    else if(lineMark >= line) 
     131        assert(c[0] == '}' || c[0] == last, TEXT._unexpected_token); 
    139132} 
    140133 
     
    144137    debug printf("!%d : parseExpression()\n",c); 
    145138    Value[] buffer; 
     139    const_char* cMark; 
    146140    bool bFlag = false; 
    147     const_char* cMark; 
    148141     
     142    lineMark = line; 
    149143    parseWhitespace(); 
    150144    cMark = c; 
     
    153147    do { 
    154148        buffer ~= v; 
     149        lineMark = line; 
    155150        parseWhitespace(); 
    156151        cMark = c; 
     
    257252    debug printf("!%d : parseKeyword()\n",c); 
    258253     
     254    Value[] buffer; 
    259255    const_char* cMark; 
    260     Value[] buffer; 
    261256    int i; 
    262257     
     
    568563void parseVars() 
    569564{ 
     565    Value[] buffer; 
    570566    const_char* cMark; 
    571     Value[] buffer; 
    572567    debug printf("!%d : KEYVAR\n",c); 
    573568    while(true) { 
     
    594589    double d; 
    595590    const_char* cMark = c; 
    596      
    597591    switch(c[0]) { 
    598592        case '\'': 
  • branches/1.9/test/hello.nut

    r144 r145  
    1 
    2    susan = [(++bob+ (3)) , {"wh]a\"t" : 3, is:/in/i } , 4 ]; 
    3 
    4     "havana".withoutTab(); 
    5     "havan\a".and()."\havana".eat(); 
    6     "hav\tana".goTo(); 
     1 
     2    3+5 ; 
     3    8-12;  4+1