Documentation ¶
Overview ¶
Package scanner is used to read in LaTeX source files as a stream of bytes. The package handles include files and keeps track of the current position in the input file for use in error messages.
Index ¶
- Constants
- type ParseError
- type Scanner
- func (scan *Scanner) Close() (err error)
- func (scan *Scanner) Include(fileName string) error
- func (scan *Scanner) MakeError(message string) *ParseError
- func (scan *Scanner) Next() bool
- func (scan *Scanner) Peek() ([]byte, error)
- func (scan *Scanner) Prepend(data []byte, name string)
- func (scan *Scanner) Skip(n int)
Constants ¶
const PeekWindowSize = 128
PeekWindowSize gives the minimum size of the lookahead buffer. Unless the end of input is reached, at least this many bytes are visible in the buffer returned by the .Peek() method.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ParseError ¶
type ParseError struct { Message string // contains filtered or unexported fields }
ParseError is used to indicate the reason and location of parse errors.
func (*ParseError) Error ¶
func (err *ParseError) Error() string
type Scanner ¶
type Scanner struct { // BaseDir is the base directory for include files. Filenames // passed to the .Include() method are interpreted as being // relative to this directory. BaseDir string // contains filtered or unexported fields }
Scanner implements methods to recursivly walk through a set of input files and buffers.
func (*Scanner) Include ¶
Include adds the contents of the given file to the list of input sources. The file contents are read next, followed by all remaining, previously registered inputs.
func (*Scanner) MakeError ¶
func (scan *Scanner) MakeError(message string) *ParseError
MakeError returns an error object which includes the given message together with human-readable information about the current input position.
func (*Scanner) Next ¶
Next checks whether more input is available. This method must be called before every call to the .Peek() method.
func (*Scanner) Peek ¶
Peek returns a buffer showing the first input bytes after the current input position. Unless the end of file is reached, this buffer is at least PeekWindowSize bytes long. The current input position is not changed by calls to .Peek().
The contents of the returned buffer are only valid until the next call to the .Skip() method. The .Next() method must be called to populate the look-ahead buffer before every call to .Peek().