- Added `setOrigin(string)` and `getOrigin()`

Coords

- Now has a `getLine()` and `getColumn()`
This commit is contained in:
Tristan B. Velloza Kildaire 2024-04-02 10:43:15 +02:00
parent 5bea0b5298
commit aaeda4c517
1 changed files with 50 additions and 0 deletions

View File

@ -22,6 +22,12 @@ public final class Token
*/
private ulong line, column;
/**
* The line this token was
* lex'd from
*/
private string origin;
/**
* Constructs a new `Token` with the given
* contents and line information
@ -38,6 +44,30 @@ public final class Token
this.column = column;
}
/**
* Sets the origin string.
* This is the line in which
* this token was derived from.
*
* Params:
* line = the line
*/
public void setOrigin(string line)
{
this.origin = line;
}
/**
* Returns the origin string (if any)
* from which this token was derived
*
* Returns: the line
*/
public string getOrigin()
{
return this.origin;
}
/**
* Overrides the `==` operator to do equality
* based on the stored token's contents
@ -107,6 +137,26 @@ public struct Coords
this.column = column;
}
/**
* Returns the line
*
* Returns: line index
*/
public ulong getLine()
{
return this.line;
}
/**
* Returns the column
*
* Returns: column index
*/
public ulong getColumn()
{
return this.column;
}
/**
* Returns a string representation
*