using System; namespace TLang.Lexer { public class LexLineInfo : IEquatable { public LexLineInfo() { Line = 1; Position = 0; Column = 1; FileName="memory.tlang"; } public string FileName {get;set;} public int Line {get;set;} public int Column {get;set;} public int Position {get;set;} public void AppendChar(char c) { Position++; if(c == '\t') { Column += 4; } else if(c == '\r') { Column = 1; } else if(c == '\n') { Column = 1; Line += 1; } else { Column++; } } public LexLineInfo Clone() { LexLineInfo lineInfo=new LexLineInfo(); lineInfo.Column = Column; lineInfo.FileName = FileName; lineInfo.Line = Line; lineInfo.Position = Position; return lineInfo; } public bool Equals(LexLineInfo other) { return Line == other.Line && Column == other.Column && FileName == other.FileName && Position == other.Position; } public override string ToString() { return $"in file: {FileName}:{Line} offset: {Position}, col: {Column}"; } } }