lexer

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const EOF rune = -1

Variables

This section is empty.

Functions

func IsIdentifierRune added in v1.0.0

func IsIdentifierRune(r rune) bool

func IsValidIdentifier added in v1.0.0

func IsValidIdentifier(s string) bool

Types

type Space

type Space struct {
	ContainsNewline bool
}

type Token

type Token struct {
	SpaceOrError any
	ast.Range
	Type TokenType
}

func (Token) Is

func (t Token) Is(ty TokenType) bool

func (Token) Source added in v0.27.0

func (t Token) Source(input []byte) []byte

type TokenLimitReachedError

type TokenLimitReachedError struct {
	ast.Position
}

func (TokenLimitReachedError) Error

func (TokenLimitReachedError) IsUserError

func (TokenLimitReachedError) IsUserError()

type TokenStream

type TokenStream interface {
	// Next consumes and returns one Token. If there are no tokens remaining, it returns Token{TokenEOF}
	Next() Token
	Cursor() int
	Revert(cursor int)
	// Input returns the whole input as source code
	Input() []byte
	Reclaim()
}

func Lex

func Lex(input []byte, memoryGauge common.MemoryGauge) TokenStream

type TokenType

type TokenType uint8
const (
	TokenError TokenType = iota
	TokenEOF
	TokenSpace
	TokenBinaryIntegerLiteral
	TokenOctalIntegerLiteral
	TokenDecimalIntegerLiteral
	TokenHexadecimalIntegerLiteral
	TokenUnknownBaseIntegerLiteral
	TokenFixedPointNumberLiteral
	TokenIdentifier
	TokenString
	TokenPlus
	TokenMinus
	TokenStar
	TokenSlash
	TokenPercent
	TokenDoubleQuestionMark
	TokenParenOpen
	TokenParenClose
	TokenBraceOpen
	TokenBraceClose
	TokenBracketOpen
	TokenBracketClose
	TokenQuestionMark
	TokenQuestionMarkDot
	TokenComma
	TokenColon
	TokenDot
	TokenSemicolon
	TokenLeftArrow
	TokenLeftArrowExclamation
	TokenRightArrow
	TokenSwap
	TokenLess
	TokenLessEqual
	TokenLessLess
	TokenGreater
	TokenGreaterEqual
	TokenEqual
	TokenEqualEqual
	TokenExclamationMark
	TokenNotEqual
	TokenBlockCommentStart
	TokenBlockCommentEnd
	TokenBlockCommentContent
	TokenLineComment
	TokenAmpersand
	TokenAmpersandAmpersand
	TokenCaret
	TokenVerticalBar
	TokenVerticalBarVerticalBar
	TokenAt
	TokenAsExclamationMark
	TokenAsQuestionMark
	TokenPragma
	// NOTE: not an actual token, must be last item
	TokenMax
)

func (TokenType) IsIntegerLiteral

func (t TokenType) IsIntegerLiteral() bool

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