#25: save position within node
This commit is contained in:
@@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user