#25: save position within node

This commit is contained in:
z7zmey
2018-06-24 10:19:44 +03:00
parent 6ac67675d5
commit 1ebb0c6fad
268 changed files with 53606 additions and 7719 deletions

View File

@@ -17,7 +17,12 @@ type Error struct {
func NewError(msg string, t *scanner.Token) *Error {
return &Error{
Msg: msg,
Pos: t.Position,
Pos: &position.Position{
StartLine: t.StartLine,
EndLine: t.EndLine,
StartPos: t.StartPos,
EndPos: t.EndPos,
},
}
}

View File

@@ -28,8 +28,11 @@ func assertEqual(t *testing.T, expected interface{}, actual interface{}) {
func TestConstructor(t *testing.T) {
pos := position.NewPosition(1, 2, 3, 4)
token := &scanner.Token{
Value: `test`,
Position: pos,
Value: `test`,
StartLine: 1,
EndLine: 2,
StartPos: 3,
EndPos: 4,
}
actual := errors.NewError("message", token)
@@ -43,10 +46,12 @@ func TestConstructor(t *testing.T) {
}
func TestPrint(t *testing.T) {
pos := position.NewPosition(1, 2, 3, 4)
token := &scanner.Token{
Value: `test`,
Position: pos,
Value: `test`,
StartLine: 1,
EndLine: 2,
StartPos: 3,
EndPos: 4,
}
Error := errors.NewError("message", token)