Something went wrong. Try again.
🌱 A minimal programming language and compiler. git.urbach.dev/cli/q
high-performance programming-language compiler
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637package token
// Source is a region that has a start and end position in the source file.type Source struct { start Position end Position}
// NewSource creates a new source region.func NewSource(start Position, end Position) Source { return Source{start: start, end: end}}
// End returns the end position.func (s Source) End() Position { return s.end}
// SetEnd sets the end position.func (s *Source) SetEnd(end Position) { s.end = end}
// SetStart sets the start position.func (s *Source) SetStart(start Position) { s.start = start}
// Start returns the start position.func (s Source) Start() Position { return s.start}
// StringFrom returns the source code.func (s Source) StringFrom(code []byte) string { return string(code[s.Start():s.End()])}