Changeset 122

Show
Ignore:
Timestamp:
01/06/08 07:37:35 (11 months ago)
Author:
dan.lewis
Message:

Almost? interprets Object literals.

Files:

Legend:

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

    r121 r122  
    11 
    22private import 
     3    methods, // for debugging only 
    34    structure, 
    45    text, 
     
    67 
    78private import 
    8     std.string; 
     9    std.string; // for debugging only 
    910 
    1011uint line = 1; 
     
    257258            return; 
    258259        case '{': 
    259             Value[] buffer; 
     260            const_string[] b1; 
     261            Value[] b2; 
     262            uint len = 0; 
    260263            parenCount++; 
    261264            c++; 
    262             parseObjectLiteral(); 
     265            while(1) { 
     266                parseOptionalWS(); 
     267                parseOperand(); 
     268                assert(v.type == TYPE.IDENT || v.type == TYPE.STRING, MESSAGE_unexpected_token); 
     269                b1 ~= v.s; 
     270                len++; 
     271                parseOptionalWS(); 
     272                assert(c[0] == ':', MESSAGE_unexpected_token); 
     273                parseOptionalWS(); 
     274                parseOperand(); 
     275                b2 ~= v; 
     276                parseOptionalWS(); 
     277                if(c[0] != ',') 
     278                    break; 
     279                c++; 
     280            } 
    263281            assert(*c == '}', MESSAGE_unmatched_parenthesis); 
     282            c++; 
     283            v.length = len; 
     284            v.keys = &b1[0]; 
     285            v.values = &b2[0]; 
     286            v.type = TYPE.OBJECT; 
     287            printf("%.*s",Object_prototype_toSource(v,context)); 
    264288            return; 
    265289        default: