Files
go-toml/position.go
T
eanderton 7c63fff960 Added Position Support to TomlTree
TomlDocument provides an optional TOML processing path where position
informaiton is stored alongside a TomlTree.
* Added Position struct
* Revised TomlTree to contain position data
* Added tomlValue to bind positions to values
* Revised parser to emit position data
* Revised token to use new Position struct
* Added tests for new functionality
* Bugfixed table array duplicate key handling
* Applied gofmt to all code
2014-08-26 21:00:41 -04:00

27 lines
512 B
Go

// Position support for go-toml
//
// BSD Licensed
// Copyright 2014 eric.t.anderton@gmail.com
package toml
import (
"fmt"
)
// position within a TOML document
type Position struct {
Line int // line within the document
Col int // column within the line
}
// String representation of the position.
// Displays 1-indexed line and column numbers.
func (p *Position) String() string {
return fmt.Sprintf("(%d, %d)", p.Line, p.Col)
}
func (p *Position) Invalid() bool {
return p.Line <= 0 || p.Col <= 0
}