scanner

package
v0.0.0-...-876207e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2017 License: GPL-3.0 Imports: 6 Imported by: 0

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

View Source
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) Close

func (scan *Scanner) Close() (err error)

Close closes all input files and discards all buffers used by the scanner.

func (*Scanner) Include

func (scan *Scanner) Include(fileName string) error

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

func (scan *Scanner) Next() bool

Next checks whether more input is available. This method must be called before every call to the .Peek() method.

func (*Scanner) Peek

func (scan *Scanner) Peek() ([]byte, error)

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().

func (*Scanner) Prepend

func (scan *Scanner) Prepend(data []byte, name string)

Prepend adds the given buffer to the list of input sources. The buffer contents are read next, followed by all previous inputs. The argument `name` is used to identify the buffer in error messages and should be a short, human-readable string.

func (*Scanner) Skip

func (scan *Scanner) Skip(n int)

Skip advances the current position in the scanner input stream by n bytes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL