lexer

package
v0.0.3-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package lexer provides a Lexer that takes Risor source code as input and outputs a stream of tokens to be consumed by a parser.

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"
	NumberTypeOctal   NumberType = "octal"
)

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