Search and commands

↑ ↓ to select · Enter to open · Esc to close

Type to search packages.

lexer

v1.0.0
go.neonxp.ru/json/internal/lexer

Documentation

pkg.go.dev ↗

Table of contents

↓ to select · Enter to jump· Shift+Enter for source

34 matches

Top ↑

Constants

LEOF (12 declarations)

const (
	LEOF lexType = iota
	LError
	LObjectStart
	LObjectEnd
	LObjectKey
	LObjectValue
	LArrayStart
	LArrayEnd
	LString
	LNumber
	LBoolean
	LNull
)

Functions

InitJson

func InitJson(l *Lexer) stateFunc

Types

Lexem

type Lexem struct {
	Type  lexType // Type of Lexem.
	Value string  // Value of Lexem.
	Start int     // Start position at input string.
	End   int     // End position at input string.
}

Lexer

type Lexer struct {
	Input  string     // Input string.
	Start  int        // Start position of current lexem.
	Pos    int        // Pos at input string.
	Output chan Lexem // Lexems channel.
	// contains filtered or unexported fields
}

Lexer holds current scanner state.

NewLexer

func NewLexer(input string) *Lexer

newLexer returns new scanner for input string.

Lexer.Accept

func (l *Lexer) Accept(valid string) bool

Accept any rune from valid string. Returns true if Next rune was in valid string.

Lexer.AcceptAnyOf

func (l *Lexer) AcceptAnyOf(s []string, caseInsentive bool) bool

AcceptAnyOf substrings. Retuns true if any of substrings was found.

Lexer.AcceptString

func (l *Lexer) AcceptString(s string, caseInsentive bool) bool

AcceptString returns true if given string was at position.

Lexer.AcceptWhile

func (l *Lexer) AcceptWhile(valid string) bool

AcceptWhile passing symbols from input while they at `valid` string.

Lexer.AcceptWhileNot

func (l *Lexer) AcceptWhileNot(invalid string) bool

AcceptWhileNot passing symbols from input while they NOT in `invalid` string.

Lexer.AtStart

func (l *Lexer) AtStart() bool

AtStart returns true if current lexem not empty

Lexer.Back

func (l *Lexer) Back()

Back move position to previos rune.

Lexer.Emit

func (l *Lexer) Emit(typ lexType)

Emit current lexem to output.

Lexer.Errorf

func (l *Lexer) Errorf(format string, args ...interface{}) stateFunc

Errorf produces error lexem and stops scanning.

Lexer.Ignore

func (l *Lexer) Ignore()

Ignore previosly buffered text.

Lexer.Next

func (l *Lexer) Next() (r rune)

Next rune from input.

Lexer.Peek

func (l *Lexer) Peek() (r rune)

Peek rune at current position without moving position.

Lexer.PopState

func (l *Lexer) PopState() stateFunc

PopState returns previous state function.

Lexer.PushState

func (l *Lexer) PushState(s stateFunc)

PushState pushes state before going deeper states.

Lexer.Run

func (l *Lexer) Run(init stateFunc)

Run lexing.

Dependency graph