lexer

package
v0.0.0-...-0be312a Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2017 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFinished is returned on Start() when Lexer was started before and has not finished yet
	ErrNotFinished = errors.New("lexer still not finished lexing")

	// ErrInputStreamNil is returned on Start() if the given inputStream is nil
	ErrInputStreamNil = errors.New("input stream should not be nil")
)

Functions

func CombineStreams

func CombineStreams(streams ...<-chan rune) <-chan rune

CombineStreams creates a sequence of the given streams, processing all successively.

func StreamFromFile

func StreamFromFile(filename string) (stream <-chan rune, err error)

StreamFromFile returns a read only rune channel representing the given file content.

func StreamFromString

func StreamFromString(input string) <-chan rune

StreamFromString returns a read only rune channel representing the given string.

Types

type Lexer

type Lexer struct {
	NextToken chan token.Token
	// contains filtered or unexported fields
}

Lexer represents an instance to get a lexical representation of the source code.

It works in it's own go routine, so after creation with NewLexer get the tokens via the NextToken field.

func New

func New() *Lexer

New creates a new instance of Lexer, ready to be started.

func (*Lexer) Start

func (lex *Lexer) Start(inputStream <-chan rune) error

Start will read from the inputStream, forwarding tokens via NextToken. Start runs in its own go routine and will get a zombie if NextToken is not read!

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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