Reduced token size

This commit is contained in:
2024-07-20 23:33:07 +02:00
parent 43cdac5572
commit ca36d34cb9
4 changed files with 21 additions and 17 deletions

View File

@ -14,13 +14,13 @@ type Error struct {
Err error
File *fs.File
Stack string
Position int
Position token.Position
}
// New generates an error message at the current token position.
// The error message is clickable in popular editors and leads you
// directly to the faulty file at the given line and position.
func New(err error, file *fs.File, position int) *Error {
func New(err error, file *fs.File, position token.Position) *Error {
return &Error{
Err: err,
File: file,
@ -48,12 +48,12 @@ func (e *Error) Error() string {
for _, t := range e.File.Tokens {
if t.Position >= e.Position {
column = e.Position - lineStart
column = int(e.Position) - lineStart
break
}
if t.Kind == token.NewLine {
lineStart = t.Position
lineStart = int(t.Position)
line++
}
}