| // Copyright 2015 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| // A Slice reads from a slice of Tokens. |
| func NewSlice(fileName string, line int, tokens []Token) *Slice { |
| pos: -1, // Next will advance to zero. |
| func (s *Slice) Next() ScanToken { |
| if s.pos >= len(s.tokens) { |
| return s.tokens[s.pos].ScanToken |
| func (s *Slice) Text() string { |
| return s.tokens[s.pos].text |
| func (s *Slice) File() string { |
| func (s *Slice) Line() int { |
| func (s *Slice) Col() int { |
| // Col is only called when defining a macro, which can't reach here. |
| panic("cannot happen: slice col") |
| func (s *Slice) SetPos(line int, file string) { |
| // Cannot happen because we only have slices of already-scanned |
| // text, but be prepared. |
| func (s *Slice) Close() { |