Fix lint errors

master
Brian Picciano 7 months ago
parent c2adfa3b46
commit da5d171479
  1. 10
      gg/decoder.go
  2. 5
      gg/grammar/location.go

@ -53,9 +53,7 @@ var (
Rune('-'),
positiveNumber,
func(neg Located[rune], posNum Located[string]) Located[string] {
return Located[string]{
neg.Location, string(neg.Value) + posNum.Value,
}
return Locate(neg.Location, string(neg.Value)+posNum.Value)
},
)
@ -68,7 +66,7 @@ var (
panic(fmt.Errorf("parsing %q as int: %w", str, err))
}
return Located[Value]{str.Location, Number(i)}
return Locate(str.Location, Number(i))
},
)
)
@ -93,7 +91,7 @@ var (
for _, r := range tail {
name = append(name, r.Value)
}
return Located[Value]{head.Location, Name(string(name))}
return Locate(head.Location, Name(string(name)))
},
)
)
@ -228,7 +226,7 @@ var graphSym, value = func() (
gs.g = new(Graph)
}
return Located[Value]{r.Location, Value{Graph: gs.g}}
return Locate(r.Location, Value{Graph: gs.g})
},
)

@ -18,6 +18,11 @@ type Located[T any] struct {
Value T
}
// Locate returns a Located instance combining the given values.
func Locate[T any](l Location, v T) Located[T] {
return Located[T]{l, v}
}
// LocatedError is an error related to a specific point within a stream of
// runes.
type LocatedError Located[error]

Loading…
Cancel
Save