FINALLY errors and lexer agree on row/col positions properly
This commit is contained in:
parent
4d2d52b425
commit
62c96ed761
|
@ -24,8 +24,11 @@ func (pos Position) Format () string {
|
|||
line := formatTabs(pos.Line)
|
||||
output := fmt.Sprintf("%-4d | %s\n ", pos.Row + 1, line)
|
||||
|
||||
start := getXInTabbedString(pos.Line, pos.Start)
|
||||
end := getXInTabbedString(pos.Line, pos.End)
|
||||
start := pos.Start
|
||||
end := pos.End
|
||||
if end <= start { end = start + 1 }
|
||||
start = getXInTabbedString(pos.Line, start)
|
||||
end = getXInTabbedString(pos.Line, end)
|
||||
|
||||
for index := range line {
|
||||
if index >= end { break }
|
||||
|
|
|
@ -383,8 +383,8 @@ func (this *fsplLexer) pos () errors.Position {
|
|||
return errors.Position {
|
||||
File: this.filename,
|
||||
Line: this.lineScanner.Text(),
|
||||
Row: this.row,
|
||||
Start: this.column,
|
||||
Row: this.row - 1,
|
||||
Start: this.column - 1,
|
||||
End: this.column,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ testString(test, "", tok(EOF, ""))
|
|||
|
||||
func TestLexerErrUnexpectedRune (test *testing.T) {
|
||||
testStringErr(test,
|
||||
"unexpected rune '\"'", `ooo " hahsdklhasldk`, 3, 5,
|
||||
"unexpected rune '\"'", `ooo " hahsdklhasldk`, 2, 4,
|
||||
`
|
||||
valid tokens valid tokens
|
||||
ooo " hahsdklhasldk
|
||||
|
@ -23,7 +23,7 @@ tok(0, ""),
|
|||
|
||||
func TestLexerErrUnexpectedEOF (test *testing.T) {
|
||||
testStringErr(test,
|
||||
"unexpected EOF", `'this is a string that does not end...`, 2, 39,
|
||||
"unexpected EOF", `'this is a string that does not end...`, 1, 38,
|
||||
`
|
||||
'this is a string that does not end...`,
|
||||
tok(String, "this is a string that does not end..."),
|
||||
|
|
Loading…
Reference in New Issue