Differences From Artifact [5f52873e3ff7ae30]:
- File
polemy/lex.d
- 2010-11-08 11:42:14 - part of checkin [5e407d7cf8] on branch trunk - Lexer Refactored so that it can accpet multi-symbol token (user: kinaba) [annotate]
To Artifact [bee9af8d0f8f7348]:
- File
polemy/lex.d
- 2010-11-08 12:26:39 - part of checkin [80ff567c75] on branch trunk - Testing easyAST. (user: kinaba) [annotate]
27 immutable int column; /// column, 1, 2, ... 27 immutable int column; /// column, 1, 2, ...
28 28
29 override string toString() const 29 override string toString() const
30 { return sprintf!"%s:%d:%d"(filename, lineno, column); } 30 { return sprintf!"%s:%d:%d"(filename, lineno, column); }
31 31
32 mixin SimpleConstructor; 32 mixin SimpleConstructor;
33 mixin SimpleCompare; 33 mixin SimpleCompare;
> 34
> 35 static immutable LexPosition dummy;
> 36 static this(){ dummy = new immutable(LexPosition)("<unnamed>",0,0); }
34 } 37 }
35 38
36 unittest 39 unittest
37 { 40 {
38 auto p = new LexPosition("hello.cpp", 123, 45); 41 auto p = new LexPosition("hello.cpp", 123, 45);
39 auto q = new LexPosition("hello.cpp", 123, 46); 42 auto q = new LexPosition("hello.cpp", 123, 46);
40 43
................................................................................................................................................................................
57 { 60 {
58 immutable LexPosition pos; /// Position where the token occurred in t 61 immutable LexPosition pos; /// Position where the token occurred in t
59 immutable string str; /// The token string itself 62 immutable string str; /// The token string itself
60 immutable bool quoted; /// Was it a "quoted" token or unquoted? 63 immutable bool quoted; /// Was it a "quoted" token or unquoted?
61 64
62 mixin SimpleConstructor; 65 mixin SimpleConstructor;
63 mixin SimpleCompare; 66 mixin SimpleCompare;
> 67 mixin SimpleToString;
64 } 68 }
65 69
66 unittest 70 unittest
67 { 71 {
68 auto p = new immutable(LexPosition)("hello.cpp", 123, 45); 72 auto p = new immutable(LexPosition)("hello.cpp", 123, 45);
69 auto t = new Token(p, "class", false); 73 auto t = new Token(p, "class", false);
70 auto u = new Token(p, "class", true); 74 auto u = new Token(p, "class", true);