lexer

package
v0.0.0-...-fbe25eb Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyToken = Token{Type: TTEOF, Lexeme: ""}

Functions

func TokenTypeName

func TokenTypeName(tt TokenType) string

Types

type Token

type Token struct {
	Type       TokenType
	Lexeme     string
	LineNumber int
}

Token represents a lexed Token

func Lex

func Lex(src string) ([]Token, error)

Lex walks the specified string and returns an array of lexed Tokens or an non-nil error if the input could not be lexed.

func (Token) ParseColor

func (t Token) ParseColor() lang.Color

func (Token) ParseNumber

func (t Token) ParseNumber() lang.Number

func (Token) ParseString

func (t Token) ParseString() string

func (Token) String

func (t Token) String() string

type TokenType

type TokenType int

TokenType represents the type of Token

const (
	TTNumber TokenType = iota
	TTIdent
	TTString
	TTColor
	TTAnd
	TTOr
	TTColonEq
	TTEq
	TTEqEq
	TTNeq
	TTGt
	TTGe
	TTLt
	TTLe
	TTPlus
	TTMinus
	TTStar
	TTSlash
	TTPercent
	TTLParen
	TTRParen
	TTNot
	TTAt
	TTComma
	TTDot
	TTSemicolon
	TTFor
	TTIn
	TTYield
	TTDotDot
	TTIf
	TTElse
	TTLBrace
	TTRBrace
	TTLBracket
	TTRBracket
	TTTrue
	TTFalse
	TTQMark
	TTColon
	TTLog
	TTFn
	TTReturn
	TTArrow
	TTNil
	TTPipe
	TTColonColon
	TTWhile
	TTDollar
	TTEOF
)

The types of tokens that can be lexed

Jump to

Keyboard shortcuts

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