Changeset 85
- Timestamp:
- 07/21/07 10:38:03 (1 year ago)
- Files:
-
- branches/1.9/documentation/ECMA Violations.txt (added)
- branches/1.9/source/methods.d (modified) (14 diffs)
- branches/1.9/source/text.d (modified) (1 diff)
- branches/1.9/test/goodbye.nut (added)
- branches/1.9/test/hello.nut (added)
- branches/1.9/walnut.exe (modified) (previous)
- branches/1.9/walnut.lib (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.9/source/methods.d
r84 r85 42 42 return UNDEFINED; 43 43 char[] 44 source = arguments[0].toString(), 45 cbuffer = []; 44 source = arguments[0].toString(); 46 45 char* 47 46 p, 47 pStart, 48 48 last = &source[$]; 49 size_t line; 49 size_t 50 line; 50 51 /* 51 52 this algorithm interprets (not compiles) source code provided to it, but … … 54 55 for(p = &source[0]; ; p++) { 55 56 switch(*p) { 57 case 0x00: 58 case 0x01: 59 case 0x02: 56 60 case 0x03: 57 61 case 0x04: … … 67 71 line++; 68 72 continue; 73 // case 0x2028: 74 // case 0x2029: 69 75 case 0x0A: 70 case 0x0C:71 76 line++; 72 case 0x00:73 case 0x01:74 case 0x02:75 77 case 0x09: 76 78 case 0x0B: 79 case 0x0C: 77 80 case 0x0E: 78 81 case 0x0F: 79 82 case 0x20: 80 printf("%.*s ",cbuffer); 81 cbuffer = []; 83 case 0xA0: 82 84 continue; 83 85 case '"': … … 251 253 { 252 254 // 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; 258 291 } 259 292 293 260 294 // a number 261 295 if(0x30 <= *p && *p <= 0x39) { 262 printf("number!");296 263 297 continue; 264 298 } … … 590 624 /** 591 625 Standards: non-standard 592 Arguments: 593 Returns: 626 Arguments: none 627 Returns: Value string containing a source representation of the array. 594 628 Synopsis: 595 629 */ … … 609 643 /** 610 644 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. 613 647 Synopsis: 614 648 */ … … 626 660 /** 627 661 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. 630 664 Synopsis: 631 665 */ … … 644 678 /** 645 679 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. 648 682 Synopsis: 649 683 */ … … 658 692 /** 659 693 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. 662 696 Synopsis: 663 697 */ … … 669 703 /** 670 704 Standards: ECMA 15.4.4.8 671 Arguments: 672 Returns: 705 Arguments: none 706 Returns: The original array, but with the elements in reverse. 673 707 Synopsis: 674 708 */ … … 680 714 /** 681 715 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. 684 718 Synopsis: 685 719 */ … … 694 728 /** 695 729 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. 698 733 Synopsis: 699 734 */ … … 709 744 710 745 /** 746 Bugs: Does not currently accept any arguments. (just sorts by numeric value) ECMA 262 dictates that this method accept a function argument. 711 747 Standards: ECMA 15.4.4.11 712 Arguments: 713 Returns: 748 Arguments: none 749 Returns: this array, but sorted. 714 750 Synopsis: 715 751 */ … … 732 768 /** 733 769 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. 736 772 Synopsis: 737 773 */ branches/1.9/source/text.d
r73 r85 15 15 16 16 static const char[] 17 18 /// Keywords 19 TEXT_break = "break", 20 TEXT_case = "case", 21 TEXT_catch = "catch", 22 TEXT_continue = "continue", 23 TEXT_default = "default", 24 TEXT_delete = "delete", 25 TEXT_do = "do", 26 TEXT_else = "else", 27 TEXT_finally = "finally", 28 TEXT_for = "for", 29 TEXT_goto = "goto", 30 TEXT_if = "if", 31 TEXT_instanceof = "instanceof", 32 TEXT_in = "in", 33 TEXT_new = "new", 34 TEXT_return = "return", 35 TEXT_switch = "switch", 36 TEXT_throw = "throw", 37 TEXT_try = "try", 38 TEXT_typeof = "typeof", 39 TEXT_var = "var", 40 TEXT_void = "void", 41 TEXT_while = "while", 42 TEXT_with = "with", 17 43 18 44 /// Global
