lexer

package
v0.0.0-...-3ee6b4a Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorAt

func ErrorAt(t position, format string, args ...interface{}) error

func Write

func Write(w io.Writer, toks []Token) error

Types

type BlockEnd

type BlockEnd struct{ Position }

func (BlockEnd) String

func (BlockEnd) String() string

type BlockStart

type BlockStart struct{ Position }

func (BlockStart) String

func (BlockStart) String() string

type Colon

type Colon struct{ Position }

func (Colon) String

func (Colon) String() string

type Comma

type Comma struct{ Position }

func (Comma) String

func (Comma) String() string

type Identifier

type Identifier struct {
	Position
	Text string
}

func (Identifier) String

func (t Identifier) String() string

type ListEnd

type ListEnd struct{ Position }

func (ListEnd) String

func (ListEnd) String() string

type ListStart

type ListStart struct{ Position }

func (ListStart) String

func (ListStart) String() string

type Number

type Number struct {
	Position
	Value      int
	Quantifier Quantifier
}

func (Number) String

func (t Number) String() string

type Options

type Options struct {
	NoPosition bool
	MaxTokens  int
}

type Position

type Position struct {
	Line int
	Col  int
}

func LineCol

func LineCol(line, col int) Position

func (Position) LineCol

func (l Position) LineCol() (int, int)

type Quantifier

type Quantifier byte
const (
	None Quantifier = '\x00'
	Kilo Quantifier = 'K'
	Mega Quantifier = 'M'
	Giga Quantifier = 'G'
)

func (Quantifier) Multiplier

func (q Quantifier) Multiplier() int

type Semicolon

type Semicolon struct{ Position }

func (Semicolon) String

func (Semicolon) String() string

type Stream

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

func NewStream

func NewStream(toks []Token) *Stream

func (*Stream) Err

func (s *Stream) Err(format string, args ...interface{}) error

func (*Stream) Last

func (s *Stream) Last() Token

func (*Stream) Peek

func (s *Stream) Peek() Token

func (*Stream) Pop

func (s *Stream) Pop() Token

type String

type String struct {
	Position
	Text string
}

func (String) String

func (t String) String() string

type TestListEnd

type TestListEnd struct{ Position }

func (TestListEnd) String

func (TestListEnd) String() string

type TestListStart

type TestListStart struct{ Position }

func (TestListStart) String

func (TestListStart) String() string

type Token

type Token interface {
	LineCol() (int, int)
	String() string
}

func Lex

func Lex(r io.Reader, opts *Options) ([]Token, error)

Jump to

Keyboard shortcuts

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