lexer

package
v0.24.2 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const EOF rune = -1

Variables

This section is empty.

Functions

This section is empty.

Types

type Space added in v0.2.1

type Space struct {
	String          string
	ContainsNewline bool
}

type Token

type Token struct {
	Type  TokenType
	Value interface{}
	ast.Range
}

func (Token) Is

func (t Token) Is(ty TokenType) bool

func (Token) IsString added in v0.2.1

func (t Token) IsString(ty TokenType, s string) bool

type TokenLimitReachedError added in v0.24.0

type TokenLimitReachedError struct {
	ast.Position
}

func (TokenLimitReachedError) Error added in v0.24.0

func (t TokenLimitReachedError) Error() string

type TokenStream added in v0.20.0

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() string
	Reclaim()
}

func Lex

func Lex(input string, 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
	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 added in v0.24.0

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