Mercurial > projects > ddmd
comparison dmd/Lexer.d @ 168:ceed63f310fb
stringtable, stringbuffer and freelist moved to Global
author | korDen |
---|---|
date | Thu, 30 Sep 2010 12:57:13 +0400 |
parents | fe932c1a9563 |
children | e7769d53e750 |
comparison
equal
deleted
inserted
replaced
167:50a6d232176c | 168:ceed63f310fb |
---|---|
35 __gshared char* __locale_decpoint; | 35 __gshared char* __locale_decpoint; |
36 } | 36 } |
37 | 37 |
38 bool isUniAlpha(uint u) | 38 bool isUniAlpha(uint u) |
39 { | 39 { |
40 static ushort table[][2] = | 40 enum ushort table[][2] = |
41 [ | 41 [ |
42 [ 0x00AA, 0x00AA ], | 42 [ 0x00AA, 0x00AA ], |
43 [ 0x00B5, 0x00B5 ], | 43 [ 0x00B5, 0x00B5 ], |
44 [ 0x00B7, 0x00B7 ], | 44 [ 0x00B7, 0x00B7 ], |
45 [ 0x00BA, 0x00BA ], | 45 [ 0x00BA, 0x00BA ], |
342 return true; | 342 return true; |
343 } | 343 } |
344 | 344 |
345 class Lexer | 345 class Lexer |
346 { | 346 { |
347 static StringTable stringtable; | |
348 static OutBuffer stringbuffer; | |
349 static Token* freelist; | |
350 | |
351 Loc loc; // for error messages | 347 Loc loc; // for error messages |
352 | 348 |
353 ubyte* base; // pointer to start of buffer | 349 ubyte* base; // pointer to start of buffer |
354 ubyte* end; // past end of buffer | 350 ubyte* end; // past end of buffer |
355 ubyte* p; // current character | 351 ubyte* p; // current character |
356 Token token; | 352 Token token; |
357 Module mod; | 353 Module mod; |
358 int doDocComment; // collect doc comment information | 354 int doDocComment; // collect doc comment information |
359 int anyToken; // !=0 means seen at least one token | 355 int anyToken; // !=0 means seen at least one token |
360 int commentToken; // !=0 means comments are TOKcomment's | 356 int commentToken; // !=0 means comments are TOKcomment's |
361 | |
362 static this() | |
363 { | |
364 stringtable = new StringTable(); | |
365 stringbuffer = new OutBuffer(); | |
366 } | |
367 | |
368 static ~this() | |
369 { | |
370 //delete stringtable; | |
371 } | |
372 | 357 |
373 this(Module mod, ubyte* base, uint begoffset, uint endoffset, int doDocComment, int commentToken) | 358 this(Module mod, ubyte* base, uint begoffset, uint endoffset, int doDocComment, int commentToken) |
374 { | 359 { |
375 loc = Loc(mod, 1); | 360 loc = Loc(mod, 1); |
376 | 361 |
690 cmtable[c] |= CMhex; | 675 cmtable[c] |= CMhex; |
691 if (isalnum(c) || c == '_') | 676 if (isalnum(c) || c == '_') |
692 cmtable[c] |= CMidchar; | 677 cmtable[c] |= CMidchar; |
693 } | 678 } |
694 } | 679 } |
695 | 680 |
681 static StringTable stringtable() | |
682 { | |
683 return global.stringtable; | |
684 } | |
685 | |
686 static OutBuffer stringbuffer() | |
687 { | |
688 return global.stringbuffer; | |
689 } | |
690 | |
696 static void initKeywords() | 691 static void initKeywords() |
697 { | 692 { |
698 uint nkeywords = keywords.length; | 693 uint nkeywords = keywords.length; |
699 | 694 |
700 if (global.params.Dversion == 1) | 695 if (global.params.Dversion == 1) |
836 return id; | 831 return id; |
837 } | 832 } |
838 | 833 |
839 static Identifier uniqueId(string s) | 834 static Identifier uniqueId(string s) |
840 { | 835 { |
841 static int num; | 836 return uniqueId(s, ++global.num); |
842 return uniqueId(s, ++num); | |
843 } | 837 } |
844 | 838 |
845 /********************************************* | 839 /********************************************* |
846 * Create a unique identifier using the prefix s. | 840 * Create a unique identifier using the prefix s. |
847 */ | 841 */ |
862 | 856 |
863 if (token.next) | 857 if (token.next) |
864 { | 858 { |
865 t = token.next; | 859 t = token.next; |
866 memcpy(&token, t, Token.sizeof); | 860 memcpy(&token, t, Token.sizeof); |
867 t.next = freelist; | 861 t.next = global.freelist; |
868 freelist = t; | 862 global.freelist = t; |
869 } | 863 } |
870 else | 864 else |
871 { | 865 { |
872 scan(&token); | 866 scan(&token); |
873 } | 867 } |