lexer

package
v0.0.0-...-20ff91b Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

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
}

func NewLexer

func NewLexer(input []byte) Lexer

func (*Lexer) Len

func (l *Lexer) Len() int

Len returns the number of tokens that have been read.

func (*Lexer) Next

func (l *Lexer) Next() (int, error)

Next reads the next token from the input and returns the number of bytes read.

func (*Lexer) Reset

func (l *Lexer) Reset()

Reset sets points to the beginning of the input and clears the tokens.

func (*Lexer) String

func (l *Lexer) String() string

func (*Lexer) Token

func (l *Lexer) Token() Token

Token returns the last token that was read.

func (*Lexer) Tokens

func (l *Lexer) Tokens() []Token

Tokens returns a copy of all tokens that have been read.

type Token

type Token struct {
	Type    TokenType
	Literal string
	Line    int
	// Col is the UTF-8 character position on the token's line.
	Col int
	// Pos is the byte position in the input where this token starts.
	Pos int
}

type TokenType

type TokenType int
const (
	EOF TokenType = iota
	NEWLINE
	WHITESPACE
	QUOTE
	LBRACE
	RBRACE
	LBRACKET
	RBRACKET
	COMMA
	COLON
	NUMBER
	STRING
	TRUE
	FALSE
	NULL
)

func (TokenType) String

func (t TokenType) String() string

Jump to

Keyboard shortcuts

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