lexer: add Step()/NewLine()/Reset() methods to TokenPosition

Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
2021-07-03 19:59:25 +01:00
parent 6e05cdbb28
commit 90e9fc47cf
+14
View File
@@ -23,6 +23,20 @@ type TokenPosition struct {
Row int
}
func (pos *TokenPosition) Reset() {
pos.Line = 1
pos.Row = 1
}
func (pos *TokenPosition) Step(n int) {
pos.Row += n
}
func (pos *TokenPosition) NewLine() {
pos.Line += 1
pos.Row = 1
}
// Token
type Token interface {
Type() TokenType