parent
f47ed805b1
commit
f2cfa0bbbc
|
@ -6,8 +6,7 @@ module tlang.compiler.lexer.core.tokens;
|
|||
import std.string : cmp, format;
|
||||
import std.conv : to;
|
||||
import tlang.compiler.reporting : Coords;
|
||||
|
||||
// TODO: Below could have linof?!?!?!
|
||||
import tlang.compiler.reporting : LineInfo;
|
||||
|
||||
/**
|
||||
* Defines a `Token` that a lexer
|
||||
|
@ -120,9 +119,13 @@ public final class Token
|
|||
return Coords(this.line, this.column);
|
||||
}
|
||||
|
||||
// TODO: Switch to this
|
||||
import tlang.compiler.reporting :LineInfo;
|
||||
public LineInfo deriveLineInfo()
|
||||
/**
|
||||
* Returns the line information
|
||||
* of this particular token
|
||||
*
|
||||
* Returns: the `LineInfo`
|
||||
*/
|
||||
public LineInfo getLineInfo()
|
||||
{
|
||||
return LineInfo(getOrigin(), getCoords());
|
||||
}
|
||||
|
|
|
@ -157,13 +157,11 @@ public string report(string message, LineInfo linfo, ulong cursor = 0)
|
|||
|
||||
public string report(Token offendingToken, string message)
|
||||
{
|
||||
string line = offendingToken.getOrigin();
|
||||
|
||||
// FIXME: Double check the boundries here
|
||||
ulong pointerPos = offendingToken.getCoords().getColumn() < message.length ? offendingToken.getCoords().getColumn() : 0;
|
||||
assert(pointerPos < message.length);
|
||||
|
||||
return report(message, offendingToken.deriveLineInfo(), pointerPos);
|
||||
return report(message, offendingToken.getLineInfo(), pointerPos);
|
||||
}
|
||||
|
||||
version(unittest)
|
||||
|
|
Loading…
Reference in New Issue