lexer: add Step()/NewLine()/Reset() methods to TokenPosition
Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
@@ -23,6 +23,20 @@ type TokenPosition struct {
|
|||||||
Row int
|
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
|
// Token
|
||||||
type Token interface {
|
type Token interface {
|
||||||
Type() TokenType
|
Type() TokenType
|
||||||
|
|||||||
Reference in New Issue
Block a user