lexer

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockStringValue added in v0.5.0

func BlockStringValue(s []byte) (formatted []byte)

Types

type Input added in v0.5.0

type Input struct {
	Pos    int
	Line   int
	Column int
	// contains filtered or unexported fields
}

func NewInput added in v0.5.0

func NewInput(bs []byte) *Input

func (*Input) PeekOne added in v0.5.0

func (i *Input) PeekOne(n int) rune

func (*Input) PeekOneRune added in v0.5.0

func (i *Input) PeekOneRune(n int) (rune, int)

func (*Input) Reset added in v0.5.0

func (i *Input) Reset()

func (*Input) Value added in v0.5.0

func (i *Input) Value(t *Token) []byte

type Lexer added in v0.5.0

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

func NewLexer added in v0.5.0

func NewLexer(in *Input) *Lexer

func (*Lexer) Read added in v0.5.0

func (l *Lexer) Read() (t Token)

type Token

type Token struct {
	Kind TokenKind

	Value string

	Err        error
	Start, End int
	Line, Col  int
}

type TokenKind

type TokenKind int

TokenKind tells what kind of value is in the Token

const (
	// Undefined token
	Undefined TokenKind = iota
	// EOFToken -> EOF
	EOFToken
	// PunctuatorToken has special characters
	PunctuatorToken
	// NameToken has names
	NameToken // /[_A-Za-z][_0-9A-Za-z]*/
	// IntValueToken has iteger numbers
	IntValueToken // NegativeSign(opt) | NonZeroDigit | Digit (list, opt)
	// FloatValueToken has float numbers
	FloatValueToken // Sign (opt) | IntegerPart | FractionalPart (ExponentPart)
	// StringValueToken has string values
	StringValueToken // "something which is a string" | """this is also valid"""
)

func (TokenKind) String added in v0.5.0

func (tk TokenKind) String() string

Jump to

Keyboard shortcuts

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