pbread

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2022 License: GPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxAFew = 512
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ABuffer

type ABuffer struct {
	Buffer      []rune
	FileName    string
	AbsFileName string
	LineNo      int
	ColNo       int
	Pos         int  // # of chars since start of this file
	EofOnFile   bool // End of buffer is EOF on this file.
}

Data from file or push back save in a buffer

type PBReadType

type PBReadType struct {
	FileName    string          //
	AbsFileName string          //
	FilesOpened map[string]bool // Set of files that have been opened
	PbBuffer    []*ABuffer      //
	PbAFew      []rune          //
	PbTop       int             //
}

The read type to track file position and collect push backs.

func NewPbRead

func NewPbRead() (rv *PBReadType)

Create a new push back buffer and return it.

func (*PBReadType) Dump01

func (pb *PBReadType) Dump01(fo io.Writer)

Output debugging info

func (*PBReadType) FileSeen

func (pb *PBReadType) FileSeen(fn string) bool

Have we already seen the specified file. Useful for require(fn)

func (*PBReadType) GetPos

func (pb *PBReadType) GetPos() (LineNo int, ColNo int, FileName string)

Get the current line/col no and file name

func (*PBReadType) NextRune

func (pb *PBReadType) NextRune() (rn rune, done bool)

Return the next rune. If runes have been pushed back then use those first.

func (*PBReadType) OpenFile

func (pb *PBReadType) OpenFile(fn string) (err error)

Open a file - this puts the file at the end of the input. This is used on the command line for a list of files in order. Each opened and added to the end of the list.

func (*PBReadType) PbByteArray

func (pb *PBReadType) PbByteArray(s []byte)

Push back a string. Will be converted from an array of byte to an array of runes.

func (*PBReadType) PbFile

func (pb *PBReadType) PbFile(fn string) (err error)

Place the contents of a file in buffers at the head so NextRune will pull from this next.

func (*PBReadType) PbRune

func (pb *PBReadType) PbRune(rn rune)

Push back a single rune onto input. You can call this more than one time.

func (*PBReadType) PbRuneArray

func (pb *PBReadType) PbRuneArray(rns []rune)

Push back a slice of runes

func (*PBReadType) PbString

func (pb *PBReadType) PbString(s string)

Push back a string - will be converted form string to array of runes

func (*PBReadType) PeekRune

func (pb *PBReadType) PeekRune() (rn rune, done bool)

Take a peek at what is out there - return the next rune without advancing forward.

func (*PBReadType) SetPos

func (pb *PBReadType) SetPos(LineNo int, ColNo int, FileName string)

Set the line/col/file-name for the current buffer - Useful for constructing something like C/Pre processor's #line

Jump to

Keyboard shortcuts

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