Diff
Not logged in

Differences From Artifact [594acaf3ac60594c]:

To Artifact [701f5b1b899607f2]:


5 * Error Information for Polemy Programming Language 5 * Error Information for Polemy Programming Language 6 */ 6 */ 7 module polemy.failure; 7 module polemy.failure; 8 import polemy._common; 8 import polemy._common; 9 9 10 /// Represents a position in source codes 10 /// Represents a position in source codes 11 11 > 12 alias immutable(LexPosition_t) LexPosition; > 13 > 14 /// Represents a position in source codes > 15 12 class LexPosition_t 16 class LexPosition_t 13 { 17 { 14 immutable string filename; /// name of the source file 18 immutable string filename; /// name of the source file 15 immutable int lineno; /// 1-origin 19 immutable int lineno; /// 1-origin 16 immutable int column; /// 1-origin 20 immutable int column; /// 1-origin 17 21 18 mixin SimpleClass; 22 mixin SimpleClass; ................................................................................................................................................................................ 21 return sprintf!("%s:%d:%d")(filename, lineno, column); 25 return sprintf!("%s:%d:%d")(filename, lineno, column); 22 } 26 } 23 27 24 static LexPosition dummy; 28 static LexPosition dummy; 25 static this(){ dummy = new LexPosition("<unnamed>",0,0); } 29 static this(){ dummy = new LexPosition("<unnamed>",0,0); } 26 } 30 } 27 31 28 /// Represents a position in source codes < 29 < 30 alias immutable(LexPosition_t) LexPosition; < 31 < 32 unittest 32 unittest 33 { 33 { 34 auto p = new LexPosition("hello.cpp", 123, 45); 34 auto p = new LexPosition("hello.cpp", 123, 45); 35 35 36 assert_eq( p.filename, "hello.cpp" ); 36 assert_eq( p.filename, "hello.cpp" ); 37 assert_eq( p.lineno, 123 ); 37 assert_eq( p.lineno, 123 ); 38 assert_eq( p.column, 45 ); 38 assert_eq( p.column, 45 );