lexer

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package lexer provides a lexical scanner for the oh language.

The oh lexer adapts the state function approach used by Go's text/template lexer and described in detail in Rob Pike's talk "Lexical Scanning in Go". See https://talks.golang.org/2011/lex.slide for more information.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type T

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

T holds the state of the scanner.

func New

func New(label string) *T

New creates a new lexer/scanner. Label can be a file name or other identifier.

func (*T) Copy

func (l *T) Copy() *T

Copy makes a copy of the lexer with its own token channel. A copy is useful for doing partial parses for command completion.

func (*T) Expected

func (l *T) Expected() []string

Expected returns the list of expected strings. (Command completion).

func (*T) Scan

func (l *T) Scan(text string)

Scan passes a text buffer to the lexer for scanning. If a buffer is currently being scanned, the new buffer will be appended to the list of buffers waiting to be scanned.

func (*T) Text

func (l *T) Text() string

Text is used to return the text corresponding to the current token.

func (*T) Token

func (l *T) Token() *token.T

Token returns the next scanned token, or nil if no token is available.

Jump to

Keyboard shortcuts

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