lexer

package
v2.0.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package lexer contains the code to lex input programs into a stream of tokens. The stream of tokens can then be parsed into an AST.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lexer

type Lexer struct {
	// contains filtered or unexported fields
}

Lexer holds our object-state.

func New

func New(input string, options ...Option) *Lexer

New returns a Lexer instance for the given string input.

func (*Lexer) Filename

func (l *Lexer) Filename() string

Filename returns the name of the file being read.

func (*Lexer) GetLineText

func (l *Lexer) GetLineText(t token.Token) string

GetLineText returns the text of the line containing the given token.

func (*Lexer) Next

func (l *Lexer) Next() (token.Token, error)

Next returns the next Token from the input that is being lexed.

func (*Lexer) Position

func (l *Lexer) Position() token.Position

Position returns the current read position of the Lexer as a Position object.

func (*Lexer) SetFilename

func (l *Lexer) SetFilename(file string)

SetFilename sets the name of the file being read.

type NumberType

type NumberType string

NumberType describes the type of a number that is being lexed.

const (
	NumberTypeInvalid NumberType = "invalid"
	NumberTypeDecimal NumberType = "decimal"
	NumberTypeHex     NumberType = "hex"
	NumberTypeBinary  NumberType = "binary"
)

type Option

type Option func(*Lexer)

Option is a configuration function for a Lexer.

func WithFile

func WithFile(file string) Option

WithFile sets the file name for the Lexer.

Jump to

Keyboard shortcuts

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