misc

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2019 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// FrSpace represents a space fragment kind
	FrSpace parser.FragmentKind

	// FrWord represents a word fragment kind
	FrWord

	// FrSign represents a special character fragment kind
	FrSign
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Lexer

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

Lexer represents a basic lexer tokenizing source code into 3 basic categories: spaces (whitespaces, tabs, line-breaks), signs (any ASCII special character) and words (any other character)

func NewLexer

func NewLexer(src *parser.SourceFile) *Lexer

NewLexer creates a new basic-latin lexer instance

func (*Lexer) Position

func (lx *Lexer) Position() parser.Cursor

Position returns the current position of the lexer

func (*Lexer) Read

func (lx *Lexer) Read() (*parser.Token, error)

Read returns either the next token or nil if end of file is reached

func (*Lexer) ReadExact

func (lx *Lexer) ReadExact(
	expectation []rune,
	kind parser.FragmentKind,
) (
	token *parser.Token,
	matched bool,
	err error,
)

ReadExact tries to read an exact string and returns false if str couldn't have been matched

func (*Lexer) ReadUntil added in v0.2.0

func (lx *Lexer) ReadUntil(
	fn func(parser.Cursor) uint,
	kind parser.FragmentKind,
) (
	token *parser.Token,
	err error,
)

ReadUntil reads until fn returns zero skipping as many runes as fn returns

func (*Lexer) Set

func (lx *Lexer) Set(cursor parser.Cursor)

Set sets a new cursor

Jump to

Keyboard shortcuts

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